Fix: Localized Dates
This commit is contained in:
@@ -10,6 +10,7 @@ import { api, OrgComplianceMember, create403Handler } from "@/lib/api";
|
||||
import { useQuery, useMutation } from "@tanstack/react-query";
|
||||
import { useToast } from "@/hooks/use-toast";
|
||||
import { useOrg } from "@/contexts/OrgContext";
|
||||
import { formatDate } from "@/lib/date";
|
||||
|
||||
const STATUS_CONFIG: Record<string, { label: string; color: string; icon: typeof Clock }> = {
|
||||
compliant: {
|
||||
@@ -231,7 +232,7 @@ export default function CompliancePage() {
|
||||
{member.deadline_at && member.status !== 'compliant' && member.status !== 'not_applicable' && (
|
||||
<div className="text-sm text-muted-foreground">
|
||||
<span className="hidden md:inline">Deadline: </span>
|
||||
{new Date(member.deadline_at).toLocaleDateString()}
|
||||
{formatDate(member.deadline_at)}
|
||||
</div>
|
||||
)}
|
||||
|
||||
|
||||
@@ -84,11 +84,8 @@ const getInitials = (name: string | null | undefined): string => {
|
||||
|
||||
function formatDate(d: string | null | undefined) {
|
||||
if (!d) return "—";
|
||||
return new Date(d).toLocaleDateString(undefined, {
|
||||
year: "numeric",
|
||||
month: "short",
|
||||
day: "numeric",
|
||||
});
|
||||
const raw = typeof d === "string" && !(d.endsWith("Z") || /[+-]\d{2}:\d{2}$/.test(d)) ? d + "Z" : d;
|
||||
return new Intl.DateTimeFormat(undefined, { year: "numeric", month: "short", day: "numeric" }).format(new Date(raw));
|
||||
}
|
||||
|
||||
function capitalize(s: string) {
|
||||
|
||||
Reference in New Issue
Block a user