Merged in fix/SW-1353-and-SW-2497-tracking-fixes (pull request #1977)
fix: tracking fixes SW-1353 and SW-2497 * fix: tracking fixes * fix: remove console log and rename variable Approved-by: Michael Zetterberg Approved-by: Arvid Norlin
This commit is contained in:
@@ -14,26 +14,24 @@ import type { BookingConfirmation } from "@/types/trpc/routers/booking/confirmat
|
||||
|
||||
export default function Tracking({
|
||||
bookingConfirmation,
|
||||
refId,
|
||||
}: {
|
||||
bookingConfirmation: BookingConfirmation
|
||||
refId: string
|
||||
}) {
|
||||
const lang = useLang()
|
||||
const bookingRooms = useBookingConfirmationStore((state) => state.rooms)
|
||||
|
||||
const [hasLoadedBookingConfirmation] = useState(() => {
|
||||
const [loadedBookingConfirmationRefId] = useState(() => {
|
||||
if (typeof window !== "undefined") {
|
||||
return sessionStorage.getItem("hasLoadedBookingConfirmation")
|
||||
return sessionStorage.getItem("loadedBookingConfirmationRefId")
|
||||
}
|
||||
return null
|
||||
})
|
||||
|
||||
useEffect(() => {
|
||||
sessionStorage.setItem("hasLoadedBookingConfirmation", "true")
|
||||
|
||||
return () => {
|
||||
sessionStorage.removeItem("hasLoadedBookingConfirmation")
|
||||
}
|
||||
}, [])
|
||||
sessionStorage.setItem("loadedBookingConfirmationRefId", refId)
|
||||
}, [refId])
|
||||
|
||||
if (!bookingRooms.every(Boolean)) {
|
||||
return null
|
||||
@@ -52,9 +50,17 @@ export default function Tracking({
|
||||
return (
|
||||
<TrackingSDK
|
||||
pageData={pageTrackingData}
|
||||
hotelInfo={hasLoadedBookingConfirmation ? undefined : hotelsTrackingData}
|
||||
paymentInfo={hasLoadedBookingConfirmation ? undefined : paymentInfo}
|
||||
ancillaries={hasLoadedBookingConfirmation ? undefined : ancillaries}
|
||||
hotelInfo={
|
||||
loadedBookingConfirmationRefId === refId
|
||||
? undefined
|
||||
: hotelsTrackingData
|
||||
}
|
||||
paymentInfo={
|
||||
loadedBookingConfirmationRefId === refId ? undefined : paymentInfo
|
||||
}
|
||||
ancillaries={
|
||||
loadedBookingConfirmationRefId === refId ? undefined : ancillaries
|
||||
}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -100,7 +100,7 @@ export default async function BookingConfirmation({
|
||||
</SidePanel>
|
||||
</aside>
|
||||
</Confirmation>
|
||||
<Tracking bookingConfirmation={bookingConfirmation} />
|
||||
<Tracking bookingConfirmation={bookingConfirmation} refId={refId} />
|
||||
</BookingConfirmationProvider>
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user