Files
web/apps/scandic-web/components/Sidebar/JoinLoyalty/Contact/ContactRow/index.tsx
Matilda Landström 5de2a993a7 Merged in feat/SW-1711-switch-icons (pull request #1558)
Switches out all the old icons to new ones, and moves them to the design system. The new icons are of three different types: Materialise Symbol, Nucleo, and Customized. Also adds further mapping between facilities/amenities and icons.

Approved-by: Michael Zetterberg
Approved-by: Erik Tiekstra
2025-03-27 09:42:52 +00:00

69 lines
1.9 KiB
TypeScript

import {
MaterialIcon,
type MaterialIconSetIconProps,
} from "@scandic-hotels/design-system/Icons"
import { serverClient } from "@/lib/trpc/server"
import Link from "@/components/TempDesignSystem/Link"
import Body from "@/components/TempDesignSystem/Text/Body"
import Footnote from "@/components/TempDesignSystem/Text/Footnote"
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 data = await serverClient().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 = function (props: MaterialIconSetIconProps) {
return <MaterialIcon icon="mail" {...props} />
}
} else if (contact.contact_field.includes("phone")) {
Icon = function (props: MaterialIconSetIconProps) {
return <MaterialIcon icon="phone" {...props} />
}
}
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}
variant="underscored"
color="burgundy"
size="small"
>
{Icon ? <Icon size={20} color="Icon/Interactive/Default" /> : null}
{val}
</Link>
{footnote && <Footnote color="burgundy">{footnote}</Footnote>}
</div>
)
}