feat(web): render objects 'Updated' as a tz-aware timestamp via formatTimestamp (#42)
This commit is contained in:
@@ -8,6 +8,7 @@ import { useObjectsPage } from "../api/queries";
|
||||
import { useDebouncedValue } from "../lib/use-debounced-value";
|
||||
import { focusRing } from "../lib/focus-ring";
|
||||
import { segmentClass, rowStateClass } from "../lib/class-recipes";
|
||||
import { formatTimestamp } from "../lib/format-timestamp";
|
||||
import { useConfig } from "../config/config-context";
|
||||
import { VisibilityBadge } from "./visibility-badge";
|
||||
import { Button, buttonVariants } from "@/components/ui/button";
|
||||
@@ -120,16 +121,6 @@ export function ObjectsTable() {
|
||||
else next.set("offset", String(value));
|
||||
});
|
||||
|
||||
const dateFmt = new Intl.DateTimeFormat(i18n.language, {
|
||||
dateStyle: "medium",
|
||||
timeZone: default_timezone,
|
||||
});
|
||||
const formatUpdated = (iso: string) => {
|
||||
const parsed = new Date(iso);
|
||||
|
||||
return Number.isNaN(parsed.getTime()) ? iso : dateFmt.format(parsed);
|
||||
};
|
||||
|
||||
const headerCell = (col: SortColumn) => {
|
||||
const active = sort === col;
|
||||
const ariaSort = active ? (order === "asc" ? "ascending" : "descending") : "none";
|
||||
@@ -267,7 +258,9 @@ export function ObjectsTable() {
|
||||
</td>
|
||||
<td className="px-3 py-2 text-muted-foreground">{object.current_location ?? "—"}</td>
|
||||
<td className="px-3 py-2 text-right tabular-nums">{object.number_of_objects}</td>
|
||||
<td className="px-3 py-2 text-muted-foreground">{formatUpdated(object.updated_at)}</td>
|
||||
<td className="px-3 py-2 text-muted-foreground">
|
||||
{formatTimestamp(object.updated_at, default_timezone, i18n.language)}
|
||||
</td>
|
||||
</tr>
|
||||
);
|
||||
})}
|
||||
|
||||
Reference in New Issue
Block a user