refactor(ui): OrderDetail uses shared ORDER_STATUS (removes the last duplicate status map)
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -19,6 +19,7 @@ import OrderConfirmationModal from "../components/OrderConfirmationModal";
|
||||
import Forbidden from "../components/Forbidden";
|
||||
import apiFetch from "../utils/api";
|
||||
import { formatCurrency, formatDate } from "../utils/formatters";
|
||||
import { ORDER_STATUS, statusLabel, statusColor } from "../lib/documentStatus";
|
||||
import {
|
||||
Button,
|
||||
Card,
|
||||
@@ -40,23 +41,6 @@ const API_BASE = "/api/admin";
|
||||
|
||||
type ItemRow = OrderItem & { _index: number };
|
||||
|
||||
const STATUS_LABELS: Record<string, string> = {
|
||||
prijata: "Přijatá",
|
||||
v_realizaci: "V realizaci",
|
||||
dokoncena: "Dokončená",
|
||||
stornovana: "Stornována",
|
||||
};
|
||||
|
||||
const STATUS_COLORS: Record<
|
||||
string,
|
||||
"default" | "success" | "error" | "warning" | "info"
|
||||
> = {
|
||||
prijata: "info",
|
||||
v_realizaci: "warning",
|
||||
dokoncena: "success",
|
||||
stornovana: "error",
|
||||
};
|
||||
|
||||
const TRANSITION_LABELS: Record<string, string> = {
|
||||
v_realizaci: "Zahájit realizaci",
|
||||
dokoncena: "Dokončit",
|
||||
@@ -420,8 +404,8 @@ export default function OrderDetail() {
|
||||
Objednávka {order.order_number}
|
||||
</Typography>
|
||||
<StatusChip
|
||||
label={STATUS_LABELS[order.status] || order.status}
|
||||
color={STATUS_COLORS[order.status] || "default"}
|
||||
label={statusLabel(ORDER_STATUS, order.status)}
|
||||
color={statusColor(ORDER_STATUS, order.status)}
|
||||
/>
|
||||
</Box>
|
||||
</Box>
|
||||
@@ -803,7 +787,7 @@ export default function OrderDetail() {
|
||||
onClose={() => setStatusConfirm({ show: false, status: null })}
|
||||
onConfirm={handleStatusChange}
|
||||
title="Změnit stav objednávky"
|
||||
message={`Opravdu chcete změnit stav objednávky "${order.order_number}" na "${STATUS_LABELS[statusConfirm.status || ""]}"?${statusConfirm.status === "dokoncena" ? " Projekt bude automaticky dokončen." : ""}`}
|
||||
message={`Opravdu chcete změnit stav objednávky "${order.order_number}" na "${statusLabel(ORDER_STATUS, statusConfirm.status)}"?${statusConfirm.status === "dokoncena" ? " Projekt bude automaticky dokončen." : ""}`}
|
||||
confirmText={
|
||||
TRANSITION_LABELS[statusConfirm.status || ""] || "Potvrdit"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user