Merged in feat(SW-1677)-my-stay-update-contact-user (pull request #1386)
Feat(SW-1677) my stay update contact user * feat(SW-1677): Hide membersettings that doesnt match the booking * feat(SW-1677) Edit my stay contact details as user Approved-by: Linus Flood
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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 (
|
||||
<div className={containerClass}>
|
||||
{user?.membership && (
|
||||
{isMemberBooking && (
|
||||
<div className={styles.userDetails}>
|
||||
<div className={styles.row}>
|
||||
<div className={styles.rowTitle}>
|
||||
@@ -41,7 +65,7 @@ export default function GuestDetails({
|
||||
</Caption>
|
||||
</div>
|
||||
<MembershipLevelIcon
|
||||
level={user.membership.membershipLevel}
|
||||
level={user.membership!.membershipLevel}
|
||||
color="red"
|
||||
height={isMobile ? "40" : "20"}
|
||||
width={isMobile ? "80" : "40"}
|
||||
@@ -62,7 +86,7 @@ export default function GuestDetails({
|
||||
</Caption>
|
||||
|
||||
<Body color="uiTextHighContrast" className={styles.totalPointsText}>
|
||||
{user.membership.currentPoints}
|
||||
{user.membership!.currentPoints}
|
||||
</Body>
|
||||
</div>
|
||||
</div>
|
||||
@@ -71,10 +95,10 @@ export default function GuestDetails({
|
||||
<Body textTransform="bold" color="uiTextHighContrast">
|
||||
{booking.guest.firstName} {booking.guest.lastName}
|
||||
</Body>
|
||||
{user?.membership && (
|
||||
{isMemberBooking && (
|
||||
<Body color="uiTextHighContrast">
|
||||
{intl.formatMessage({ id: "Member no." })}{" "}
|
||||
{user.membership.membershipNumber}
|
||||
{user.membership!.membershipNumber}
|
||||
</Body>
|
||||
)}
|
||||
<Caption color="uiTextHighContrast">{booking.guest.email}</Caption>
|
||||
@@ -86,6 +110,7 @@ export default function GuestDetails({
|
||||
variant="icon"
|
||||
color="burgundy"
|
||||
intent={isMobile ? "secondary" : "text"}
|
||||
onClick={handleModifyGuestDetails}
|
||||
>
|
||||
<EditIcon color="burgundy" width={20} height={20} />
|
||||
<Caption color="burgundy">
|
||||
|
||||
Reference in New Issue
Block a user