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:
@@ -58,28 +58,14 @@ import {
|
||||
PageEnter,
|
||||
headerActionsSx,
|
||||
} from "../ui";
|
||||
import {
|
||||
ISSUED_ORDER_STATUS,
|
||||
statusLabel,
|
||||
statusColor,
|
||||
} from "../lib/documentStatus";
|
||||
|
||||
const API_BASE = "/api/admin";
|
||||
|
||||
const STATUS_LABELS: Record<string, string> = {
|
||||
draft: "Koncept",
|
||||
sent: "Odeslaná",
|
||||
confirmed: "Potvrzená",
|
||||
completed: "Dokončená",
|
||||
cancelled: "Stornovaná",
|
||||
};
|
||||
|
||||
const STATUS_COLORS: Record<
|
||||
string,
|
||||
"default" | "success" | "error" | "warning" | "info"
|
||||
> = {
|
||||
draft: "default",
|
||||
sent: "info",
|
||||
confirmed: "warning",
|
||||
completed: "success",
|
||||
cancelled: "error",
|
||||
};
|
||||
|
||||
// Labels for the buttons that trigger a status transition.
|
||||
const TRANSITION_LABELS: Record<string, string> = {
|
||||
sent: "Odeslat",
|
||||
@@ -862,8 +848,8 @@ export default function IssuedOrderDetail() {
|
||||
</Typography>
|
||||
{isEdit && (
|
||||
<StatusChip
|
||||
label={STATUS_LABELS[form.status] || form.status}
|
||||
color={STATUS_COLORS[form.status] || "default"}
|
||||
label={statusLabel(ISSUED_ORDER_STATUS, form.status)}
|
||||
color={statusColor(ISSUED_ORDER_STATUS, form.status)}
|
||||
/>
|
||||
)}
|
||||
</Box>
|
||||
@@ -1281,9 +1267,10 @@ export default function IssuedOrderDetail() {
|
||||
onClose={() => setStatusConfirm({ show: false, status: null })}
|
||||
onConfirm={handleStatusChange}
|
||||
title="Změnit stav objednávky"
|
||||
message={`Opravdu chcete změnit stav objednávky "${poNumber}" na "${
|
||||
STATUS_LABELS[statusConfirm.status || ""] || ""
|
||||
}"?`}
|
||||
message={`Opravdu chcete změnit stav objednávky "${poNumber}" na "${statusLabel(
|
||||
ISSUED_ORDER_STATUS,
|
||||
statusConfirm.status,
|
||||
)}"?`}
|
||||
confirmText={
|
||||
TRANSITION_LABELS[statusConfirm.status || ""] || "Potvrdit"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user