From 02c438169487322340d853e0e64dcf705251f8c4 Mon Sep 17 00:00:00 2001 From: Ilya Kreymer Date: Fri, 13 Dec 2024 21:11:26 -0800 Subject: [PATCH] fix rendering org list if org.created is null: (#2243) - org.created may be null (for backwards compatibility before it was set) - fix frontend type to match backend - update format.date() to accept null, return empty string --- frontend/src/types/org.ts | 2 +- frontend/src/utils/localize.ts | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/frontend/src/types/org.ts b/frontend/src/types/org.ts index 44e134e8..e6759ba4 100644 --- a/frontend/src/types/org.ts +++ b/frontend/src/types/org.ts @@ -52,7 +52,7 @@ export type CrawlingDefaults = z.infer; export const orgDataSchema = z.object({ id: z.string().uuid(), name: z.string(), - created: apiDateSchema, + created: apiDateSchema.nullable(), slug: z.string(), default: z.boolean(), quotas: orgQuotasSchema, diff --git a/frontend/src/utils/localize.ts b/frontend/src/utils/localize.ts index 00ccf9be..ae7347b7 100644 --- a/frontend/src/utils/localize.ts +++ b/frontend/src/utils/localize.ts @@ -201,7 +201,13 @@ export class Localize { }; // Custom date formatter that takes missing `Z` into account - readonly date = (d: Date | string, opts?: Intl.DateTimeFormatOptions) => { + readonly date = ( + d: Date | string | null, + opts?: Intl.DateTimeFormatOptions, + ) => { + if (!d) { + return ""; + } const date = new Date(d instanceof Date || d.endsWith("Z") ? d : `${d}Z`); const formatter = dateFormatter(