fix(audit): correct + unify entity_type label map to match server values
Audit Log + dashboard feed used legacy keys (invoices_invoice, offers_quotation, trips, vehicles) that never matched the server's entity_type (invoice, quotation, trip, vehicle, ...) and omitted all warehouse_* entities, so many audit rows showed raw English. Single source of truth in lib/entityTypeLabels.ts, keyed to the actual EntityType values, with Czech labels for every type the server writes. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
39
src/admin/lib/entityTypeLabels.ts
Normal file
39
src/admin/lib/entityTypeLabels.ts
Normal file
@@ -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<string, string> = {
|
||||||
|
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",
|
||||||
|
};
|
||||||
@@ -11,6 +11,7 @@ import AdminDatePicker from "../components/AdminDatePicker";
|
|||||||
import { czechPlural } from "../utils/formatters";
|
import { czechPlural } from "../utils/formatters";
|
||||||
import apiFetch from "../utils/api";
|
import apiFetch from "../utils/api";
|
||||||
import { useApiMutation } from "../lib/queries/mutations";
|
import { useApiMutation } from "../lib/queries/mutations";
|
||||||
|
import { ENTITY_TYPE_LABELS } from "../lib/entityTypeLabels";
|
||||||
|
|
||||||
const API_BASE = "/api/admin";
|
const API_BASE = "/api/admin";
|
||||||
|
|
||||||
@@ -44,27 +45,6 @@ const ACTION_BADGE_CLASS: Record<string, string> = {
|
|||||||
access_denied: "admin-badge-danger",
|
access_denied: "admin-badge-danger",
|
||||||
};
|
};
|
||||||
|
|
||||||
const ENTITY_TYPE_LABELS: Record<string, string> = {
|
|
||||||
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]) => ({
|
const ACTION_OPTIONS = Object.entries(ACTION_LABELS).map(([value, label]) => ({
|
||||||
value,
|
value,
|
||||||
label,
|
label,
|
||||||
|
|||||||
@@ -18,26 +18,9 @@ export const STATUS_LABELS: Record<string, string> = {
|
|||||||
leave: "Nepřítomen",
|
leave: "Nepřítomen",
|
||||||
};
|
};
|
||||||
|
|
||||||
export const ENTITY_TYPE_LABELS: Record<string, string> = {
|
// Re-exported from the single source of truth so the dashboard activity feed
|
||||||
user: "Uživatel",
|
// and the Audit Log page can't drift apart. See ../lib/entityTypeLabels.
|
||||||
attendance: "Docházka",
|
export { ENTITY_TYPE_LABELS } from "../lib/entityTypeLabels";
|
||||||
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",
|
|
||||||
};
|
|
||||||
|
|
||||||
export const ACTION_LABELS: Record<string, string> = {
|
export const ACTION_LABELS: Record<string, string> = {
|
||||||
create: "Vytvořil",
|
create: "Vytvořil",
|
||||||
|
|||||||
Reference in New Issue
Block a user