Merged in fix/add-breakfast-wrong-quantity (pull request #2086)
fix: check if breakfast and refill modal with correct confirmation if cancelled/error payment * fix: check if breakfast and refill modal with correct confirmation if cancelled/error payment * fix: only include packages with quantity Approved-by: Linus Flood Approved-by: Matilda Landström
This commit is contained in:
@@ -226,7 +226,7 @@ export default function AddAncillaryFlowModal({
|
||||
data: AncillaryFormData,
|
||||
breakfastData: BreakfastData
|
||||
) {
|
||||
return [
|
||||
const packages = [
|
||||
{
|
||||
code: BreakfastPackageEnum.ANCILLARY_REGULAR_BREAKFAST,
|
||||
quantity: breakfastData.nrOfAdults,
|
||||
@@ -243,6 +243,8 @@ export default function AddAncillaryFlowModal({
|
||||
comment: data.optionalText || undefined,
|
||||
},
|
||||
]
|
||||
|
||||
return packages.filter((pkg) => pkg.quantity > 0)
|
||||
}
|
||||
|
||||
const onSubmit = (data: AncillaryFormData) => {
|
||||
@@ -266,6 +268,7 @@ export default function AddAncillaryFlowModal({
|
||||
formData: data,
|
||||
selectedAncillary,
|
||||
packages: packagesToAdd,
|
||||
isBreakfast,
|
||||
})
|
||||
const shouldSkipGuarantee =
|
||||
booking.guaranteeInfo || (data.quantityWithCard ?? 0) <= 0
|
||||
|
||||
@@ -48,6 +48,7 @@ export const getAncillarySessionData = ():
|
||||
quantity: number
|
||||
comment: string | undefined
|
||||
}[]
|
||||
isBreakfast: boolean
|
||||
}
|
||||
| undefined => {
|
||||
if (typeof window === "undefined") return undefined
|
||||
@@ -65,6 +66,7 @@ export function setAncillarySessionData({
|
||||
formData,
|
||||
selectedAncillary,
|
||||
packages,
|
||||
isBreakfast,
|
||||
}: {
|
||||
formData?: AncillaryFormData
|
||||
selectedAncillary?: Ancillary["ancillaryContent"][number] | null
|
||||
@@ -73,14 +75,20 @@ export function setAncillarySessionData({
|
||||
quantity: number
|
||||
comment: string | undefined
|
||||
}[]
|
||||
isBreakfast: boolean
|
||||
}) {
|
||||
if (typeof window === "undefined") return
|
||||
|
||||
try {
|
||||
const currentData = getAncillarySessionData() || {}
|
||||
sessionStorage.setItem(
|
||||
ancillarySessionKey,
|
||||
JSON.stringify({ ...currentData, formData, selectedAncillary, packages })
|
||||
JSON.stringify({
|
||||
...currentData,
|
||||
formData,
|
||||
selectedAncillary,
|
||||
packages,
|
||||
isBreakfast,
|
||||
})
|
||||
)
|
||||
} catch (error) {
|
||||
console.error("Error writing to session storage:", error)
|
||||
|
||||
@@ -33,6 +33,7 @@ export function AddAncillaryProvider({
|
||||
storeRef.current?.setState({
|
||||
selectedAncillary: savedData.selectedAncillary,
|
||||
currentStep: AncillaryStepEnum.confirmation,
|
||||
isBreakfast: savedData.isBreakfast,
|
||||
isOpen: true,
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user