Moved events components to events page. Updated map data loading.

This commit is contained in:
Mike Cao 2024-08-08 12:00:38 -07:00
parent c6b8114945
commit f135e4ffbb
8 changed files with 52 additions and 35 deletions

View file

@ -26,14 +26,17 @@ export default async (
await useAuth(req, res);
await useValidate(schema, req, res);
const { websiteId } = req.query;
const { websiteId, startAt, endAt } = req.query;
if (req.method === 'GET') {
if (!(await canViewWebsite(req.auth, websiteId))) {
return unauthorized(res);
}
const data = await getWebsiteEvents(websiteId, {}, req.query);
const startDate = new Date(+startAt);
const endDate = new Date(+endAt);
const data = await getWebsiteEvents(websiteId, { startDate, endDate }, req.query);
return ok(res, data);
}

View file

@ -30,14 +30,14 @@ export default async (
const { websiteId, startAt, endAt } = req.query;
const startDate = new Date(+startAt);
const endDate = new Date(+endAt);
if (req.method === 'GET') {
if (!(await canViewWebsite(req.auth, websiteId))) {
return unauthorized(res);
}
const startDate = new Date(+startAt);
const endDate = new Date(+endAt);
const data = await getWebsiteSessions(websiteId, { startDate, endDate }, req.query);
return ok(res, data);