From 95814350c9a655fc7ef95167066a99821850978e Mon Sep 17 00:00:00 2001 From: IT Dog Date: Mon, 20 Jul 2026 01:46:59 +0800 Subject: [PATCH] Accident display: fix aliases + submitted_at format MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Issues: 1. Frontend renders record[h] where h comes from column_order. column_order now uses submitter_email (not employee_name), so record[submitter_email] = None → shows as "-". 2. submitted_at shows as ISO format "2026-07-06T15:45:33.850000" (less readable than "2026-07-06 15:45:33"). Fix: 1. to_dict adds both submitter_email and employee_name alias (same value, r.submitter_email). Same for injured_person_id ↔ employee_id. Frontend column_order key matches record key (submitter_email shows email). 2. submitted_at formatted as "YYYY-MM-DD HH:MM:%S" via strftime Verified: - record.submitter_email = "operation@scmedical.hk" - record.employee_name = "operation@scmedical.hk" (alias) - record.submitted_at = "2026-07-06 15:45:33" --- backend/main.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/backend/main.py b/backend/main.py index d74bc06..915548f 100644 --- a/backend/main.py +++ b/backend/main.py @@ -2353,13 +2353,18 @@ async def accident_records( return { "id": r.id, - "submitted_at": r.submitted_at.isoformat() if r.submitted_at else None, + # Submitted time formatted as "YYYY-MM-DD HH:MM:SS" (display-friendly) + "submitted_at": r.submitted_at.strftime("%Y-%m-%d %H:%M:%S") if r.submitted_at else None, "date": r.date.isoformat() if r.date else None, "time": r.time, "incident_datetime": incident_dt, # YYYY-MM-DD HH:MM:SS combined "location": r.location, - "employee_name": r.submitter_email, - "employee_id": r.injured_person_id, + # Backend alias: frontend column_order uses submitter_email as key + # but legacy UI expected employee_name + "submitter_email": r.submitter_email, + "employee_name": r.submitter_email, # alias for backward compat + "injured_person_id": r.injured_person_id, + "employee_id": r.injured_person_id, # alias "department": r.department, "description": r.description, "severity": r.severity,