feat: Ajouter colonne Notif. dans tableau factures et améliorer message par défaut

- Ajouter colonne 'Notif.' avec voyant vert (Oui) ou gris (Non) après la colonne Statut
- Enlever le bouton 'Modifier' du tableau (garder seulement 'Voir')
- Ajouter champ notified au type Invoice et à l'API GET /staff/facturation
- Ajouter période au message par défaut pour factures sans invoice_type reconnu
- Appliqué aux deux routes (notify et bulk-notify)
This commit is contained in:
odentas 2025-12-04 22:30:54 +01:00
parent 5bff842a8c
commit 6dffd2ed45
4 changed files with 22 additions and 19 deletions

View file

@ -23,6 +23,7 @@ type Invoice = {
pdf?: string | null;
org_id: string;
organization_name?: string;
notified?: boolean;
};
type StaffBillingResponse = {
@ -1193,6 +1194,7 @@ export default function StaffFacturationPage() {
/>
</th>
<th className="px-3 py-2 w-24">Statut</th>
<th className="px-3 py-2 w-20">Notif.</th>
<th className="px-3 py-2 w-32">
<button
onClick={() => handleSort("numero")}
@ -1242,7 +1244,7 @@ export default function StaffFacturationPage() {
{filteredAndSortedItems.length > 0 && (
<tr className="border-b bg-blue-50">
<td className="px-3 py-2"></td>
<td colSpan={5} className="px-3 py-2 text-sm font-medium text-blue-900">
<td colSpan={6} className="px-3 py-2 text-sm font-medium text-blue-900">
Total affiché ({filteredAndSortedItems.length} facture{filteredAndSortedItems.length > 1 ? "s" : ""})
</td>
<td className="px-3 py-2 text-right font-bold text-blue-900">
@ -1286,6 +1288,13 @@ export default function StaffFacturationPage() {
<span className="inline-flex items-center gap-1 text-xs"><span className="w-2 h-2 rounded-full bg-blue-500 flex-shrink-0"/> Émise</span>
)}
</td>
<td className="px-3 py-2">
{f.notified ? (
<span className="inline-flex items-center gap-1 text-xs"><span className="w-2 h-2 rounded-full bg-emerald-500 flex-shrink-0"/> Oui</span>
) : (
<span className="inline-flex items-center gap-1 text-xs"><span className="w-2 h-2 rounded-full bg-slate-400 flex-shrink-0"/> Non</span>
)}
</td>
<td className="px-3 py-2 font-medium text-nowrap">{f.numero || "—"}</td>
<td className="px-3 py-2">
<span className="font-medium">{f.organization_name || "—"}</span>
@ -1304,22 +1313,13 @@ export default function StaffFacturationPage() {
)}
</td>
<td className="px-3 py-2">
<div className="flex items-center gap-2">
<Link
href={`/staff/facturation/${f.id}`}
className="inline-flex items-center gap-1 text-xs px-2 py-1 bg-blue-100 text-blue-700 rounded hover:bg-blue-200 transition-colors"
>
<Eye className="w-3 h-3" />
Voir
</Link>
<Link
href={`/staff/facturation/${f.id}?edit=true`}
className="inline-flex items-center gap-1 text-xs px-2 py-1 bg-amber-100 text-amber-700 rounded hover:bg-amber-200 transition-colors"
>
<Edit className="w-3 h-3" />
Modifier
</Link>
</div>
<Link
href={`/staff/facturation/${f.id}`}
className="inline-flex items-center gap-1 text-xs px-2 py-1 bg-blue-100 text-blue-700 rounded hover:bg-blue-200 transition-colors"
>
<Eye className="w-3 h-3" />
Voir
</Link>
</td>
</tr>
))}

View file

@ -47,8 +47,9 @@ function buildInvoiceCustomMessage(invoice: any): string {
}
return `Votre facture pour le renouvellement du site web ${siteNameRenewal} est disponible et sera prélevée à la date indiquée ci-dessous.`.trim();
default:
const defaultPeriodText = invoice.period_label || 'du mois';
console.warn('[buildInvoiceCustomMessage] Unknown invoice_type:', invoice.invoice_type, 'for invoice:', invoice.id);
return 'Votre facture est disponible et sera prélevée à la date indiquée ci-dessous.';
return `Votre facture pour la période ${defaultPeriodText} est disponible et sera prélevée à la date indiquée ci-dessous.`;
}
}

View file

@ -47,8 +47,9 @@ function buildInvoiceCustomMessage(invoice: any): string {
}
return `Votre facture pour le renouvellement du site web ${siteNameRenewal} est disponible et sera prélevée à la date indiquée ci-dessous.`.trim();
default:
const defaultPeriodText = invoice.period_label || 'du mois';
console.warn('[buildInvoiceCustomMessage] Unknown invoice_type:', invoice.invoice_type, 'for invoice:', invoice.id);
return 'Votre facture est disponible et sera prélevée à la date indiquée ci-dessous.';
return `Votre facture pour la période ${defaultPeriodText} est disponible et sera prélevée à la date indiquée ci-dessous.`;
}
}

View file

@ -131,6 +131,7 @@ export async function GET(req: Request) {
pdf: await maybeSign(r.pdf_s3_key || null),
org_id: r.org_id,
organization_name: organizationsMap[r.org_id] || null,
notified: r.notified || false,
})));
const total = typeof count === 'number' ? count : items.length;