import Title from "@/components/Title"
import ContactRow from "./ContactRow"

import styles from "./contact.module.css"

import { JoinLoyaltyContactTypenameEnum } from "@/types/requests/loyaltyPage"
import type { ContactProps } from "@/types/components/loyalty/sidebar"

export default async function Contact({ contactBlock }: ContactProps) {
  return (
    <div className={styles.contactContainer}>
      <Title level="h5">Contact us</Title>
      <section>
        {contactBlock.map(({ contact, __typename }) => {
          switch (__typename) {
            case JoinLoyaltyContactTypenameEnum.LoyaltyPageSidebarJoinLoyaltyContactBlockContactContact:
              return <ContactRow contact={contact} />
            default:
              return null
          }
        })}
      </section>
    </div>
  )
}
