Merged in fix/STAY-65-manage-stay (pull request #3089)
Fix/STAY-65 manage stay * fix: Disable manage stay for past bookings * fix: handle past and cancelled stay the same * fix: indentify past booking * fix: refactor to use design system components Approved-by: Erik Tiekstra
This commit is contained in:
@@ -3,6 +3,7 @@ import { notFound } from "next/navigation"
|
||||
import { use, useRef } from "react"
|
||||
import { useIntl } from "react-intl"
|
||||
|
||||
import { dt } from "@scandic-hotels/common/dt"
|
||||
import { trpc } from "@scandic-hotels/trpc/client"
|
||||
|
||||
import { createMyStayStore } from "@/stores/my-stay"
|
||||
@@ -91,9 +92,15 @@ export default function MyStayProvider({
|
||||
|
||||
const rooms = [data.booking, ...linkedReservations]
|
||||
|
||||
// Following the API logic for determining if booking is in the past.
|
||||
// This is the same logic as used for separating stays in /future and /past endpoints on the API
|
||||
const now = dt()
|
||||
const isPastBooking = dt(data.booking.checkInDate).isBefore(now, "day")
|
||||
|
||||
const hasInvalidatedQueryAndRefetched =
|
||||
(isFetchedAfterMount && data) ||
|
||||
(linkedReservationsIsFetchedAfterMount && linkedReservations)
|
||||
|
||||
if (!storeRef.current || hasInvalidatedQueryAndRefetched) {
|
||||
storeRef.current = createMyStayStore({
|
||||
breakfastPackages,
|
||||
@@ -104,6 +111,7 @@ export default function MyStayProvider({
|
||||
rooms,
|
||||
savedCreditCards,
|
||||
isLoggedIn,
|
||||
isPastBooking,
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user