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
|
// Kept logout out of Next router forcing browser to navigate on logout url
|
||||||
window.location.href = logout[lang]
|
window.location.href = logout[lang]
|
||||||
} else {
|
} 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
|
router.refresh() // Can be removed on NextJs 15
|
||||||
}
|
}
|
||||||
break
|
break
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
"use client"
|
||||||
|
import { useRouter } from "next/navigation"
|
||||||
import { useIntl } from "react-intl"
|
import { useIntl } from "react-intl"
|
||||||
|
|
||||||
import { DiamondIcon, EditIcon } from "@/components/Icons"
|
import { DiamondIcon, EditIcon } from "@/components/Icons"
|
||||||
@@ -5,6 +7,7 @@ import MembershipLevelIcon from "@/components/Levels/Icon"
|
|||||||
import Button from "@/components/TempDesignSystem/Button"
|
import Button from "@/components/TempDesignSystem/Button"
|
||||||
import Body from "@/components/TempDesignSystem/Text/Body"
|
import Body from "@/components/TempDesignSystem/Text/Body"
|
||||||
import Caption from "@/components/TempDesignSystem/Text/Caption"
|
import Caption from "@/components/TempDesignSystem/Text/Caption"
|
||||||
|
import useLang from "@/hooks/useLang"
|
||||||
|
|
||||||
import styles from "./room.module.css"
|
import styles from "./room.module.css"
|
||||||
|
|
||||||
@@ -21,13 +24,34 @@ export default function GuestDetails({
|
|||||||
isMobile?: boolean
|
isMobile?: boolean
|
||||||
}) {
|
}) {
|
||||||
const intl = useIntl()
|
const intl = useIntl()
|
||||||
|
const lang = useLang()
|
||||||
|
const router = useRouter()
|
||||||
const containerClass = isMobile
|
const containerClass = isMobile
|
||||||
? styles.guestDetailsMobile
|
? styles.guestDetailsMobile
|
||||||
: styles.guestDetailsDesktop
|
: 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 (
|
return (
|
||||||
<div className={containerClass}>
|
<div className={containerClass}>
|
||||||
{user?.membership && (
|
{isMemberBooking && (
|
||||||
<div className={styles.userDetails}>
|
<div className={styles.userDetails}>
|
||||||
<div className={styles.row}>
|
<div className={styles.row}>
|
||||||
<div className={styles.rowTitle}>
|
<div className={styles.rowTitle}>
|
||||||
@@ -41,7 +65,7 @@ export default function GuestDetails({
|
|||||||
</Caption>
|
</Caption>
|
||||||
</div>
|
</div>
|
||||||
<MembershipLevelIcon
|
<MembershipLevelIcon
|
||||||
level={user.membership.membershipLevel}
|
level={user.membership!.membershipLevel}
|
||||||
color="red"
|
color="red"
|
||||||
height={isMobile ? "40" : "20"}
|
height={isMobile ? "40" : "20"}
|
||||||
width={isMobile ? "80" : "40"}
|
width={isMobile ? "80" : "40"}
|
||||||
@@ -62,7 +86,7 @@ export default function GuestDetails({
|
|||||||
</Caption>
|
</Caption>
|
||||||
|
|
||||||
<Body color="uiTextHighContrast" className={styles.totalPointsText}>
|
<Body color="uiTextHighContrast" className={styles.totalPointsText}>
|
||||||
{user.membership.currentPoints}
|
{user.membership!.currentPoints}
|
||||||
</Body>
|
</Body>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -71,10 +95,10 @@ export default function GuestDetails({
|
|||||||
<Body textTransform="bold" color="uiTextHighContrast">
|
<Body textTransform="bold" color="uiTextHighContrast">
|
||||||
{booking.guest.firstName} {booking.guest.lastName}
|
{booking.guest.firstName} {booking.guest.lastName}
|
||||||
</Body>
|
</Body>
|
||||||
{user?.membership && (
|
{isMemberBooking && (
|
||||||
<Body color="uiTextHighContrast">
|
<Body color="uiTextHighContrast">
|
||||||
{intl.formatMessage({ id: "Member no." })}{" "}
|
{intl.formatMessage({ id: "Member no." })}{" "}
|
||||||
{user.membership.membershipNumber}
|
{user.membership!.membershipNumber}
|
||||||
</Body>
|
</Body>
|
||||||
)}
|
)}
|
||||||
<Caption color="uiTextHighContrast">{booking.guest.email}</Caption>
|
<Caption color="uiTextHighContrast">{booking.guest.email}</Caption>
|
||||||
@@ -86,6 +110,7 @@ export default function GuestDetails({
|
|||||||
variant="icon"
|
variant="icon"
|
||||||
color="burgundy"
|
color="burgundy"
|
||||||
intent={isMobile ? "secondary" : "text"}
|
intent={isMobile ? "secondary" : "text"}
|
||||||
|
onClick={handleModifyGuestDetails}
|
||||||
>
|
>
|
||||||
<EditIcon color="burgundy" width={20} height={20} />
|
<EditIcon color="burgundy" width={20} height={20} />
|
||||||
<Caption color="burgundy">
|
<Caption color="burgundy">
|
||||||
|
|||||||
Reference in New Issue
Block a user