From e2e3d3ea6c7a233c967885495d98326e91e08489 Mon Sep 17 00:00:00 2001 From: "j.dev" Date: Tue, 12 Mar 2024 21:47:32 -0700 Subject: [PATCH] chore: check updated_at validity --- app/api/private-cloud/all-projects/route.ts | 2 +- app/api/public-cloud/all-projects/route.ts | 2 +- utils/date.ts | 2 ++ 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/app/api/private-cloud/all-projects/route.ts b/app/api/private-cloud/all-projects/route.ts index 799d6fc4a..3e997bff9 100644 --- a/app/api/private-cloud/all-projects/route.ts +++ b/app/api/private-cloud/all-projects/route.ts @@ -63,7 +63,7 @@ export async function GET(req: NextRequest) { secondaryTechnicalLeadEmail: project.secondaryTechnicalLead ? project.secondaryTechnicalLead.email : '', secondaryTechnicalLeadName: formatFullName(project.secondaryTechnicalLead), created: formatDate(project.created.$date), - updatedAt: formatDate(project.updatedAt.$date), + updatedAt: formatDate(project.updatedAt?.$date), licencePlate: project.licencePlate, status: project.status, })); diff --git a/app/api/public-cloud/all-projects/route.ts b/app/api/public-cloud/all-projects/route.ts index 66cd2a21a..366e1ec23 100644 --- a/app/api/public-cloud/all-projects/route.ts +++ b/app/api/public-cloud/all-projects/route.ts @@ -64,7 +64,7 @@ export async function GET(req: NextRequest) { secondaryTechnicalLeadEmail: project.secondaryTechnicalLead ? project.secondaryTechnicalLead.email : '', secondaryTechnicalLeadName: formatFullName(project.secondaryTechnicalLead), created: formatDate(project.created.$date), - updatedAt: formatDate(project.updatedAt.$date), + updatedAt: formatDate(project.updatedAt?.$date), licencePlate: project.licencePlate, status: project.status, })); diff --git a/utils/date.ts b/utils/date.ts index eb96c2193..edbb71931 100644 --- a/utils/date.ts +++ b/utils/date.ts @@ -1,4 +1,6 @@ const formatDate = (date: string) => { + if (!date) return ''; + const monthNames = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']; const d = new Date(date);