feat: refactor of my stay
This commit is contained in:
committed by
Simon.Emanuelsson
parent
b5deb84b33
commit
ec087a3d15
@@ -17,7 +17,7 @@ export interface CardProps extends React.PropsWithChildren {
|
||||
|
||||
export interface InitialProps {
|
||||
totalSurprises: number
|
||||
onOpen: VoidFunction
|
||||
onOpen: () => void
|
||||
}
|
||||
|
||||
export interface SlideProps {
|
||||
@@ -25,5 +25,5 @@ export interface SlideProps {
|
||||
}
|
||||
|
||||
export interface HeaderProps extends React.PropsWithChildren {
|
||||
onClose: VoidFunction
|
||||
onClose: () => void
|
||||
}
|
||||
|
||||
@@ -1,17 +1,11 @@
|
||||
import type { Locale } from "date-fns"
|
||||
import type { DateRange } from "react-day-picker"
|
||||
|
||||
import type { Lang } from "@/constants/languages"
|
||||
|
||||
export interface DatePickerFormProps {
|
||||
name?: string
|
||||
}
|
||||
|
||||
type LangWithoutEn = Lang.da | Lang.de | Lang.fi | Lang.no | Lang.sv
|
||||
|
||||
interface DatePickerProps {
|
||||
close: () => void
|
||||
locales: Record<LangWithoutEn, Locale>
|
||||
startMonth?: Date
|
||||
hideHeader?: boolean
|
||||
}
|
||||
|
||||
@@ -6,5 +6,5 @@ export interface HeaderLinkProps extends React.PropsWithChildren {
|
||||
href: LinkProps["href"]
|
||||
iconName: IconName | null
|
||||
iconSize?: number
|
||||
onClick?: VoidFunction
|
||||
onClick?: () => void
|
||||
}
|
||||
|
||||
@@ -12,7 +12,8 @@ export interface BookingConfirmationRoom extends Room {
|
||||
bedType: Room["roomTypes"][number]
|
||||
}
|
||||
|
||||
export interface ConfirmationProps extends BookingConfirmation {
|
||||
export interface ConfirmationProps
|
||||
extends Pick<BookingConfirmation, "booking" | "hotel"> {
|
||||
room: BookingConfirmationRoom
|
||||
refId: string
|
||||
}
|
||||
|
||||
@@ -1,23 +1,22 @@
|
||||
import { z } from "zod"
|
||||
|
||||
import type { Hotel } from "@/types/hotel"
|
||||
import type { Room } from "@/stores/my-stay/myStayRoomDetailsStore"
|
||||
|
||||
export const cancelStaySchema = z.object({
|
||||
rooms: z.array(
|
||||
z.object({
|
||||
checked: z.boolean().optional(),
|
||||
checked: z.boolean(),
|
||||
confirmationNumber: z.string(),
|
||||
})
|
||||
),
|
||||
})
|
||||
|
||||
export interface CancelStayProps {
|
||||
hotel: Hotel
|
||||
handleCloseModal: () => void
|
||||
hotel: Hotel
|
||||
}
|
||||
|
||||
export type CancelStayFormValues = z.infer<typeof cancelStaySchema>
|
||||
export type CancelStayFormValues = z.output<typeof cancelStaySchema>
|
||||
|
||||
export interface RoomDetails {
|
||||
id: string
|
||||
@@ -43,17 +42,3 @@ export interface StayDetails {
|
||||
adultsText: string
|
||||
childrenText: string
|
||||
}
|
||||
|
||||
export interface CancelStayConfirmationProps {
|
||||
hotel: Hotel
|
||||
stayDetails: StayDetails
|
||||
}
|
||||
|
||||
export interface FinalConfirmationProps {
|
||||
stayDetails: StayDetails
|
||||
}
|
||||
|
||||
export interface PriceContainerProps {
|
||||
roomDetails: Room
|
||||
stayDetails: StayDetails
|
||||
}
|
||||
|
||||
@@ -2,12 +2,12 @@ import { z } from "zod"
|
||||
|
||||
import { Lang } from "@/constants/languages"
|
||||
|
||||
export const modifyDateSchema = z.object({
|
||||
export const changeDatesSchema = z.object({
|
||||
checkInDate: z.string(),
|
||||
checkOutDate: z.string(),
|
||||
})
|
||||
|
||||
export type ModifyDateSchema = z.infer<typeof modifyDateSchema>
|
||||
export type ChangeDatesSchema = z.output<typeof changeDatesSchema>
|
||||
|
||||
export interface QueryInput {
|
||||
hotelId: string
|
||||
@@ -33,6 +33,12 @@ export const DEFAULT_QUERY_INPUT: QueryInput = {
|
||||
lang: Lang.en,
|
||||
}
|
||||
|
||||
export interface ModifyStayProps {
|
||||
isLoggedIn: boolean
|
||||
export interface ChangeDatesStepsProps {
|
||||
closeModal: () => void
|
||||
}
|
||||
|
||||
export interface ChangeDatesFormProps {
|
||||
checkAvailability: (fromDate: string, toDate: string) => Promise<void>
|
||||
closeModal: () => void
|
||||
noAvailability: boolean
|
||||
}
|
||||
@@ -1,10 +1,10 @@
|
||||
import type { User } from "@/types/user"
|
||||
import type { SafeUser } from "@/types/user"
|
||||
|
||||
export type ToggleSidePeekProps = {
|
||||
hotelId: string
|
||||
roomTypeCode?: string
|
||||
intent?: "text" | "textInverted"
|
||||
title?: string
|
||||
user?: User
|
||||
user?: SafeUser
|
||||
confirmationNumber?: string
|
||||
}
|
||||
|
||||
@@ -70,6 +70,6 @@ export interface StepsProps {
|
||||
|
||||
export interface ActionButtonsProps {
|
||||
isPriceDetailsOpen: boolean
|
||||
togglePriceDetails: VoidFunction
|
||||
togglePriceDetails: () => void
|
||||
isSubmitting: boolean
|
||||
}
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
import type { Room } from "@/types/hotel"
|
||||
import type { User } from "@/types/user"
|
||||
import type { SafeUser } from "@/types/user"
|
||||
import type { SidePeekEnum } from "../hotelReservation/sidePeek"
|
||||
|
||||
export type BookedRoomSidePeekProps = {
|
||||
room: Room
|
||||
activeSidePeek: SidePeekEnum | null
|
||||
close: () => void
|
||||
user: User | null
|
||||
user: SafeUser
|
||||
confirmationNumber: string
|
||||
}
|
||||
|
||||
|
||||
3
apps/scandic-web/types/contexts/my-stay.ts
Normal file
3
apps/scandic-web/types/contexts/my-stay.ts
Normal file
@@ -0,0 +1,3 @@
|
||||
import type { createMyStayStore } from "@/stores/my-stay"
|
||||
|
||||
export type MyStayStore = ReturnType<typeof createMyStayStore>
|
||||
@@ -62,6 +62,8 @@ export type RestaurantOpeningHoursDay = z.output<
|
||||
typeof openingHoursDetailsSchema
|
||||
>
|
||||
export type Room = ReturnType<typeof transformRoomCategories>
|
||||
export type RoomCategory = Room
|
||||
export type RoomCategories = RoomCategory[]
|
||||
|
||||
export type PoiMapMarkersProps = {
|
||||
activePoi?: string | null
|
||||
|
||||
89
apps/scandic-web/types/stores/my-stay.ts
Normal file
89
apps/scandic-web/types/stores/my-stay.ts
Normal file
@@ -0,0 +1,89 @@
|
||||
import type { IntlShape } from "react-intl"
|
||||
|
||||
import type { BreakfastPackage } from "@/types/components/hotelReservation/breakfast"
|
||||
import type { BedTypeSchema } from "@/types/components/hotelReservation/enterDetails/bedType"
|
||||
import type { RoomPrice } from "@/types/components/hotelReservation/enterDetails/details"
|
||||
import type { PriceTypeEnum } from "@/types/components/hotelReservation/myStay/myStay"
|
||||
import type { Child } from "@/types/components/hotelReservation/selectRate/selectRate"
|
||||
import type { Packages } from "@/types/components/myPages/myStay/ancillaries"
|
||||
import type { Hotel, Room as HotelRoom, RoomCategories } from "@/types/hotel"
|
||||
import type { BookingConfirmation } from "@/types/trpc/routers/booking/confirmation"
|
||||
import type { CreditCard } from "@/types/user"
|
||||
|
||||
export type Room = Pick<
|
||||
BookingConfirmation["booking"],
|
||||
| "adults"
|
||||
| "bookingCode"
|
||||
| "canChangeDate"
|
||||
| "cancellationNumber"
|
||||
| "checkInDate"
|
||||
| "checkOutDate"
|
||||
| "cheques"
|
||||
| "childrenAges"
|
||||
| "confirmationNumber"
|
||||
| "createDateTime"
|
||||
| "currencyCode"
|
||||
| "guaranteeInfo"
|
||||
| "guest"
|
||||
| "hotelId"
|
||||
| "isCancelable"
|
||||
| "linkedReservations"
|
||||
| "multiRoom"
|
||||
| "rateDefinition"
|
||||
| "reservationStatus"
|
||||
| "roomPoints"
|
||||
| "roomTypeCode"
|
||||
| "totalPoints"
|
||||
| "totalPrice"
|
||||
| "totalPriceExVat"
|
||||
| "vatAmount"
|
||||
| "vatPercentage"
|
||||
| "vouchers"
|
||||
> & {
|
||||
bedType: BedTypeSchema
|
||||
breakfast: Omit<BreakfastPackage, "requestedPrice"> | null
|
||||
childrenAsString: string
|
||||
childrenInRoom: Child[]
|
||||
isCancelled: boolean
|
||||
mainRoom: boolean
|
||||
packages: Packages | null
|
||||
priceType: PriceTypeEnum
|
||||
rate: string
|
||||
room: (HotelRoom & { bedType: HotelRoom["roomTypes"][number] }) | null
|
||||
roomName: string
|
||||
roomNumber: number
|
||||
roomPrice: RoomPrice
|
||||
terms: string | null
|
||||
}
|
||||
|
||||
export type BookingRoom = BookingConfirmation["booking"]
|
||||
|
||||
interface Actions {
|
||||
closeManageStay: () => void
|
||||
openManageStay: () => void
|
||||
}
|
||||
|
||||
export interface MyStayState {
|
||||
actions: Actions
|
||||
allRoomsAreCancelled: boolean
|
||||
bookedRoom: Room
|
||||
breakfastPackages: Packages | null
|
||||
hotel: Hotel
|
||||
mainRoom: Room
|
||||
manageStay: boolean
|
||||
refId: string
|
||||
rooms: Room[]
|
||||
savedCreditCards: CreditCard[] | null
|
||||
totalPoints: number
|
||||
totalPrice: string
|
||||
}
|
||||
|
||||
export interface InitialState
|
||||
extends Pick<
|
||||
MyStayState,
|
||||
"breakfastPackages" | "hotel" | "refId" | "savedCreditCards"
|
||||
> {
|
||||
intl: IntlShape
|
||||
roomCategories: RoomCategories
|
||||
rooms: BookingRoom[]
|
||||
}
|
||||
@@ -22,10 +22,10 @@ interface Actions {
|
||||
appendRegularRates: (
|
||||
roomConfigurations: RoomConfiguration[] | undefined
|
||||
) => void
|
||||
closeSection: VoidFunction
|
||||
modifyRate: VoidFunction
|
||||
closeSection: () => void
|
||||
modifyRate: () => void
|
||||
removeSelectedPackage: (code: PackageEnum) => void
|
||||
removeSelectedPackages: VoidFunction
|
||||
removeSelectedPackages: () => void
|
||||
selectFilter: (filter: BookingCodeFilterEnum) => void
|
||||
selectPackages: (codes: PackageEnum[]) => void
|
||||
selectRate: (rate: SelectedRate, isUserLoggedIn: boolean) => void
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import type { z } from "zod"
|
||||
|
||||
import type { Hotel, Room } from "@/types/hotel"
|
||||
import type { HotelData, Room } from "@/types/hotel"
|
||||
import type {
|
||||
bookingConfirmationSchema,
|
||||
packageSchema,
|
||||
@@ -11,9 +11,8 @@ export interface BookingConfirmationSchema
|
||||
|
||||
export interface PackageSchema extends z.output<typeof packageSchema> {}
|
||||
|
||||
export interface BookingConfirmation {
|
||||
export interface BookingConfirmation extends HotelData {
|
||||
booking: BookingConfirmationSchema
|
||||
hotel: Hotel
|
||||
room:
|
||||
| (Room & {
|
||||
bedType: Room["roomTypes"][number]
|
||||
|
||||
Reference in New Issue
Block a user