03d5b59b48
Refactor object-detail.tsx to resolve term/authority ids to labels via FlexibleFieldValue, group flexible fields by def.group in definition order (ungrouped → trailing "Other"), always show core fields with "—" placeholders, and move Edit (button-styled Link) + Delete into a right-aligned toolbar. Move formatDate into lib/format-date.ts so the component module no longer co-exports a non-component (clears the react-refresh/only-export-components warning); both flexible-field-value.tsx and object-detail.tsx import it. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
9 lines
484 B
TypeScript
9 lines
484 B
TypeScript
/** Formats a date-only ISO string (YYYY-MM-DD) for display in the active locale.
|
|
* Parses as local midnight so a date-only value isn't shifted a day by tz. */
|
|
export function formatDate(value: unknown, lang: string): string {
|
|
if (typeof value !== "string") return value == null ? "—" : String(value);
|
|
const date = new Date(`${value}T00:00:00`);
|
|
if (Number.isNaN(date.getTime())) return value;
|
|
return new Intl.DateTimeFormat(lang, { dateStyle: "medium" }).format(date);
|
|
}
|