From fa20f128ef7080ac8e3a3fab193e412ba71241c9 Mon Sep 17 00:00:00 2001 From: Linus Flood Date: Wed, 8 Jan 2025 15:38:36 +0000 Subject: [PATCH] Merged in feat/check-session-fix-2 (pull request #1154) fix: is user logged in fix * fix: is user logged in fix --- .../HotelReservation/SelectRate/RoomSelection/index.tsx | 4 +--- .../HotelReservation/SelectRate/Rooms/RoomsContainer.tsx | 6 +++++- components/HotelReservation/SelectRate/Rooms/index.tsx | 2 ++ .../components/hotelReservation/selectRate/roomSelection.ts | 2 ++ 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/components/HotelReservation/SelectRate/RoomSelection/index.tsx b/components/HotelReservation/SelectRate/RoomSelection/index.tsx index 20eb24931..b784c94bd 100644 --- a/components/HotelReservation/SelectRate/RoomSelection/index.tsx +++ b/components/HotelReservation/SelectRate/RoomSelection/index.tsx @@ -24,6 +24,7 @@ export default function RoomSelection({ roomCategories, availablePackages, selectedPackages, + isUserLoggedIn, setRateCode, rateSummary, hotelType, @@ -31,9 +32,6 @@ export default function RoomSelection({ const router = useRouter() const pathname = usePathname() const searchParams = useSearchParams() - const session = useSession() - const isUserLoggedIn = - !!session && !!session.data && isValidSession(session.data) const roomRefs = useRef([]) const { roomConfigurations, rateDefinitions } = roomsAvailability diff --git a/components/HotelReservation/SelectRate/Rooms/RoomsContainer.tsx b/components/HotelReservation/SelectRate/Rooms/RoomsContainer.tsx index ff6986108..ea5f79a26 100644 --- a/components/HotelReservation/SelectRate/Rooms/RoomsContainer.tsx +++ b/components/HotelReservation/SelectRate/Rooms/RoomsContainer.tsx @@ -2,11 +2,12 @@ import { dt } from "@/lib/dt" import { getHotelData, getPackages, - getProfileSafely, getRoomsAvailability, } from "@/lib/trpc/memoizedRequests" +import { auth } from "@/auth" import { safeTry } from "@/utils/safeTry" +import { isValidSession } from "@/utils/session" import { generateChildrenString } from "../RoomSelection/utils" import Rooms from "." @@ -32,6 +33,8 @@ export async function RoomsContainer({ childArray, lang, }: Props) { + const session = await auth() + const isUserLoggedIn = isValidSession(session) const fromDateString = dt(fromDate).format("YYYY-MM-DD") const toDateString = dt(toDate).format("YYYY-MM-DD") @@ -94,6 +97,7 @@ export async function RoomsContainer({ roomsAvailability={roomsAvailability} roomCategories={hotelData?.included?.rooms ?? []} hotelType={hotelData?.data.attributes?.hotelType} + isUserLoggedIn={isUserLoggedIn} /> ) } diff --git a/components/HotelReservation/SelectRate/Rooms/index.tsx b/components/HotelReservation/SelectRate/Rooms/index.tsx index abb2ee340..90e2663a1 100644 --- a/components/HotelReservation/SelectRate/Rooms/index.tsx +++ b/components/HotelReservation/SelectRate/Rooms/index.tsx @@ -25,6 +25,7 @@ export default function Rooms({ roomCategories = [], availablePackages, hotelType, + isUserLoggedIn, }: SelectRateProps) { const visibleRooms: RoomConfiguration[] = useMemo(() => { const deduped = filterDuplicateRoomTypesByLowestPrice( @@ -188,6 +189,7 @@ export default function Rooms({ setRateCode={setSelectedRate} rateSummary={rateSummary} hotelType={hotelType} + isUserLoggedIn={isUserLoggedIn} /> ) diff --git a/types/components/hotelReservation/selectRate/roomSelection.ts b/types/components/hotelReservation/selectRate/roomSelection.ts index 58b5af91c..7a0faf0af 100644 --- a/types/components/hotelReservation/selectRate/roomSelection.ts +++ b/types/components/hotelReservation/selectRate/roomSelection.ts @@ -12,6 +12,7 @@ export interface RoomSelectionProps { setRateCode: React.Dispatch> rateSummary: Rate | null hotelType: string | undefined + isUserLoggedIn: boolean } export interface SelectRateProps { @@ -19,4 +20,5 @@ export interface SelectRateProps { roomCategories: RoomData[] availablePackages: RoomPackageData hotelType: string | undefined + isUserLoggedIn: boolean }