"use client"; import { certificationExpiryBadgeVariant, certificationExpiryLabel, type CertificationRenewal, type Renewable, } from "@/lib/certification"; import { formatDateOnly } from "@/lib/date-time"; import { Badge } from "@/components/ui/badge"; import { TruncatedNote } from "@/components/ui/truncated-note"; import { NotificationRow } from "@/components/layout/notification-row"; interface RenewalsListProps { // Already flagged and sorted, soonest first - see `certificationRenewals`. renewals: CertificationRenewal[]; truncated: boolean; // Called as a row's title link is followed, so whatever holds the list can close. onNavigate: () => void; // A click on the row: open the form whose "Expires on" this is. onRenew: (row: Renewable) => void; } // What a diver has to renew - certifications that have run out or are about to, and // the insurance policies among them. export function RenewalsList({ renewals, truncated, onNavigate, onRenew, }: RenewalsListProps) { return (
{renewals.map(({ certification: row, status, expiresOn }) => ( {certificationExpiryLabel(status)} } qualifier={`on ${formatDateOnly(expiresOn)}`} actionLabel={ row.kind === "insurance" ? `Edit your ${row.title} policy` : `Edit ${row.title}` } onAction={() => onRenew(row)} onNavigate={onNavigate} /> ))} {truncated && }
); }