feat: make steps of enter details flow dynamic depending on data
This commit is contained in:
committed by
Joakim Jäderberg
parent
d49e301634
commit
c6fc500d9e
40
types/stores/details.ts
Normal file
40
types/stores/details.ts
Normal file
@@ -0,0 +1,40 @@
|
||||
import type { BedTypeSchema } from "@/types/components/hotelReservation/enterDetails/bedType"
|
||||
import type { BookingData } from "@/types/components/hotelReservation/enterDetails/bookingData"
|
||||
import type { BreakfastPackage } from "@/types/components/hotelReservation/enterDetails/breakfast"
|
||||
import type { DetailsSchema } from "@/types/components/hotelReservation/enterDetails/details"
|
||||
import { StepEnum } from "@/types/enums/step"
|
||||
|
||||
export interface DetailsState {
|
||||
actions: {
|
||||
setIsSubmittingDisabled: (isSubmittingDisabled: boolean) => void
|
||||
setTotalPrice: (totalPrice: TotalPrice) => void
|
||||
toggleSummaryOpen: () => void,
|
||||
updateBedType: (data: BedTypeSchema) => void
|
||||
updateBreakfast: (data: BreakfastPackage | false) => void
|
||||
updateDetails: (data: DetailsSchema) => void
|
||||
updateValidity: (property: StepEnum, isValid: boolean) => void
|
||||
}
|
||||
data: DetailsSchema & {
|
||||
bedType: BedTypeSchema | undefined
|
||||
breakfast: BreakfastPackage | false | undefined
|
||||
booking: BookingData
|
||||
}
|
||||
isSubmittingDisabled: boolean
|
||||
isSummaryOpen: boolean
|
||||
isValid: Record<StepEnum, boolean>
|
||||
totalPrice: TotalPrice
|
||||
}
|
||||
|
||||
export interface InitialState extends Partial<DetailsState> {
|
||||
booking: BookingData
|
||||
}
|
||||
|
||||
interface Price {
|
||||
currency: string
|
||||
price: number
|
||||
}
|
||||
|
||||
export interface TotalPrice {
|
||||
euro: Price | undefined
|
||||
local: Price
|
||||
}
|
||||
10
types/stores/steps.ts
Normal file
10
types/stores/steps.ts
Normal file
@@ -0,0 +1,10 @@
|
||||
import { StepEnum } from "@/types/enums/step"
|
||||
|
||||
export interface StepState {
|
||||
completeStep: () => void
|
||||
navigate: (step: StepEnum) => void
|
||||
setStep: (step: StepEnum) => void
|
||||
|
||||
currentStep: StepEnum
|
||||
steps: StepEnum[]
|
||||
}
|
||||
Reference in New Issue
Block a user