refactor: update assignment service methods for pagination support

This commit is contained in:
2025-11-12 16:59:39 +01:00
parent f668b6f006
commit 2d8d0e663e
2 changed files with 21 additions and 2 deletions
+1 -1
View File
@@ -18,7 +18,7 @@ export default async function AssignmentsPage(props: {
const currentPage = searchParams?.page ? parseInt(searchParams.page) : 1
const search = searchParams?.search || ""
const { data: assignments, totalPages } =
await AssignmentService.findAllWithRecipient({
await AssignmentService.findAllWithRecipientPaginated({
page: currentPage,
search,
})
+20 -1
View File
@@ -7,7 +7,26 @@ import { Assignment, AssignmentWithRecipientItemAsset } from "@/lib/types"
import { getAuthenticatedUserId } from "./auth.service"
export const AssignmentService = {
findAllWithRecipient: async ({
findAllWithRecipient: async (): Promise<
AssignmentWithRecipientItemAsset[]
> => {
return prisma.assignment.findMany({
where: {
returnDate: {
equals: null,
},
},
include: {
recipient: true,
item: true,
asset: true,
},
orderBy: {
createdAt: "desc",
},
})
},
findAllWithRecipientPaginated: async ({
page,
pageSize,
search,