Merged in fix/SW-2648-remove-ancillary-update-price (pull request #2002)

fix(SW-2648): refresh mystay after removing ancillary

* fix(SW-2648): refresh mystay after removing ancillary


Approved-by: Niclas Edenvin
This commit is contained in:
Bianca Widstam
2025-05-08 06:48:01 +00:00
parent ef2d4a3846
commit 0fd18590c5
2 changed files with 27 additions and 15 deletions

View File

@@ -1,3 +1,4 @@
import { useRouter } from "next/navigation"
import { useIntl } from "react-intl"
import { MaterialIcon } from "@scandic-hotels/design-system/Icons/MaterialIcon"
@@ -8,20 +9,31 @@ import Dialog from "@/components/Dialog"
import Button from "@/components/TempDesignSystem/Button"
import { toast } from "@/components/TempDesignSystem/Toasts"
import useLang from "@/hooks/useLang"
import { trackRemoveAncillary } from "@/utils/tracking/myStay"
import type {
BookingConfirmation,
PackageSchema,
} from "@/types/trpc/routers/booking/confirmation"
export default function RemoveButton({
refId,
codes,
title,
onSuccess,
booking,
ancillary,
}: {
refId: string
codes: string[]
title?: string
onSuccess: () => void
booking: BookingConfirmation["booking"]
ancillary: PackageSchema
}) {
const lang = useLang()
const intl = useIntl()
const utils = trpc.useUtils()
const router = useRouter()
const removePackage = trpc.booking.removePackage.useMutation()
return (
@@ -59,9 +71,17 @@ export default function RemoveButton({
if (!data) {
throw new Error()
}
utils.booking.get.invalidate({
refId: refId,
})
trackRemoveAncillary(
ancillary,
booking.hotelId,
booking.ancillary?.deliveryTime
)
router.refresh()
close()
onSuccess()
},
onError: () => {
toast.error(