feat(LOY-243): add change name disclaimer to profile

This commit is contained in:
Christian Andolf
2025-05-27 16:54:52 +02:00
parent ac953ccd97
commit 7fdffb8e1d
5 changed files with 136 additions and 68 deletions

View File

@@ -17,6 +17,7 @@ import { trpc } from "@/lib/trpc/client"
import { editProfile } from "@/actions/editProfile"
import Dialog from "@/components/Dialog"
import ChangeNameDisclaimer from "@/components/MyPages/Profile/ChangeNameDisclaimer"
import Button from "@/components/TempDesignSystem/Button"
import Title from "@/components/TempDesignSystem/Text/Title"
import { toast } from "@/components/TempDesignSystem/Toasts"
@@ -120,74 +121,77 @@ export default function Form({ user }: EditFormProps) {
}, [trigger])
return (
<section className={styles.container}>
<div className={styles.title}>
<Title as="h4" color="red" level="h1" textTransform="capitalize">
{intl.formatMessage({
defaultMessage: "Welcome",
})}
</Title>
<Title
data-hj-suppress
as="h4"
color="burgundy"
level="h2"
textTransform="capitalize"
<>
<section className={styles.container}>
<div className={styles.title}>
<Title as="h4" color="red" level="h1" textTransform="capitalize">
{intl.formatMessage({
defaultMessage: "Welcome",
})}
</Title>
<Title
data-hj-suppress
as="h4"
color="burgundy"
level="h2"
textTransform="capitalize"
>
{user.name}
</Title>
</div>
<div className={styles.btnContainer}>
<Dialog
bodyText={intl.formatMessage({
defaultMessage: "Any changes you've made will be lost.",
})}
cancelButtonText={intl.formatMessage({
defaultMessage: "Go back to edit",
})}
proceedHref={profile[lang]}
proceedText={intl.formatMessage({
defaultMessage: "Yes, discard changes",
})}
titleText={intl.formatMessage({
defaultMessage: "Discard unsaved changes?",
})}
trigger={
<Button intent="secondary" size="small" theme="base">
{intl.formatMessage({
defaultMessage: "Discard changes",
})}
</Button>
}
/>
<Button
disabled={!isValid || methods.formState.isSubmitting}
form={formId}
intent="primary"
size="small"
theme="base"
type="submit"
>
{intl.formatMessage({
defaultMessage: "Save",
})}
</Button>
</div>
<form
/**
* Ignoring since ts doesn't recognize that tRPC
* parses FormData before reaching the route
* @ts-ignore */
action={editProfile}
className={styles.form}
id={formId}
onSubmit={methods.handleSubmit(handleSubmit)}
>
{user.name}
</Title>
</div>
<div className={styles.btnContainer}>
<Dialog
bodyText={intl.formatMessage({
defaultMessage: "Any changes you've made will be lost.",
})}
cancelButtonText={intl.formatMessage({
defaultMessage: "Go back to edit",
})}
proceedHref={profile[lang]}
proceedText={intl.formatMessage({
defaultMessage: "Yes, discard changes",
})}
titleText={intl.formatMessage({
defaultMessage: "Discard unsaved changes?",
})}
trigger={
<Button intent="secondary" size="small" theme="base">
{intl.formatMessage({
defaultMessage: "Discard changes",
})}
</Button>
}
/>
<Button
disabled={!isValid || methods.formState.isSubmitting}
form={formId}
intent="primary"
size="small"
theme="base"
type="submit"
>
{intl.formatMessage({
defaultMessage: "Save",
})}
</Button>
</div>
<FormProvider {...methods}>
<FormContent />
</FormProvider>
</form>
</section>
<form
/**
* Ignoring since ts doesn't recognize that tRPC
* parses FormData before reaching the route
* @ts-ignore */
action={editProfile}
className={styles.form}
id={formId}
onSubmit={methods.handleSubmit(handleSubmit)}
>
<FormProvider {...methods}>
<FormContent />
</FormProvider>
</form>
</section>
<ChangeNameDisclaimer />
</>
)
}

View File

@@ -0,0 +1,6 @@
.changeNameDisclaimer {
display: flex;
gap: var(--Space-x1);
color: var(--Text-Secondary);
align-items: center;
}

View File

@@ -0,0 +1,54 @@
"use client"
import { useIntl } from "react-intl"
import { MaterialIcon } from "@scandic-hotels/design-system/Icons/MaterialIcon"
import { Typography } from "@scandic-hotels/design-system/Typography"
import Link from "@/components/TempDesignSystem/Link"
import styles from "./changeNameDisclaimer.module.css"
export default function ChangeNameDisclaimer() {
const intl = useIntl()
return (
<div className={styles.changeNameDisclaimer}>
<MaterialIcon icon="info" />
<Typography variant="Body/Paragraph/mdRegular">
<p>
{intl.formatMessage(
{
defaultMessage:
"Need to change your name? Please get in touch with member support at <phone>+46 8 517 517 00</phone> or <email>member@scandichotels.com</email>.",
},
{
phone([str]) {
return (
<Link
href={`tel:${str.replaceAll(" ", "")}`}
textDecoration="underline"
weight="bold"
>
{str}
</Link>
)
},
email(str) {
return (
<Link
href={`mailto:${str}`}
textDecoration="underline"
weight="bold"
>
{str}
</Link>
)
},
}
)}
</p>
</Typography>
</div>
)
}

View File

@@ -16,6 +16,8 @@ import { getLang } from "@/i18n/serverContext"
import { isValidCountry } from "@/utils/countries"
import { isValidLang } from "@/utils/languages"
import ChangeNameDisclaimer from "./ChangeNameDisclaimer"
import styles from "./profile.module.css"
export default async function Profile() {
@@ -173,6 +175,9 @@ export default async function Profile() {
</Typography>
</div>
</div>
<ChangeNameDisclaimer />
<Divider color="burgundy" opacity={8} />
<CreditCardSlot />
{/* <MembershipCardSlot /> */}

View File

@@ -4,7 +4,6 @@
display: grid;
gap: var(--Space-x3);
padding: var(--Space-x2) var(--Space-x2) var(--Space-x4);
color: var(--Text-Default);
}
.title {