Feat/SW-1281 ancillaries add flow * feat(SW-1546): update design * feat(SW-1546): show points only if logged in * feat(SW-1546): always show points * feat(SW-1281): ancillary add flow initial * feat(SW-1546): add api call * feat(SW-1281): refactor naming and break out components * feat(SW-1281): handle back button * feat(SW-1281): make mobile cards clickable * feat(SW-1281): refactor spread ancillaries * feat(SW-1281): add deliverytimes * feat(SW-1281): rebase master * feat(SW-1281): add design for logged in or not * feat(SW-1281): add design * feat(SW-1281): add mobile design * feat(SW-1281): fix carousel * feat(SW-1281): show deliverytime only if ancillary has not been added * feat(SW-1281): add design * feat(SW-1281): add translations * feat(SW-1281): add translations * feat(SW-1281): add translations * feat(SW-1281): base dates on check in date only * feat(SW-1281): fix show correct toast when no valid data * feat(SW-1281): hande logic if deliverytime is not required * feat(SW-1281): fix max width for mobile * feat(SW-1281): refactor after pr comment Approved-by: Niclas Edenvin Approved-by: Linus Flood
43 lines
1.4 KiB
TypeScript
43 lines
1.4 KiB
TypeScript
import { create } from "zustand"
|
|
|
|
import type { Ancillary } from "@/types/components/myPages/myStay/ancillaries"
|
|
|
|
interface AddAncillaryState {
|
|
step: number
|
|
totalSteps: number
|
|
nextStep: () => void
|
|
prevStep: () => void
|
|
resetStore: () => void
|
|
selectedAncillary: Ancillary["ancillaryContent"][number] | null
|
|
setSelectedAncillary: (
|
|
ancillary: Ancillary["ancillaryContent"][number]
|
|
) => void
|
|
confirmationNumber: string
|
|
setConfirmationNumber: (confirmationNumber: string) => void
|
|
openedFrom: "list" | "grid" | null
|
|
setOpenedFrom: (source: "list" | "grid") => void
|
|
isGridOpen: boolean
|
|
setGridIsOpen: (isOpen: boolean) => void
|
|
}
|
|
|
|
export const useAddAncillaryStore = create<AddAncillaryState>((set) => ({
|
|
step: 1,
|
|
totalSteps: 3,
|
|
nextStep: () =>
|
|
set((state) =>
|
|
state.step < state.totalSteps ? { step: state.step + 1 } : {}
|
|
),
|
|
prevStep: () =>
|
|
set((state) => (state.step > 1 ? { step: state.step - 1 } : {})),
|
|
resetStore: () => set({ step: 1 }),
|
|
selectedAncillary: null,
|
|
setSelectedAncillary: (ancillary) => set({ selectedAncillary: ancillary }),
|
|
confirmationNumber: "",
|
|
setConfirmationNumber: (confirmationNumber) =>
|
|
set({ confirmationNumber: confirmationNumber }),
|
|
openedFrom: null,
|
|
setOpenedFrom: (source) => set({ openedFrom: source }),
|
|
isGridOpen: false,
|
|
setGridIsOpen: (isOpen) => set({ isGridOpen: isOpen }),
|
|
}))
|