"use client";
import { useFormatter, useTranslations } from "next-intl";
import { formatPolicyDate } from "@/lib/formatPolicyDate";

interface TermsAndConditionsHeaderProps {
  updatedAt?: string | null;
}

export default function TermsAndConditionsHeader({
  updatedAt,
}: TermsAndConditionsHeaderProps) {
  const t = useTranslations("TermsAndConditionsPage");
  const format = useFormatter();
  const formattedDate = formatPolicyDate(format, updatedAt);

  return (
    <div>
      <h2 className="text-secondary-main text-[20px] md:text-[24px] font-bold">
        {t("title")}
      </h2>
      {formattedDate && (
        <h4 className="text-[14px] font-light">
          {t("lastUpdated", { date: formattedDate })}
        </h4>
      )}
    </div>
  );
}
