diff --git a/src/admin/lib/entityTypeLabels.ts b/src/admin/lib/entityTypeLabels.ts new file mode 100644 index 0000000..20b199d --- /dev/null +++ b/src/admin/lib/entityTypeLabels.ts @@ -0,0 +1,39 @@ +// Single source of truth for audit-log entity_type → Czech label, used by +// the Audit Log page and the dashboard activity feed. +// +// IMPORTANT: keys MUST match the `entityType` values the server actually +// writes via logAudit() (see src/types/index.ts `EntityType` and the +// `entityType:` args in src/routes/**). The previous maps used legacy keys +// (e.g. "invoices_invoice", "offers_quotation", "trips") that never matched +// what the server writes, and omitted every warehouse_* entity, so those +// audit rows rendered the raw English entity_type instead of a Czech label. +export const ENTITY_TYPE_LABELS: Record = { + user: "Uživatel", + role: "Role", + attendance: "Docházka", + leave_request: "Žádost o nepřítomnost", + leave_balance: "Saldo nepřítomnosti", + invoice: "Faktura", + quotation: "Nabídka", + order: "Objednávka", + project: "Projekt", + project_file: "Soubor projektu", + customer: "Zákazník", + trip: "Jízda", + vehicle: "Vozidlo", + bank_account: "Bankovní účet", + company_settings: "Nastavení firmy", + audit_logs: "Audit log", + warehouse_item: "Skladová položka", + warehouse_receipt: "Příjemka", + warehouse_issue: "Výdejka", + warehouse_reservation: "Rezervace", + warehouse_inventory: "Inventura", + warehouse_supplier: "Dodavatel", + warehouse_category: "Kategorie skladu", + warehouse_location: "Skladová lokace", + warehouse_receipt_attachment: "Příloha příjemky", + work_plan_entry: "Plán prací – záznam", + work_plan_override: "Plán prací – přepsání dne", + plan_category: "Plán prací – kategorie", +}; diff --git a/src/admin/pages/AuditLog.tsx b/src/admin/pages/AuditLog.tsx index 6dd7343..3cfb160 100644 --- a/src/admin/pages/AuditLog.tsx +++ b/src/admin/pages/AuditLog.tsx @@ -11,6 +11,7 @@ import AdminDatePicker from "../components/AdminDatePicker"; import { czechPlural } from "../utils/formatters"; import apiFetch from "../utils/api"; import { useApiMutation } from "../lib/queries/mutations"; +import { ENTITY_TYPE_LABELS } from "../lib/entityTypeLabels"; const API_BASE = "/api/admin"; @@ -44,27 +45,6 @@ const ACTION_BADGE_CLASS: Record = { access_denied: "admin-badge-danger", }; -const ENTITY_TYPE_LABELS: Record = { - user: "Uživatel", - attendance: "Docházka", - leave_request: "Žádost o nepřítomnost", - offers_quotation: "Nabídka", - offers_customer: "Zákazník", - offers_item_template: "Šablona položky", - offers_scope_template: "Šablona rozsahu", - offers_settings: "Nastavení nabídek", - orders_order: "Objednávka", - invoices_invoice: "Faktura", - projects_project: "Projekt", - role: "Role", - trips: "Jízda", - vehicles: "Vozidlo", - bank_account: "Bankovní účet", - work_plan_entry: "Plán prací – záznam", - work_plan_override: "Plán prací – přepsání dne", - plan_category: "Plán prací – kategorie", -}; - const ACTION_OPTIONS = Object.entries(ACTION_LABELS).map(([value, label]) => ({ value, label, diff --git a/src/admin/utils/dashboardHelpers.ts b/src/admin/utils/dashboardHelpers.ts index 2800753..f544019 100644 --- a/src/admin/utils/dashboardHelpers.ts +++ b/src/admin/utils/dashboardHelpers.ts @@ -18,26 +18,9 @@ export const STATUS_LABELS: Record = { leave: "Nepřítomen", }; -export const ENTITY_TYPE_LABELS: Record = { - user: "Uživatel", - attendance: "Docházka", - leave_request: "Žádost o nepřítomnost", - offers_quotation: "Nabídka", - offers_customer: "Zákazník", - offers_item_template: "Šablona položky", - offers_scope_template: "Šablona rozsahu", - offers_settings: "Nastavení nabídek", - orders_order: "Objednávka", - invoices_invoice: "Faktura", - projects_project: "Projekt", - role: "Role", - trips: "Jízda", - vehicles: "Vozidlo", - bank_account: "Bankovní účet", - work_plan_entry: "Plán prací – záznam", - work_plan_override: "Plán prací – přepsání dne", - plan_category: "Plán prací – kategorie", -}; +// Re-exported from the single source of truth so the dashboard activity feed +// and the Audit Log page can't drift apart. See ../lib/entityTypeLabels. +export { ENTITY_TYPE_LABELS } from "../lib/entityTypeLabels"; export const ACTION_LABELS: Record = { create: "Vytvořil",