refactor: update assignment service methods for pagination support
This commit is contained in:
@@ -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,
|
||||
})
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user