fix retention report invalid date

This commit is contained in:
Francis Cao 2024-08-02 00:14:32 -07:00
parent 2c18cca3cd
commit 7582670aef
2 changed files with 6 additions and 4 deletions

View File

@ -52,7 +52,7 @@ export function RetentionTable({ days = DAYS }) {
{rows.map(({ date, visitors, records }, rowIndex) => { {rows.map(({ date, visitors, records }, rowIndex) => {
return ( return (
<div key={rowIndex} className={styles.row}> <div key={rowIndex} className={styles.row}>
<div className={styles.date}>{formatDate(`${date} 00:00:00`, 'PP', locale)}</div> <div className={styles.date}>{formatDate(date, 'PP', locale)}</div>
<div className={styles.visitors}>{visitors}</div> <div className={styles.visitors}>{visitors}</div>
{days.map(day => { {days.map(day => {
if (totalDays - rowIndex < day) { if (totalDays - rowIndex < day) {

View File

@ -9,7 +9,8 @@ import * as yup from 'yup';
export interface RetentionRequestBody { export interface RetentionRequestBody {
websiteId: string; websiteId: string;
dateRange: { startDate: string; endDate: string; timezone: string }; dateRange: { startDate: string; endDate: string };
timezone: string;
} }
const schema = { const schema = {
@ -20,9 +21,9 @@ const schema = {
.shape({ .shape({
startDate: yup.date().required(), startDate: yup.date().required(),
endDate: yup.date().required(), endDate: yup.date().required(),
timezone: TimezoneTest,
}) })
.required(), .required(),
timezone: TimezoneTest,
}), }),
}; };
@ -37,7 +38,8 @@ export default async (
if (req.method === 'POST') { if (req.method === 'POST') {
const { const {
websiteId, websiteId,
dateRange: { startDate, endDate, timezone }, dateRange: { startDate, endDate },
timezone,
} = req.body; } = req.body;
if (!(await canViewWebsite(req.auth, websiteId))) { if (!(await canViewWebsite(req.auth, websiteId))) {