From 8308d004640c365a350be19581057a9114fba37a Mon Sep 17 00:00:00 2001 From: Linus Flood Date: Wed, 8 Jan 2025 15:24:20 +0100 Subject: [PATCH] fix: valid session check in rooms container --- .../HotelReservation/SelectRate/RoomSelection/index.tsx | 6 ++++-- .../HotelReservation/SelectRate/Rooms/RoomsContainer.tsx | 3 --- components/HotelReservation/SelectRate/Rooms/index.tsx | 2 -- .../components/hotelReservation/selectRate/roomSelection.ts | 2 -- 4 files changed, 4 insertions(+), 9 deletions(-) diff --git a/components/HotelReservation/SelectRate/RoomSelection/index.tsx b/components/HotelReservation/SelectRate/RoomSelection/index.tsx index ffd712563..cd3d8831e 100644 --- a/components/HotelReservation/SelectRate/RoomSelection/index.tsx +++ b/components/HotelReservation/SelectRate/RoomSelection/index.tsx @@ -1,8 +1,10 @@ "use client" import { usePathname, useRouter, useSearchParams } from "next/navigation" +import { useSession } from "next-auth/react" import { useCallback, useEffect, useMemo, useRef } from "react" import { debounce } from "@/utils/debounce" +import { isValidSession } from "@/utils/session" import RateSummary from "./RateSummary" import RoomCard from "./RoomCard" @@ -20,7 +22,6 @@ import type { RoomSelectionProps } from "@/types/components/hotelReservation/sel export default function RoomSelection({ roomsAvailability, roomCategories, - user, availablePackages, selectedPackages, setRateCode, @@ -30,7 +31,8 @@ export default function RoomSelection({ const router = useRouter() const pathname = usePathname() const searchParams = useSearchParams() - const isUserLoggedIn = !!user + const session = useSession() + const isUserLoggedIn = 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 d8570e159..ff6986108 100644 --- a/components/HotelReservation/SelectRate/Rooms/RoomsContainer.tsx +++ b/components/HotelReservation/SelectRate/Rooms/RoomsContainer.tsx @@ -32,8 +32,6 @@ export async function RoomsContainer({ childArray, lang, }: Props) { - const user = await getProfileSafely() - const fromDateString = dt(fromDate).format("YYYY-MM-DD") const toDateString = dt(toDate).format("YYYY-MM-DD") @@ -92,7 +90,6 @@ export async function RoomsContainer({ return ( > @@ -18,7 +17,6 @@ export interface RoomSelectionProps { export interface SelectRateProps { roomsAvailability: RoomsAvailability roomCategories: RoomData[] - user: SafeUser availablePackages: RoomPackageData hotelType: string | undefined }