"use client";

import { useTranslation } from "react-i18next";
import { useLanguageStore } from "@/store/languageStore";
import { missedCheckOutAlert, type AttendanceBearingRow, type MissedCheckOutMeta } from "./volunteerListHelpers";

/**
 * «3 مشاركين سجلوا دخول بدون خروج، عدل ساعاتهم قبل قفل نافذة التحضير» —
 * the organizer's reminder for forgotten check-outs (client answers p.6,
 * additional note). Shown while hours can still be corrected.
 */
export default function MissedCheckOutBanner({
  registrations,
  canStillEdit,
  meta,
  listComplete,
}: {
  registrations: AttendanceBearingRow[];
  canStillEdit: boolean;
  meta?: MissedCheckOutMeta | null;
  listComplete: boolean;
}) {
  const { t } = useTranslation();
  const language = useLanguageStore((s) => s.language);
  const { count, note } = missedCheckOutAlert(registrations, meta, listComplete, language);
  if (!canStillEdit || count === 0) return null;
  return (
    <p role="status" className="mx-auto mb-6 max-w-3xl rounded-xl bg-amber-50 p-4 text-center text-amber-900">
      {note ?? t("COMMON.MISSED_CHECK_OUT_ALERT", { count })}
    </p>
  );
}
