Revert "feat: use v1 profile api"
This reverts commit61e6d7ee39and2cfdbc19a9.
This commit is contained in:
@@ -11,7 +11,7 @@ export const getUserSchema = z.object({
|
|||||||
}),
|
}),
|
||||||
dateOfBirth: z.string(),
|
dateOfBirth: z.string(),
|
||||||
email: z.string().email(),
|
email: z.string().email(),
|
||||||
firstName: z.string(),
|
name: z.string(),
|
||||||
language: z.string(),
|
language: z.string(),
|
||||||
lastName: z.string(),
|
lastName: z.string(),
|
||||||
membership: z
|
membership: z
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ function fakingRequest<T>(payload: T): Promise<T> {
|
|||||||
|
|
||||||
export const userQueryRouter = router({
|
export const userQueryRouter = router({
|
||||||
get: protectedProcedure.query(async function ({ ctx }) {
|
get: protectedProcedure.query(async function ({ ctx }) {
|
||||||
const apiResponse = await api.get(api.endpoints.v1.profile, {
|
const apiResponse = await api.get(api.endpoints.v0.profile, {
|
||||||
cache: "no-store",
|
cache: "no-store",
|
||||||
headers: {
|
headers: {
|
||||||
Authorization: `Bearer ${ctx.session.token.access_token}`,
|
Authorization: `Bearer ${ctx.session.token.access_token}`,
|
||||||
@@ -43,11 +43,11 @@ export const userQueryRouter = router({
|
|||||||
}
|
}
|
||||||
|
|
||||||
const apiJson = await apiResponse.json()
|
const apiJson = await apiResponse.json()
|
||||||
if (!apiJson.data?.attributes) {
|
if (!apiJson.data?.length) {
|
||||||
throw notFound(apiJson)
|
throw notFound(apiJson)
|
||||||
}
|
}
|
||||||
|
|
||||||
const verifiedData = getUserSchema.safeParse(apiJson.data.attributes)
|
const verifiedData = getUserSchema.safeParse(apiJson.data[0].attributes)
|
||||||
if (!verifiedData.success) {
|
if (!verifiedData.success) {
|
||||||
throw internalServerError(verifiedData.error)
|
throw internalServerError(verifiedData.error)
|
||||||
}
|
}
|
||||||
@@ -55,7 +55,8 @@ export const userQueryRouter = router({
|
|||||||
return {
|
return {
|
||||||
...extendedUser,
|
...extendedUser,
|
||||||
...verifiedData.data,
|
...verifiedData.data,
|
||||||
name: `${verifiedData.data.firstName} ${verifiedData.data.lastName}`,
|
firstName: verifiedData.data.name,
|
||||||
|
name: `${verifiedData.data.name} ${verifiedData.data.lastName}`,
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
|
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ type Victory = {
|
|||||||
* we have to get the values from elsewhere
|
* we have to get the values from elsewhere
|
||||||
*/
|
*/
|
||||||
export interface User extends z.infer<typeof getUserSchema> {
|
export interface User extends z.infer<typeof getUserSchema> {
|
||||||
name: string
|
firstName: string
|
||||||
journeys: Journey[]
|
journeys: Journey[]
|
||||||
nights: number
|
nights: number
|
||||||
shortcuts: ShortcutLink[]
|
shortcuts: ShortcutLink[]
|
||||||
|
|||||||
Reference in New Issue
Block a user