"use client"

import { useEffect, useState } from "react"
import { formatInvitationTimeChip } from "@/lib/calendar-invitation"

type InvitationTimeChipTextProps = {
  start: Date
  end: Date
}

/** Horaire invitation formaté côté client (fuseau navigateur, évite mismatch SSR). */
export function InvitationTimeChipText({ start, end }: InvitationTimeChipTextProps) {
  const [text, setText] = useState("\u00a0")

  useEffect(() => {
    setText(formatInvitationTimeChip(start, end))
  }, [start, end])

  return <span suppressHydrationWarning>{text}</span>
}
