feat(SW-66, SW-348): search functionality and ui
This commit is contained in:
@@ -1,40 +1,54 @@
|
||||
import { z } from "zod"
|
||||
|
||||
import { countriesMap } from "@/components/TempDesignSystem/Form/Country/countries"
|
||||
import { getMembership } from "@/utils/user"
|
||||
|
||||
export const getUserSchema = z.object({
|
||||
address: z.object({
|
||||
city: z.string().optional(),
|
||||
country: z.string().optional(),
|
||||
countryCode: z.nativeEnum(countriesMap).optional(),
|
||||
streetAddress: z.string().optional(),
|
||||
zipCode: z.string().optional(),
|
||||
}),
|
||||
dateOfBirth: z.string().optional().default("1900-01-01"),
|
||||
email: z.string().email(),
|
||||
firstName: z.string(),
|
||||
language: z.string().optional(),
|
||||
lastName: z.string(),
|
||||
memberships: z.array(
|
||||
z.object({
|
||||
currentPoints: z.number(),
|
||||
expirationDate: z.string(),
|
||||
membershipNumber: z.string(),
|
||||
membershipLevel: z.string().optional(),
|
||||
memberSince: z.string(),
|
||||
membershipType: z.string(),
|
||||
nextLevel: z.string().optional(),
|
||||
nightsToTopTier: z.number().optional(),
|
||||
pointsExpiryDate: z.string().optional(),
|
||||
pointsRequiredToNextlevel: z.number().optional(),
|
||||
pointsToExpire: z.number().optional(),
|
||||
tierExpirationDate: z.string().optional(),
|
||||
})
|
||||
),
|
||||
phoneNumber: z.string().optional(),
|
||||
profileId: z.string(),
|
||||
export const membershipSchema = z.object({
|
||||
currentPoints: z.number(),
|
||||
expirationDate: z.string(),
|
||||
membershipNumber: z.string(),
|
||||
membershipLevel: z.string().optional(),
|
||||
memberSince: z.string(),
|
||||
membershipType: z.string(),
|
||||
nextLevel: z.string().optional(),
|
||||
nightsToTopTier: z.number().optional(),
|
||||
pointsExpiryDate: z.string().optional(),
|
||||
pointsRequiredToNextlevel: z.number().optional(),
|
||||
pointsToExpire: z.number().optional(),
|
||||
tierExpirationDate: z.string().optional(),
|
||||
})
|
||||
|
||||
export const getUserSchema = z
|
||||
.object({
|
||||
data: z.object({
|
||||
attributes: z.object({
|
||||
address: z.object({
|
||||
city: z.string().optional(),
|
||||
country: z.string().optional(),
|
||||
countryCode: z.nativeEnum(countriesMap).optional(),
|
||||
streetAddress: z.string().optional(),
|
||||
zipCode: z.string().optional(),
|
||||
}),
|
||||
dateOfBirth: z.string().optional().default("1900-01-01"),
|
||||
email: z.string().email(),
|
||||
firstName: z.string(),
|
||||
language: z.string().optional(),
|
||||
lastName: z.string(),
|
||||
memberships: z.array(membershipSchema),
|
||||
phoneNumber: z.string().optional(),
|
||||
profileId: z.string(),
|
||||
}),
|
||||
type: z.string(),
|
||||
}),
|
||||
})
|
||||
.transform((apiResponse) => {
|
||||
return {
|
||||
...apiResponse.data.attributes,
|
||||
membership: getMembership(apiResponse.data.attributes.memberships),
|
||||
name: `${apiResponse.data.attributes.firstName} ${apiResponse.data.attributes.lastName}`,
|
||||
}
|
||||
})
|
||||
|
||||
// Schema is the same for upcoming and previous stays endpoints
|
||||
export const getStaysSchema = z.object({
|
||||
data: z.array(
|
||||
|
||||
Reference in New Issue
Block a user