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:
Bianca Widstam
2025-05-14 08:12:45 +00:00
parent 9322a7385a
commit 32618ad318
3 changed files with 15 additions and 3 deletions

View File

@@ -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)