Add team reports.

This commit is contained in:
Brian Cao 2023-08-17 16:39:59 -07:00
parent f35a9f0950
commit 69389ebcd5
3 changed files with 7 additions and 6 deletions

View File

@ -37,6 +37,7 @@ export default async (
page,
filter,
pageSize: +pageSize || null,
includeTeams: true,
});
return ok(res, data);

View File

@ -1,7 +1,7 @@
import { Prisma, Report } from '@prisma/client';
import { REPORT_FILTER_TYPES } from 'lib/constants';
import prisma from 'lib/prisma';
import { FilterResult, ReportSearchFilter, ReportSearchFilterType, SearchFilter } from 'lib/types';
import { FilterResult, ReportSearchFilter } from 'lib/types';
export async function createReport(data: Prisma.ReportUncheckedCreateInput): Promise<Report> {
return prisma.client.report.create({ data });
@ -155,7 +155,7 @@ export async function getReports(
export async function getReportsByUserId(
userId: string,
filter: SearchFilter<ReportSearchFilterType>,
filter: ReportSearchFilter,
): Promise<FilterResult<Report[]>> {
return getReports(
{ userId, ...filter },
@ -174,7 +174,7 @@ export async function getReportsByUserId(
export async function getReportsByWebsiteId(
websiteId: string,
filter: SearchFilter<ReportSearchFilterType>,
filter: ReportSearchFilter,
): Promise<FilterResult<Report[]>> {
return getReports({ websiteId, ...filter });
}

View File

@ -1,8 +1,8 @@
import { Prisma, Team } from '@prisma/client';
import prisma from 'lib/prisma';
import { ROLES, TEAM_FILTER_TYPES } from 'lib/constants';
import { uuid } from 'lib/crypto';
import { FilterResult, TeamSearchFilter, TeamSearchFilterType, SearchFilter } from 'lib/types';
import prisma from 'lib/prisma';
import { FilterResult, TeamSearchFilter } from 'lib/types';
export interface GetTeamOptions {
includeTeamUser?: boolean;
@ -142,7 +142,7 @@ export async function getTeams(
export async function getTeamsByUserId(
userId: string,
filter?: SearchFilter<TeamSearchFilterType>,
filter?: TeamSearchFilter,
): Promise<FilterResult<Team[]>> {
return getTeams(
{ userId, ...filter },