* feat(SW-3516): Include partnerLoyaltyNumber on bookings - Added user context to BookingFlowProviders for user state management. - Updated booking input and output schemas to accommodate new user data. - Refactored booking mutation logic to include user-related information. - Improved type definitions for better TypeScript support across booking components. Approved-by: Anton Gunnarsson
36 lines
778 B
TypeScript
36 lines
778 B
TypeScript
"use client"
|
|
|
|
import { createContext } from "react"
|
|
|
|
type BaseUser = {
|
|
firstName: string | null
|
|
lastName: string | null
|
|
email: string
|
|
}
|
|
|
|
export type BookingFlowUser =
|
|
| (BaseUser & {
|
|
type: "partner-sas"
|
|
partnerLoyaltyNumber: `EB${string}`
|
|
})
|
|
| (BaseUser & {
|
|
type: "scandic"
|
|
/**
|
|
* This will always be null for Scandic Friends members
|
|
*/
|
|
partnerLoyaltyNumber: null
|
|
membershipNumber: string
|
|
})
|
|
|
|
export type BookingFlowContextData = {
|
|
isLoggedIn: boolean
|
|
user:
|
|
| { state: "loading"; data: undefined }
|
|
| { state: "error"; data: undefined }
|
|
| { state: "loaded"; data: BookingFlowUser | undefined }
|
|
}
|
|
|
|
export const BookingFlowContext = createContext<
|
|
BookingFlowContextData | undefined
|
|
>(undefined)
|