diff --git a/components/Forms/Edit/Profile/index.tsx b/components/Forms/Edit/Profile/index.tsx index 4c7b70fea..7e9578106 100644 --- a/components/Forms/Edit/Profile/index.tsx +++ b/components/Forms/Edit/Profile/index.tsx @@ -94,7 +94,14 @@ export default function Form({ user }: EditFormProps) { // Kept logout out of Next router forcing browser to navigate on logout url window.location.href = logout[lang] } else { - router.push(profile[lang]) + const myStayReturnRoute = localStorage.getItem("myStayReturnRoute") + if (myStayReturnRoute) { + const returnRoute = JSON.parse(myStayReturnRoute) + localStorage.removeItem("myStayReturnRoute") + router.push(returnRoute.path) + } else { + router.push(profile[lang]) + } router.refresh() // Can be removed on NextJs 15 } break diff --git a/components/HotelReservation/MyStay/Room/GuestDetails.tsx b/components/HotelReservation/MyStay/Room/GuestDetails.tsx index a4e011f38..c00104a0a 100644 --- a/components/HotelReservation/MyStay/Room/GuestDetails.tsx +++ b/components/HotelReservation/MyStay/Room/GuestDetails.tsx @@ -1,3 +1,5 @@ +"use client" +import { useRouter } from "next/navigation" import { useIntl } from "react-intl" import { DiamondIcon, EditIcon } from "@/components/Icons" @@ -5,6 +7,7 @@ import MembershipLevelIcon from "@/components/Levels/Icon" import Button from "@/components/TempDesignSystem/Button" import Body from "@/components/TempDesignSystem/Text/Body" import Caption from "@/components/TempDesignSystem/Text/Caption" +import useLang from "@/hooks/useLang" import styles from "./room.module.css" @@ -21,13 +24,34 @@ export default function GuestDetails({ isMobile?: boolean }) { const intl = useIntl() + const lang = useLang() + const router = useRouter() const containerClass = isMobile ? styles.guestDetailsMobile : styles.guestDetailsDesktop + const isMemberBooking = + booking.guest.membershipNumber === user?.membership?.membershipNumber + + function handleModifyGuestDetails() { + if (isMemberBooking) { + const expirationTime = Date.now() + 10 * 60 * 1000 + localStorage.setItem( + "myStayReturnRoute", + JSON.stringify({ + path: window.location.pathname, + expiry: expirationTime, + }) + ) + router.push(`/${lang}/scandic-friends/my-pages/profile/edit`) + } else { + console.log("not a member booking") // TODO: Implement non-member booking + } + } + return (