import {type FunctionComponent} from 'react'
import ContactDetailForm from '@/app/(authenticated)/contacts/[contactId]/edit/contactDetailForm'
import {getContact} from '@/dal/contacts'
import {getSessionProfileFromCookieOrThrow} from '@/lib/sessionUtils'

interface ContactEditPageProps {
  params: Promise<{
    contactId: string
  }>
}

const ContactEditPageProps: FunctionComponent<ContactEditPageProps> = async ({params}) => {
  const {contactId} = await params
  const profile = await getSessionProfileFromCookieOrThrow()
  const contact = await getContact(contactId, profile.id)

  return <ContactDetailForm {...contact} />
}

export default ContactEditPageProps
