Merge pull request #476 from gnarlex/event-type-selection

Dashboard: Dropdown for filtering events by their type
This commit is contained in:
Mike Cao 2021-02-16 19:05:19 -08:00 committed by GitHub
commit 3a0195ed50
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 138 additions and 9 deletions

View file

@ -0,0 +1,25 @@
import { getEventTypes } from 'lib/queries';
import { ok, methodNotAllowed, unauthorized } from 'lib/response';
import { allowQuery } from 'lib/auth';
export default async (req, res) => {
if (req.method === 'GET') {
if (!(await allowQuery(req))) {
return unauthorized(res);
}
const { id, start_at, end_at, url } = req.query;
const websiteId = +id;
const startDate = new Date(+start_at);
const endDate = new Date(+end_at);
const eventTypes = await getEventTypes(websiteId, startDate, endDate, undefined, undefined, {
url,
});
return ok(res, eventTypes);
}
return methodNotAllowed(res);
};