import type {FunctionComponent} from 'react'
import {Card, CardContent, CardDescription, CardHeader, CardTitle} from '@/components/ui/card'
import Link from 'next/link'
import {BookUserIcon, CalendarIcon, EditIcon} from 'lucide-react'
import type {MeetingWithContact} from '@/models/meetings'

const Meeting: FunctionComponent<MeetingWithContact> = ({id, contactId, description, contact, title, date}) => {
  return (
    <Card>
      <CardHeader>
        <CardTitle className="text-2xl text-ellipsis whitespace-nowrap overflow-hidden ">{title}</CardTitle>
        <CardDescription className="flex gap-2 items-center flex-row justify-between">
          <span className="flex gap-2 items-center" suppressHydrationWarning>
            <CalendarIcon size={20} /> {date.toLocaleDateString()}
          </span>
          <Link href={`/meetings/${id}`}>
            <EditIcon size={20} className="hover:cursor-pointer" />
          </Link>
        </CardDescription>
        <CardDescription className="flex gap-2 items-center">
          <BookUserIcon size={20} />
          <Link href={`/contacts/${contactId}`}>
            {contact.firstName} {contact.lastName}
          </Link>
        </CardDescription>
      </CardHeader>
      <CardContent className="h-[6rem] overflow-y-auto flex-grow">{description}</CardContent>
    </Card>
  )
}

export default Meeting
