From 7582670aef1bcb9c5d170b82a2349ab6bc865945 Mon Sep 17 00:00:00 2001 From: Francis Cao Date: Fri, 2 Aug 2024 00:14:32 -0700 Subject: [PATCH] fix retention report invalid date --- src/app/(main)/reports/retention/RetentionTable.tsx | 2 +- src/pages/api/reports/retention.ts | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/app/(main)/reports/retention/RetentionTable.tsx b/src/app/(main)/reports/retention/RetentionTable.tsx index 171c5bd3..1770a764 100644 --- a/src/app/(main)/reports/retention/RetentionTable.tsx +++ b/src/app/(main)/reports/retention/RetentionTable.tsx @@ -52,7 +52,7 @@ export function RetentionTable({ days = DAYS }) { {rows.map(({ date, visitors, records }, rowIndex) => { return (
-
{formatDate(`${date} 00:00:00`, 'PP', locale)}
+
{formatDate(date, 'PP', locale)}
{visitors}
{days.map(day => { if (totalDays - rowIndex < day) { diff --git a/src/pages/api/reports/retention.ts b/src/pages/api/reports/retention.ts index 6ff7bbe1..f4d9b7df 100644 --- a/src/pages/api/reports/retention.ts +++ b/src/pages/api/reports/retention.ts @@ -9,7 +9,8 @@ import * as yup from 'yup'; export interface RetentionRequestBody { websiteId: string; - dateRange: { startDate: string; endDate: string; timezone: string }; + dateRange: { startDate: string; endDate: string }; + timezone: string; } const schema = { @@ -20,9 +21,9 @@ const schema = { .shape({ startDate: yup.date().required(), endDate: yup.date().required(), - timezone: TimezoneTest, }) .required(), + timezone: TimezoneTest, }), }; @@ -37,7 +38,8 @@ export default async ( if (req.method === 'POST') { const { websiteId, - dateRange: { startDate, endDate, timezone }, + dateRange: { startDate, endDate }, + timezone, } = req.body; if (!(await canViewWebsite(req.auth, websiteId))) {