import { IconCalendarCheck } from "@tabler/icons-react";

interface PageLastReviewedProps {
  date: string;
  label: string;
}

export function PageLastReviewed({ date, label }: PageLastReviewedProps) {
  return (
    <div className="container mx-auto px-4 py-8 sm:px-6 lg:px-8">
      <div className="mx-auto flex max-w-4xl items-center gap-2 text-neutral-400 text-sm">
        <IconCalendarCheck
          className="h-4 w-4 text-white/80"
          strokeWidth={1.5}
        />
        <span>
          {label} <time dateTime={date}>{formatDate(date)}</time>
        </span>
      </div>
    </div>
  );
}

function formatDate(iso: string): string {
  const d = new Date(iso);
  return d.toLocaleDateString("fr-FR", {
    day: "numeric",
    month: "long",
    year: "numeric",
  });
}
