Merged in feat/membership-schema-update (pull request #1459)
Update membership schema to adapt for API changes Approved-by: Michael Zetterberg
This commit is contained in:
@@ -89,8 +89,8 @@
|
|||||||
"Booking code": "Bookingkode",
|
"Booking code": "Bookingkode",
|
||||||
"Booking confirmation": "Booking bekræftelse",
|
"Booking confirmation": "Booking bekræftelse",
|
||||||
"Booking number": "Bookingnummer",
|
"Booking number": "Bookingnummer",
|
||||||
"Booking number {value}": "Booking number {value}",
|
|
||||||
"Booking number is required": "Bookingnummer er påkrævet",
|
"Booking number is required": "Bookingnummer er påkrævet",
|
||||||
|
"Booking number {value}": "Booking number {value}",
|
||||||
"Booking policy": "Booking politik",
|
"Booking policy": "Booking politik",
|
||||||
"Booking summary": "Opsummering",
|
"Booking summary": "Opsummering",
|
||||||
"Breakfast": "Morgenmad",
|
"Breakfast": "Morgenmad",
|
||||||
@@ -477,8 +477,8 @@
|
|||||||
"Password": "Adgangskode",
|
"Password": "Adgangskode",
|
||||||
"Pay later": "Betal senere",
|
"Pay later": "Betal senere",
|
||||||
"Pay now": "Betal nu",
|
"Pay now": "Betal nu",
|
||||||
"Pay with Card": "Pay with Card",
|
|
||||||
"Pay the member price of {amount} for Room {roomNr}": "Betal medlemsprisen på {amount} til værelse {roomNr}",
|
"Pay the member price of {amount} for Room {roomNr}": "Betal medlemsprisen på {amount} til værelse {roomNr}",
|
||||||
|
"Pay with Card": "Pay with Card",
|
||||||
"Pay with card": "Betal med kort",
|
"Pay with card": "Betal med kort",
|
||||||
"Pay with points": "Betal med point",
|
"Pay with points": "Betal med point",
|
||||||
"Payment": "Betaling",
|
"Payment": "Betaling",
|
||||||
|
|||||||
@@ -90,8 +90,8 @@
|
|||||||
"Booking code": "Buchungscode",
|
"Booking code": "Buchungscode",
|
||||||
"Booking confirmation": "Buchungsbestätigung",
|
"Booking confirmation": "Buchungsbestätigung",
|
||||||
"Booking number": "Buchungsnummer",
|
"Booking number": "Buchungsnummer",
|
||||||
"Booking number {value}": "Booking number {value}",
|
|
||||||
"Booking number is required": "Buchungsnummer ist erforderlich",
|
"Booking number is required": "Buchungsnummer ist erforderlich",
|
||||||
|
"Booking number {value}": "Booking number {value}",
|
||||||
"Booking policy": "Buchungsbedingungen",
|
"Booking policy": "Buchungsbedingungen",
|
||||||
"Booking summary": "Zusammenfassung",
|
"Booking summary": "Zusammenfassung",
|
||||||
"Breakfast": "Frühstück",
|
"Breakfast": "Frühstück",
|
||||||
|
|||||||
@@ -88,8 +88,8 @@
|
|||||||
"Booking code": "Booking code",
|
"Booking code": "Booking code",
|
||||||
"Booking confirmation": "Booking confirmation",
|
"Booking confirmation": "Booking confirmation",
|
||||||
"Booking number": "Booking number",
|
"Booking number": "Booking number",
|
||||||
"Booking number {value}": "Booking number {value}",
|
|
||||||
"Booking number is required": "Booking number is required",
|
"Booking number is required": "Booking number is required",
|
||||||
|
"Booking number {value}": "Booking number {value}",
|
||||||
"Booking policy": "Booking policy",
|
"Booking policy": "Booking policy",
|
||||||
"Booking summary": "Booking summary",
|
"Booking summary": "Booking summary",
|
||||||
"Breakfast": "Breakfast",
|
"Breakfast": "Breakfast",
|
||||||
|
|||||||
@@ -88,8 +88,8 @@
|
|||||||
"Booking code": "Varauskoodi",
|
"Booking code": "Varauskoodi",
|
||||||
"Booking confirmation": "Varausvahvistus",
|
"Booking confirmation": "Varausvahvistus",
|
||||||
"Booking number": "Varausnumero",
|
"Booking number": "Varausnumero",
|
||||||
"Booking number {value}": "Booking number {value}",
|
|
||||||
"Booking number is required": "Varausnumero vaaditaan",
|
"Booking number is required": "Varausnumero vaaditaan",
|
||||||
|
"Booking number {value}": "Booking number {value}",
|
||||||
"Booking policy": "Varauskäytäntö",
|
"Booking policy": "Varauskäytäntö",
|
||||||
"Booking summary": "Yhteenveto",
|
"Booking summary": "Yhteenveto",
|
||||||
"Breakfast": "Aamiainen",
|
"Breakfast": "Aamiainen",
|
||||||
|
|||||||
@@ -88,8 +88,8 @@
|
|||||||
"Booking code": "Bestillingskode",
|
"Booking code": "Bestillingskode",
|
||||||
"Booking confirmation": "Bestillingsbekreftelse",
|
"Booking confirmation": "Bestillingsbekreftelse",
|
||||||
"Booking number": "Bestillingsnummer",
|
"Booking number": "Bestillingsnummer",
|
||||||
"Booking number {value}": "Booking number {value}",
|
|
||||||
"Booking number is required": "Bookingnummer er påkrevd",
|
"Booking number is required": "Bookingnummer er påkrevd",
|
||||||
|
"Booking number {value}": "Booking number {value}",
|
||||||
"Booking policy": "Bestillingsbetingelser",
|
"Booking policy": "Bestillingsbetingelser",
|
||||||
"Booking summary": "Sammendrag",
|
"Booking summary": "Sammendrag",
|
||||||
"Breakfast": "Frokost",
|
"Breakfast": "Frokost",
|
||||||
@@ -475,9 +475,9 @@
|
|||||||
"Password": "Passord",
|
"Password": "Passord",
|
||||||
"Pay later": "Betal senere",
|
"Pay later": "Betal senere",
|
||||||
"Pay now": "Betal nå",
|
"Pay now": "Betal nå",
|
||||||
|
"Pay the member price of {amount} for Room {roomNr}": "Betal medlemsprisen på {amount} for rom {roomNr}",
|
||||||
"Pay with Card": "Pay with Card",
|
"Pay with Card": "Pay with Card",
|
||||||
"Pay with points": "Pay with points",
|
"Pay with points": "Pay with points",
|
||||||
"Pay the member price of {amount} for Room {roomNr}": "Betal medlemsprisen på {amount} for rom {roomNr}",
|
|
||||||
"Payment": "Betaling",
|
"Payment": "Betaling",
|
||||||
"Payment Guarantee": "Garantera betalning",
|
"Payment Guarantee": "Garantera betalning",
|
||||||
"Payment details": "Payment details",
|
"Payment details": "Payment details",
|
||||||
|
|||||||
@@ -88,8 +88,8 @@
|
|||||||
"Booking code": "Bokningskod",
|
"Booking code": "Bokningskod",
|
||||||
"Booking confirmation": "Bokningsbekräftelse",
|
"Booking confirmation": "Bokningsbekräftelse",
|
||||||
"Booking number": "Bokningsnummer",
|
"Booking number": "Bokningsnummer",
|
||||||
"Booking number {value}": "Booking number {value}",
|
|
||||||
"Booking number is required": "Bokningsnummer krävs",
|
"Booking number is required": "Bokningsnummer krävs",
|
||||||
|
"Booking number {value}": "Booking number {value}",
|
||||||
"Booking policy": "Bokningsvillkor",
|
"Booking policy": "Bokningsvillkor",
|
||||||
"Booking summary": "Sammanfattning",
|
"Booking summary": "Sammanfattning",
|
||||||
"Breakfast": "Frukost",
|
"Breakfast": "Frukost",
|
||||||
@@ -475,9 +475,9 @@
|
|||||||
"Password": "Lösenord",
|
"Password": "Lösenord",
|
||||||
"Pay later": "Betala senare",
|
"Pay later": "Betala senare",
|
||||||
"Pay now": "Betala nu",
|
"Pay now": "Betala nu",
|
||||||
|
"Pay the member price of {amount} for Room {roomNr}": "Betala medlemspriset på {amount} för rum {roomNr}",
|
||||||
"Pay with Card": "Pay with Card",
|
"Pay with Card": "Pay with Card",
|
||||||
"Pay with points": "Pay with points",
|
"Pay with points": "Pay with points",
|
||||||
"Pay the member price of {amount} for Room {roomNr}": "Betala medlemspriset på {amount} för rum {roomNr}",
|
|
||||||
"Payment": "Betalning",
|
"Payment": "Betalning",
|
||||||
"Payment Guarantee": "Garantera betalning",
|
"Payment Guarantee": "Garantera betalning",
|
||||||
"Payment details": "Payment details",
|
"Payment details": "Payment details",
|
||||||
|
|||||||
@@ -2,17 +2,14 @@ import { z } from "zod"
|
|||||||
|
|
||||||
import { countriesMap } from "@/constants/countries"
|
import { countriesMap } from "@/constants/countries"
|
||||||
|
|
||||||
import { getMembership } from "@/utils/user"
|
import { getMembership, scandicMemberships } from "@/utils/user"
|
||||||
|
|
||||||
import { imageSchema } from "../hotels/schemas/image"
|
import { imageSchema } from "../hotels/schemas/image"
|
||||||
|
|
||||||
export const membershipSchema = z.object({
|
const commonMembershipSchema = z.object({
|
||||||
currentPoints: z.number(),
|
currentPoints: z.number().optional(),
|
||||||
expirationDate: z.string(),
|
expirationDate: z.string().optional(),
|
||||||
membershipNumber: z.string(),
|
|
||||||
membershipLevel: z.string().optional(),
|
membershipLevel: z.string().optional(),
|
||||||
memberSince: z.string(),
|
|
||||||
membershipType: z.string(),
|
|
||||||
nextLevel: z.string().optional(),
|
nextLevel: z.string().optional(),
|
||||||
nightsToTopTier: z.number().optional(),
|
nightsToTopTier: z.number().optional(),
|
||||||
pointsExpiryDate: z.string().optional(),
|
pointsExpiryDate: z.string().optional(),
|
||||||
@@ -21,6 +18,34 @@ export const membershipSchema = z.object({
|
|||||||
tierExpirationDate: z.string().optional(),
|
tierExpirationDate: z.string().optional(),
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const membershipType = (membershipType: scandicMemberships) =>
|
||||||
|
z
|
||||||
|
.string()
|
||||||
|
// The memberships enum is in lower case so this makes sure it will match regardless of casing in the API response.
|
||||||
|
.transform((s) => s.toLowerCase())
|
||||||
|
.pipe(z.literal(membershipType))
|
||||||
|
|
||||||
|
const friendsMembershipSchema = z
|
||||||
|
.object({
|
||||||
|
membershipType: membershipType(scandicMemberships.guestpr),
|
||||||
|
membershipNumber: z.string(),
|
||||||
|
memberSince: z.string(),
|
||||||
|
})
|
||||||
|
.merge(commonMembershipSchema)
|
||||||
|
|
||||||
|
const otherMembershipSchema = z
|
||||||
|
.object({
|
||||||
|
membershipType: z.string(),
|
||||||
|
membershipNumber: z.string().optional(),
|
||||||
|
memberSince: z.string().optional(),
|
||||||
|
})
|
||||||
|
.merge(commonMembershipSchema)
|
||||||
|
|
||||||
|
export const membershipSchema = z.union([
|
||||||
|
friendsMembershipSchema,
|
||||||
|
otherMembershipSchema,
|
||||||
|
])
|
||||||
|
|
||||||
export const getUserSchema = z
|
export const getUserSchema = z
|
||||||
.object({
|
.object({
|
||||||
data: z.object({
|
data: z.object({
|
||||||
|
|||||||
@@ -1,13 +1,12 @@
|
|||||||
import { z } from "zod"
|
import type { z } from "zod"
|
||||||
|
|
||||||
import {
|
import type { RouterOutput } from "@/lib/trpc/client"
|
||||||
|
import type {
|
||||||
creditCardSchema,
|
creditCardSchema,
|
||||||
getUserSchema,
|
getUserSchema,
|
||||||
membershipSchema,
|
membershipSchema,
|
||||||
} from "@/server/routers/user/output"
|
} from "@/server/routers/user/output"
|
||||||
|
|
||||||
import type { RouterOutput } from "@/lib/trpc/client"
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* All extended field needs to be added by API team to response or
|
* All extended field needs to be added by API team to response or
|
||||||
* we have to get the values from elsewhere
|
* we have to get the values from elsewhere
|
||||||
@@ -18,6 +17,6 @@ export type SafeUser = RouterOutput["user"]["getSafely"]
|
|||||||
|
|
||||||
export type CreditCard = z.output<typeof creditCardSchema>
|
export type CreditCard = z.output<typeof creditCardSchema>
|
||||||
|
|
||||||
export interface Membership extends z.output<typeof membershipSchema> {}
|
export type Membership = z.output<typeof membershipSchema>
|
||||||
|
|
||||||
export type Memberships = Membership[]
|
export type Memberships = Membership[]
|
||||||
|
|||||||
@@ -1,14 +1,14 @@
|
|||||||
import { z } from "zod"
|
|
||||||
|
|
||||||
import {
|
import {
|
||||||
MembershipLevel,
|
type MembershipLevel,
|
||||||
MembershipLevelEnum,
|
MembershipLevelEnum,
|
||||||
} from "@/constants/membershipLevels"
|
} from "@/constants/membershipLevels"
|
||||||
import { getMembershipCardsSchema } from "@/server/routers/user/output"
|
|
||||||
|
import type { z } from "zod"
|
||||||
|
|
||||||
import type { Membership, Memberships, User } from "@/types/user"
|
import type { Membership, Memberships, User } from "@/types/user"
|
||||||
|
import type { getMembershipCardsSchema } from "@/server/routers/user/output"
|
||||||
|
|
||||||
enum scandicMemberships {
|
export enum scandicMemberships {
|
||||||
guestpr = "guestpr",
|
guestpr = "guestpr",
|
||||||
scandicfriends = "scandicfriend's",
|
scandicfriends = "scandicfriend's",
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user