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,
|
data: AncillaryFormData,
|
||||||
breakfastData: BreakfastData
|
breakfastData: BreakfastData
|
||||||
) {
|
) {
|
||||||
return [
|
const packages = [
|
||||||
{
|
{
|
||||||
code: BreakfastPackageEnum.ANCILLARY_REGULAR_BREAKFAST,
|
code: BreakfastPackageEnum.ANCILLARY_REGULAR_BREAKFAST,
|
||||||
quantity: breakfastData.nrOfAdults,
|
quantity: breakfastData.nrOfAdults,
|
||||||
@@ -243,6 +243,8 @@ export default function AddAncillaryFlowModal({
|
|||||||
comment: data.optionalText || undefined,
|
comment: data.optionalText || undefined,
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
|
|
||||||
|
return packages.filter((pkg) => pkg.quantity > 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
const onSubmit = (data: AncillaryFormData) => {
|
const onSubmit = (data: AncillaryFormData) => {
|
||||||
@@ -266,6 +268,7 @@ export default function AddAncillaryFlowModal({
|
|||||||
formData: data,
|
formData: data,
|
||||||
selectedAncillary,
|
selectedAncillary,
|
||||||
packages: packagesToAdd,
|
packages: packagesToAdd,
|
||||||
|
isBreakfast,
|
||||||
})
|
})
|
||||||
const shouldSkipGuarantee =
|
const shouldSkipGuarantee =
|
||||||
booking.guaranteeInfo || (data.quantityWithCard ?? 0) <= 0
|
booking.guaranteeInfo || (data.quantityWithCard ?? 0) <= 0
|
||||||
|
|||||||
@@ -48,6 +48,7 @@ export const getAncillarySessionData = ():
|
|||||||
quantity: number
|
quantity: number
|
||||||
comment: string | undefined
|
comment: string | undefined
|
||||||
}[]
|
}[]
|
||||||
|
isBreakfast: boolean
|
||||||
}
|
}
|
||||||
| undefined => {
|
| undefined => {
|
||||||
if (typeof window === "undefined") return undefined
|
if (typeof window === "undefined") return undefined
|
||||||
@@ -65,6 +66,7 @@ export function setAncillarySessionData({
|
|||||||
formData,
|
formData,
|
||||||
selectedAncillary,
|
selectedAncillary,
|
||||||
packages,
|
packages,
|
||||||
|
isBreakfast,
|
||||||
}: {
|
}: {
|
||||||
formData?: AncillaryFormData
|
formData?: AncillaryFormData
|
||||||
selectedAncillary?: Ancillary["ancillaryContent"][number] | null
|
selectedAncillary?: Ancillary["ancillaryContent"][number] | null
|
||||||
@@ -73,14 +75,20 @@ export function setAncillarySessionData({
|
|||||||
quantity: number
|
quantity: number
|
||||||
comment: string | undefined
|
comment: string | undefined
|
||||||
}[]
|
}[]
|
||||||
|
isBreakfast: boolean
|
||||||
}) {
|
}) {
|
||||||
if (typeof window === "undefined") return
|
if (typeof window === "undefined") return
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const currentData = getAncillarySessionData() || {}
|
const currentData = getAncillarySessionData() || {}
|
||||||
sessionStorage.setItem(
|
sessionStorage.setItem(
|
||||||
ancillarySessionKey,
|
ancillarySessionKey,
|
||||||
JSON.stringify({ ...currentData, formData, selectedAncillary, packages })
|
JSON.stringify({
|
||||||
|
...currentData,
|
||||||
|
formData,
|
||||||
|
selectedAncillary,
|
||||||
|
packages,
|
||||||
|
isBreakfast,
|
||||||
|
})
|
||||||
)
|
)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Error writing to session storage:", error)
|
console.error("Error writing to session storage:", error)
|
||||||
|
|||||||
@@ -33,6 +33,7 @@ export function AddAncillaryProvider({
|
|||||||
storeRef.current?.setState({
|
storeRef.current?.setState({
|
||||||
selectedAncillary: savedData.selectedAncillary,
|
selectedAncillary: savedData.selectedAncillary,
|
||||||
currentStep: AncillaryStepEnum.confirmation,
|
currentStep: AncillaryStepEnum.confirmation,
|
||||||
|
isBreakfast: savedData.isBreakfast,
|
||||||
isOpen: true,
|
isOpen: true,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user