import {type FunctionComponent} from 'react'
import {getFavoriteContacts} from '@/dal/contacts'
import FavoriteCard from '@/app/(authenticated)/contacts/_favoriteContacts/favoriteCard'
import {getSessionProfileFromCookieOrThrow} from '@/lib/sessionUtils'

const FavoritesList: FunctionComponent = async () => {
  const profile = await getSessionProfileFromCookieOrThrow()
  const favorites = await getFavoriteContacts(profile.id)

  return (
    <>
      {favorites.map(f => (
        <FavoriteCard key={f.id} {...f} />
      ))}
    </>
  )
}

export default FavoritesList
