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
This commit is contained in:
Ilya Kreymer 2024-12-13 21:11:26 -08:00 committed by GitHub
parent cf60c43df2
commit 02c4381694
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 8 additions and 2 deletions

View File

@ -52,7 +52,7 @@ export type CrawlingDefaults = z.infer<typeof crawlingDefaultsSchema>;
export const orgDataSchema = z.object({ export const orgDataSchema = z.object({
id: z.string().uuid(), id: z.string().uuid(),
name: z.string(), name: z.string(),
created: apiDateSchema, created: apiDateSchema.nullable(),
slug: z.string(), slug: z.string(),
default: z.boolean(), default: z.boolean(),
quotas: orgQuotasSchema, quotas: orgQuotasSchema,

View File

@ -201,7 +201,13 @@ export class Localize {
}; };
// Custom date formatter that takes missing `Z` into account // 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 date = new Date(d instanceof Date || d.endsWith("Z") ? d : `${d}Z`);
const formatter = dateFormatter( const formatter = dateFormatter(