fix: paginate import history and report
This commit is contained in:
@@ -3,6 +3,7 @@ import { COOKIE_NAME } from "@shared/const";
|
||||
import { BAP_MIN_QUALITY_SCORE, meetsBapQualityThreshold } from "@shared/bapEligibility";
|
||||
import { requiresBapBeforeOriginalPdfExport } from "@shared/bapExportGuard";
|
||||
import { calculateInvoiceQualityScore, withCalculatedInvoiceQuality } from "@shared/invoiceQuality";
|
||||
import { normalizeImportLogPagination } from "@shared/importLogPagination";
|
||||
import { webPortalUrlSchema } from "./webPortalUrl";
|
||||
|
||||
interface Condition {
|
||||
@@ -1727,12 +1728,15 @@ export const appRouter = router({
|
||||
|
||||
// ============= IMPORT LOGS ROUTES =============
|
||||
importLogs: router({
|
||||
getByUser: protectedProcedure.query(async ({ ctx }) => {
|
||||
getByUser: protectedProcedure
|
||||
.input(z.object({ limit: z.number().int().positive().optional(), offset: z.number().int().min(0).optional() }).optional())
|
||||
.query(async ({ ctx, input }) => {
|
||||
const pagination = normalizeImportLogPagination(input);
|
||||
// Les admins voient tous les logs d'import
|
||||
if (ctx.user.role === 'admin') {
|
||||
return getAllImportLogsWithDetails();
|
||||
return getAllImportLogsWithDetails(pagination);
|
||||
}
|
||||
return getImportLogsWithDetailsByUser(ctx.user.id);
|
||||
return getImportLogsWithDetailsByUser(ctx.user.id, pagination);
|
||||
}),
|
||||
|
||||
deleteAll: protectedProcedure.mutation(async ({ ctx }) => {
|
||||
|
||||
Reference in New Issue
Block a user