feat: use v1 profile api
This commit is contained in:
@@ -11,7 +11,7 @@ export const getUserSchema = z.object({
|
||||
}),
|
||||
dateOfBirth: z.string(),
|
||||
email: z.string().email(),
|
||||
name: z.string(),
|
||||
firstName: z.string(),
|
||||
language: z.string(),
|
||||
lastName: z.string(),
|
||||
membership: z
|
||||
|
||||
@@ -22,7 +22,7 @@ function fakingRequest<T>(payload: T): Promise<T> {
|
||||
|
||||
export const userQueryRouter = router({
|
||||
get: protectedProcedure.query(async function ({ ctx }) {
|
||||
const apiResponse = await api.get(api.endpoints.v0.profile, {
|
||||
const apiResponse = await api.get(api.endpoints.v1.profile, {
|
||||
cache: "no-store",
|
||||
headers: {
|
||||
Authorization: `Bearer ${ctx.session.token.access_token}`,
|
||||
@@ -43,11 +43,11 @@ export const userQueryRouter = router({
|
||||
}
|
||||
|
||||
const apiJson = await apiResponse.json()
|
||||
if (!apiJson.data?.length) {
|
||||
if (!apiJson.data?.attributes) {
|
||||
throw notFound(apiJson)
|
||||
}
|
||||
|
||||
const verifiedData = getUserSchema.safeParse(apiJson.data[0].attributes)
|
||||
const verifiedData = getUserSchema.safeParse(apiJson.data.attributes)
|
||||
if (!verifiedData.success) {
|
||||
throw internalServerError(verifiedData.error)
|
||||
}
|
||||
@@ -55,8 +55,7 @@ export const userQueryRouter = router({
|
||||
return {
|
||||
...extendedUser,
|
||||
...verifiedData.data,
|
||||
firstName: verifiedData.data.name,
|
||||
name: `${verifiedData.data.name} ${verifiedData.data.lastName}`,
|
||||
name: `${verifiedData.data.firstName} ${verifiedData.data.lastName}`,
|
||||
}
|
||||
}),
|
||||
|
||||
|
||||
Reference in New Issue
Block a user