Files
web/apps/scandic-web/components/Sidebar/JoinLoyalty/Contact/ContactRow/index.tsx
Erik Tiekstra 333636c81a Merged in feat/BOOK-61-refactor-hotel-page-css-variables (pull request #3014)
Feat/BOOK-61 refactor hotel page css variables

* feat(BOOK-61): Breadcrumbs

* feat(BOOK-61): intro section

* feat(BOOK-61): show more button

* feat(BOOK-61): rooms section

* feat(BOOK-61): sidepeeks

* feat(BOOK-61): deprecated old Link component

* feat(BOOK-61): added new TextLink component to the design-system

* feat(BOOK-61): replaced deprecated links with new TextLink component

* feat(BOOK-61): miscellaneous changes


Approved-by: Bianca Widstam
Approved-by: Christel Westerberg
2025-10-29 09:15:03 +00:00

72 lines
2.0 KiB
TypeScript

import Body from "@scandic-hotels/design-system/Body"
import Footnote from "@scandic-hotels/design-system/Footnote"
import {
MaterialIcon,
type MaterialIconSetIconProps,
} from "@scandic-hotels/design-system/Icons/MaterialIcon"
import Link from "@scandic-hotels/design-system/OldDSLink"
import { getValueFromContactConfig } from "@scandic-hotels/trpc/utils/contactConfig"
import { serverClient } from "@/lib/trpc/server"
// import { getValueFromContactConfig } from "@/utils/contactConfig"
import styles from "./contactRow.module.css"
import type { ContactRowProps } from "@/types/components/sidebar/joinLoyaltyContact"
export default async function ContactRow({ contact }: ContactRowProps) {
const caller = await serverClient()
const data = await caller.contentstack.base.contact()
if (!data) {
return null
}
const val = getValueFromContactConfig(contact.contact_field, data)
const footnote = contact.footnote
? getValueFromContactConfig(contact.footnote, data)
: null
if (!val) {
return null
}
let Icon = null
if (contact.contact_field.includes("email")) {
Icon = MailIcon
} else if (contact.contact_field.includes("phone")) {
Icon = PhoneIcon
}
let openableLink = val
if (contact.contact_field.includes("email")) {
openableLink = `mailto:${val}`
} else if (contact.contact_field.includes("phone")) {
openableLink = `tel:${val}`
}
return (
<div className={styles.wrapper}>
<Body color="burgundy" textTransform="bold">
{contact.display_text}
</Body>
<Link
className={styles.link}
href={openableLink}
textDecoration="underline"
size="small"
>
{Icon ? <Icon size={20} color="Icon/Interactive/Default" /> : null}
{val}
</Link>
{footnote && <Footnote color="burgundy">{footnote}</Footnote>}
</div>
)
}
function PhoneIcon(props: MaterialIconSetIconProps) {
return <MaterialIcon icon="phone" {...props} />
}
function MailIcon(props: MaterialIconSetIconProps) {
return <MaterialIcon icon="mail" {...props} />
}