More work on reports. Added Funnel page.

This commit is contained in:
Mike Cao 2025-06-05 22:19:35 -07:00
parent 5159dd470f
commit 3847e32f39
59 changed files with 1815 additions and 2370 deletions

View file

@ -1,15 +1,17 @@
import { z } from 'zod';
import { canViewWebsite } from '@/lib/auth';
import { getWebsiteReports } from '@/queries';
import { pagingParams } from '@/lib/schema';
import { getReports } from '@/queries';
import { filterParams, pagingParams } from '@/lib/schema';
import { parseRequest } from '@/lib/request';
import { unauthorized, json } from '@/lib/response';
export async function GET(
request: Request,
{ params }: { params: Promise<{ websiteId: string }> },
filters: { type: string },
) {
const schema = z.object({
...filterParams,
...pagingParams,
});
@ -26,11 +28,19 @@ export async function GET(
return unauthorized();
}
const data = await getWebsiteReports(websiteId, {
page: +page,
pageSize: +pageSize,
search,
});
const data = await getReports(
{
where: {
websiteId,
type: filters.type,
},
},
{
page,
pageSize,
search,
},
);
return json(data);
}