refactor(ui): single shared documentStatus map across offers/invoices/orders (fix issued color drift, add offers status chip)

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
BOHA
2026-06-09 16:12:44 +02:00
parent d341db2e51
commit 66235ff567
9 changed files with 200 additions and 131 deletions

View File

@@ -67,6 +67,11 @@ import {
RichTextView,
headerActionsSx,
} from "../ui";
import {
INVOICE_STATUS,
statusLabel,
statusColor,
} from "../lib/documentStatus";
const API_BASE = "/api/admin";
@@ -97,21 +102,6 @@ function addDaysLocalStr(days: number, base?: string): string {
return `${result.getFullYear()}-${mm}-${dd}`;
}
const STATUS_LABELS: Record<string, string> = {
issued: "Vystavena",
paid: "Zaplacena",
overdue: "Po splatnosti",
};
const STATUS_COLORS: Record<
string,
"default" | "success" | "error" | "warning" | "info"
> = {
issued: "info",
paid: "success",
overdue: "error",
};
const TRANSITION_LABELS: Record<string, string> = { paid: "Zaplaceno" };
const BackIcon = (
@@ -1141,8 +1131,8 @@ export default function InvoiceDetail() {
Faktura {invoice.invoice_number}
</Typography>
<StatusChip
label={STATUS_LABELS[invoice.status] || invoice.status}
color={STATUS_COLORS[invoice.status] || "default"}
label={statusLabel(INVOICE_STATUS, invoice.status)}
color={statusColor(INVOICE_STATUS, invoice.status)}
/>
</Box>
</Box>
@@ -1658,8 +1648,8 @@ export default function InvoiceDetail() {
Faktura {invoice.invoice_number}
</Typography>
<StatusChip
label={STATUS_LABELS[invoice.status] || invoice.status}
color={STATUS_COLORS[invoice.status] || "default"}
label={statusLabel(INVOICE_STATUS, invoice.status)}
color={statusColor(INVOICE_STATUS, invoice.status)}
/>
</Box>
) : (
@@ -2249,7 +2239,7 @@ export default function InvoiceDetail() {
onClose={() => setStatusConfirm({ show: false, status: null })}
onConfirm={handleStatusChange}
title="Změnit stav faktury"
message={`Opravdu chcete změnit stav faktury "${invoice.invoice_number}" na "${STATUS_LABELS[statusConfirm.status || ""]}"?`}
message={`Opravdu chcete změnit stav faktury "${invoice.invoice_number}" na "${statusLabel(INVOICE_STATUS, statusConfirm.status)}"?`}
confirmText={
TRANSITION_LABELS[statusConfirm.status || ""] || "Potvrdit"
}