Merge remote-tracking branch 'origin/dev' into dev

# Conflicts:
#	src/components/common/Pager.module.css
#	src/lib/constants.ts
#	src/lib/yup.ts
#	src/pages/api/teams/[id]/users/index.ts
#	src/pages/api/websites/[id]/reports.ts
This commit is contained in:
Mike Cao 2023-09-26 23:27:55 -07:00
commit 40cfcd41e9
19 changed files with 135 additions and 92 deletions

View file

@ -1,6 +1,7 @@
import { canViewWebsite } from 'lib/auth';
import { useAuth, useCors, useValidate } from 'lib/middleware';
import { NextApiRequestQueryBody } from 'lib/types';
import { TimezoneTest } from 'lib/yup';
import { NextApiResponse } from 'next';
import { methodNotAllowed, ok, unauthorized } from 'next-basics';
import { getRetention } from 'queries';
@ -8,7 +9,7 @@ import * as yup from 'yup';
export interface RetentionRequestBody {
websiteId: string;
dateRange: { startDate: string; endDate: string };
dateRange: { startDate: string; endDate: string; timezone: string };
}
const schema = {
@ -19,6 +20,7 @@ const schema = {
.shape({
startDate: yup.date().required(),
endDate: yup.date().required(),
timezone: TimezoneTest,
})
.required(),
}),
@ -37,7 +39,7 @@ export default async (
if (req.method === 'POST') {
const {
websiteId,
dateRange: { startDate, endDate },
dateRange: { startDate, endDate, timezone },
} = req.body;
if (!(await canViewWebsite(req.auth, websiteId))) {
@ -47,6 +49,7 @@ export default async (
const data = await getRetention(websiteId, {
startDate: new Date(startDate),
endDate: new Date(endDate),
timezone,
});
return ok(res, data);