This commit is contained in:
David Nguyen
2025-02-05 00:57:00 +11:00
parent 540cc5bfc1
commit 1057ae6d2a
105 changed files with 379 additions and 357 deletions

View File

@ -40,7 +40,7 @@ export const findDocuments = async ({
orderBy,
period,
senderIds,
query,
query = '',
}: FindDocumentsOptions) => {
const user = await prisma.user.findFirstOrThrow({
where: {
@ -226,6 +226,8 @@ export const findDocuments = async ({
};
}
console.log(JSON.stringify(whereClause, null, 2));
const [data, count] = await Promise.all([
prisma.document.findMany({
where: whereClause,

View File

@ -17,7 +17,7 @@ export type GetStatsInput = {
search?: string;
};
export const getStats = async ({ user, period, search, ...options }: GetStatsInput) => {
export const getStats = async ({ user, period, search = '', ...options }: GetStatsInput) => {
let createdAt: Prisma.DocumentWhereInput['createdAt'];
if (period) {

View File

@ -172,18 +172,33 @@ export const documentRouter = router({
};
}
console.log({
userId: user.id,
teamId,
query,
templateId,
page,
perPage,
source,
status,
period,
senderIds,
orderBy: orderByColumn ? { column: orderByColumn, direction: orderByDirection } : undefined,
});
const [stats, documents] = await Promise.all([
getStats(getStatOptions),
findDocuments({
userId: user.id,
teamId,
templateId,
query,
source,
status,
templateId,
page,
perPage,
source,
status,
period,
senderIds,
orderBy: orderByColumn
? { column: orderByColumn, direction: orderByDirection }
: undefined,

View File

@ -1,5 +1,3 @@
'use client';
import * as React from 'react';
import * as SwitchPrimitives from '@radix-ui/react-switch';