mirror of
https://github.com/Sea-Haven-Industries/shoc-frontend-new.git
synced 2026-09-30 06:53:12 +00:00
Format created date as YYYY-MM-DD HH:MM TZ on view page
- Parse timestamp as UTC, display in user's local timezone - 24-hour format with short timezone name (e.g. 2026-04-16 17:27 EDT)
This commit is contained in:
parent
9c2c8321de
commit
9bae91f281
2 changed files with 13 additions and 1 deletions
|
|
@ -23,6 +23,7 @@ export const getWorkOrderById = async (id) => {
|
|||
assignedTo: wo.assignee ?? wo.assignedTo ?? "",
|
||||
dueDate: wo.dueDate ? wo.dueDate.split("T")[0] : "",
|
||||
createdDate: wo.createdDate ? wo.createdDate.split("T")[0] : "",
|
||||
createdDateFull: wo.createdDate ?? "",
|
||||
description: wo.description ?? "",
|
||||
priority: wo.priority ?? "",
|
||||
status: wo.status ?? "Open",
|
||||
|
|
|
|||
|
|
@ -4,6 +4,15 @@ import { toast } from "react-toastify";
|
|||
import { getWorkOrderById } from "../api";
|
||||
import "./WorkOrderViewPage.css";
|
||||
|
||||
function formatDateTime(value) {
|
||||
const d = new Date(value.endsWith("Z") ? value : value + "Z");
|
||||
if (isNaN(d)) return value;
|
||||
const date = d.toLocaleDateString("en-CA");
|
||||
const time = d.toLocaleTimeString(undefined, { hour: "2-digit", minute: "2-digit", hour12: false });
|
||||
const tz = d.toLocaleTimeString(undefined, { timeZoneName: "short" }).split(" ").pop();
|
||||
return `${date} ${time} ${tz}`;
|
||||
}
|
||||
|
||||
export default function WorkOrderViewPage() {
|
||||
const { id } = useParams();
|
||||
const navigate = useNavigate();
|
||||
|
|
@ -79,7 +88,9 @@ export default function WorkOrderViewPage() {
|
|||
</div>
|
||||
<div className="woField">
|
||||
<span className="woFieldLabel">Created</span>
|
||||
<span className="woFieldValue">{wo.createdDate || "—"}</span>
|
||||
<span className="woFieldValue">
|
||||
{wo.createdDateFull ? formatDateTime(wo.createdDateFull) : "—"}
|
||||
</span>
|
||||
</div>
|
||||
<div className="woField">
|
||||
<span className="woFieldLabel">Due Date</span>
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue