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 Forbidden from "../components/Forbidden";
|
||||||
import apiFetch from "../utils/api";
|
import apiFetch from "../utils/api";
|
||||||
import { formatCurrency, formatDate } from "../utils/formatters";
|
import { formatCurrency, formatDate } from "../utils/formatters";
|
||||||
|
import { ORDER_STATUS, statusLabel, statusColor } from "../lib/documentStatus";
|
||||||
import {
|
import {
|
||||||
Button,
|
Button,
|
||||||
Card,
|
Card,
|
||||||
@@ -40,23 +41,6 @@ const API_BASE = "/api/admin";
|
|||||||
|
|
||||||
type ItemRow = OrderItem & { _index: number };
|
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> = {
|
const TRANSITION_LABELS: Record<string, string> = {
|
||||||
v_realizaci: "Zahájit realizaci",
|
v_realizaci: "Zahájit realizaci",
|
||||||
dokoncena: "Dokončit",
|
dokoncena: "Dokončit",
|
||||||
@@ -420,8 +404,8 @@ export default function OrderDetail() {
|
|||||||
Objednávka {order.order_number}
|
Objednávka {order.order_number}
|
||||||
</Typography>
|
</Typography>
|
||||||
<StatusChip
|
<StatusChip
|
||||||
label={STATUS_LABELS[order.status] || order.status}
|
label={statusLabel(ORDER_STATUS, order.status)}
|
||||||
color={STATUS_COLORS[order.status] || "default"}
|
color={statusColor(ORDER_STATUS, order.status)}
|
||||||
/>
|
/>
|
||||||
</Box>
|
</Box>
|
||||||
</Box>
|
</Box>
|
||||||
@@ -803,7 +787,7 @@ export default function OrderDetail() {
|
|||||||
onClose={() => setStatusConfirm({ show: false, status: null })}
|
onClose={() => setStatusConfirm({ show: false, status: null })}
|
||||||
onConfirm={handleStatusChange}
|
onConfirm={handleStatusChange}
|
||||||
title="Změnit stav objednávky"
|
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={
|
confirmText={
|
||||||
TRANSITION_LABELS[statusConfirm.status || ""] || "Potvrdit"
|
TRANSITION_LABELS[statusConfirm.status || ""] || "Potvrdit"
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user