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:
@@ -1,3 +1,4 @@
|
|||||||
|
import { useRouter } from "next/navigation"
|
||||||
import { useIntl } from "react-intl"
|
import { useIntl } from "react-intl"
|
||||||
|
|
||||||
import { MaterialIcon } from "@scandic-hotels/design-system/Icons/MaterialIcon"
|
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 Button from "@/components/TempDesignSystem/Button"
|
||||||
import { toast } from "@/components/TempDesignSystem/Toasts"
|
import { toast } from "@/components/TempDesignSystem/Toasts"
|
||||||
import useLang from "@/hooks/useLang"
|
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({
|
export default function RemoveButton({
|
||||||
refId,
|
refId,
|
||||||
codes,
|
codes,
|
||||||
title,
|
title,
|
||||||
onSuccess,
|
booking,
|
||||||
|
ancillary,
|
||||||
}: {
|
}: {
|
||||||
refId: string
|
refId: string
|
||||||
codes: string[]
|
codes: string[]
|
||||||
title?: string
|
title?: string
|
||||||
onSuccess: () => void
|
booking: BookingConfirmation["booking"]
|
||||||
|
ancillary: PackageSchema
|
||||||
}) {
|
}) {
|
||||||
const lang = useLang()
|
const lang = useLang()
|
||||||
const intl = useIntl()
|
const intl = useIntl()
|
||||||
|
const utils = trpc.useUtils()
|
||||||
|
const router = useRouter()
|
||||||
|
|
||||||
const removePackage = trpc.booking.removePackage.useMutation()
|
const removePackage = trpc.booking.removePackage.useMutation()
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -59,9 +71,17 @@ export default function RemoveButton({
|
|||||||
if (!data) {
|
if (!data) {
|
||||||
throw new Error()
|
throw new Error()
|
||||||
}
|
}
|
||||||
|
utils.booking.get.invalidate({
|
||||||
|
refId: refId,
|
||||||
|
})
|
||||||
|
trackRemoveAncillary(
|
||||||
|
ancillary,
|
||||||
|
booking.hotelId,
|
||||||
|
booking.ancillary?.deliveryTime
|
||||||
|
)
|
||||||
|
router.refresh()
|
||||||
|
|
||||||
close()
|
close()
|
||||||
onSuccess()
|
|
||||||
},
|
},
|
||||||
onError: () => {
|
onError: () => {
|
||||||
toast.error(
|
toast.error(
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
import { useRouter } from "next/navigation"
|
|
||||||
import { useIntl } from "react-intl"
|
import { useIntl } from "react-intl"
|
||||||
|
|
||||||
import { MaterialIcon } from "@scandic-hotels/design-system/Icons/MaterialIcon"
|
import { MaterialIcon } from "@scandic-hotels/design-system/Icons/MaterialIcon"
|
||||||
@@ -8,7 +7,6 @@ import AccordionItem from "@/components/TempDesignSystem/Accordion/AccordionItem
|
|||||||
import Divider from "@/components/TempDesignSystem/Divider"
|
import Divider from "@/components/TempDesignSystem/Divider"
|
||||||
import Body from "@/components/TempDesignSystem/Text/Body"
|
import Body from "@/components/TempDesignSystem/Text/Body"
|
||||||
import Subtitle from "@/components/TempDesignSystem/Text/Subtitle"
|
import Subtitle from "@/components/TempDesignSystem/Text/Subtitle"
|
||||||
import { trackRemoveAncillary } from "@/utils/tracking/myStay"
|
|
||||||
|
|
||||||
import { getBreakfastPackagesFromAncillaryFlow } from "../../utils/hasBreakfastPackage"
|
import { getBreakfastPackagesFromAncillaryFlow } from "../../utils/hasBreakfastPackage"
|
||||||
import RemoveButton from "./RemoveButton"
|
import RemoveButton from "./RemoveButton"
|
||||||
@@ -27,7 +25,6 @@ export function AddedAncillaries({
|
|||||||
booking,
|
booking,
|
||||||
}: AddedAncillariesProps) {
|
}: AddedAncillariesProps) {
|
||||||
const intl = useIntl()
|
const intl = useIntl()
|
||||||
const router = useRouter()
|
|
||||||
|
|
||||||
const addedBreakfastPackages = getBreakfastPackagesFromAncillaryFlow(
|
const addedBreakfastPackages = getBreakfastPackagesFromAncillaryFlow(
|
||||||
booking.packages
|
booking.packages
|
||||||
@@ -134,7 +131,8 @@ export function AddedAncillaries({
|
|||||||
: [ancillary.code]
|
: [ancillary.code]
|
||||||
}
|
}
|
||||||
title={ancillaryTitle}
|
title={ancillaryTitle}
|
||||||
onSuccess={router.refresh}
|
booking={booking}
|
||||||
|
ancillary={ancillary}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
) : null}
|
) : null}
|
||||||
@@ -200,14 +198,8 @@ export function AddedAncillaries({
|
|||||||
: [ancillary.code]
|
: [ancillary.code]
|
||||||
}
|
}
|
||||||
title={ancillaryTitle}
|
title={ancillaryTitle}
|
||||||
onSuccess={() => {
|
booking={booking}
|
||||||
trackRemoveAncillary(
|
ancillary={ancillary}
|
||||||
ancillary,
|
|
||||||
booking.hotelId,
|
|
||||||
booking.ancillary?.deliveryTime
|
|
||||||
)
|
|
||||||
router.refresh()
|
|
||||||
}}
|
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
) : null}
|
) : null}
|
||||||
|
|||||||
Reference in New Issue
Block a user