39 lines
1.0 KiB
TypeScript
39 lines
1.0 KiB
TypeScript
import { serverClient } from "@/lib/trpc/server"
|
|
|
|
import { EmailIcon, PhoneIcon } from "@/components/Icons"
|
|
import Body from "@/components/TempDesignSystem/Text/Body"
|
|
import { getValueFromContactConfig } from "@/utils/contactConfig"
|
|
|
|
import styles from "./contactRow.module.css"
|
|
|
|
import type { ContactRowProps } from "@/types/components/loyalty/sidebar"
|
|
|
|
export default async function ContactRow({ contact }: ContactRowProps) {
|
|
const data = await serverClient().contentstack.base.contact()
|
|
|
|
const val = getValueFromContactConfig(contact.contact_field, data)
|
|
|
|
if (!val) {
|
|
return null
|
|
}
|
|
|
|
let Icon = null
|
|
if (contact.contact_field.includes("email")) {
|
|
Icon = EmailIcon
|
|
} else if (contact.contact_field.includes("phone")) {
|
|
Icon = PhoneIcon
|
|
}
|
|
|
|
return (
|
|
<div>
|
|
{Icon ? <Icon className={styles.icon} /> : null}
|
|
<Body color="burgundy" textAlign="center" textTransform="bold">
|
|
{contact.display_text}
|
|
</Body>
|
|
<Body color="burgundy" textAlign="center">
|
|
{val}
|
|
</Body>
|
|
</div>
|
|
)
|
|
}
|