abhishek-akbari01 commited on
Commit
759c7c3
·
1 Parent(s): 02a3dcb

pagination change

Browse files
src/controllers/invoice/invoice.controller.ts CHANGED
@@ -366,10 +366,16 @@ export const getAllInvoices = async (req: AuthenticatedRequest, res: Response):
366
 
367
  const totalInvoices = invoices.length;
368
 
369
- const paginatedInvoices = invoices.slice((currentPage - 1) * pageSize, currentPage * pageSize);
 
 
 
 
 
 
370
 
371
  const responseData = {
372
- page: currentPage,
373
  limit: pageSize,
374
  total: totalInvoices,
375
  data: paginatedInvoices
 
366
 
367
  const totalInvoices = invoices.length;
368
 
369
+ let paginatedInvoices;
370
+
371
+ if (currentPage === -1) {
372
+ paginatedInvoices = invoices;
373
+ } else {
374
+ paginatedInvoices = invoices.slice((currentPage - 1) * pageSize, currentPage * pageSize);
375
+ }
376
 
377
  const responseData = {
378
+ page: currentPage === -1 ? 1 : currentPage,
379
  limit: pageSize,
380
  total: totalInvoices,
381
  data: paginatedInvoices