@react-pakistan/util-functions 1.23.10 → 1.23.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -44,7 +44,7 @@ const postCompanies = (_c) => __awaiter(void 0, [_c], void 0, function* ({ prism
44
44
  },
45
45
  where: queryWhere,
46
46
  take: pageLimit,
47
- skip: currentPage === 1 ? 0 : currentPage - 1 * pageLimit,
47
+ skip: (currentPage - 1) * pageLimit,
48
48
  }),
49
49
  ]);
50
50
  return companies;
@@ -49,7 +49,7 @@ const postContacts = (_c) => __awaiter(void 0, [_c], void 0, function* ({ curren
49
49
  },
50
50
  where: queryWhere,
51
51
  take: pageLimit,
52
- skip: currentPage === 1 ? 0 : currentPage - 1 * pageLimit,
52
+ skip: (currentPage - 1) * pageLimit,
53
53
  }),
54
54
  ]);
55
55
  return contacts;
@@ -55,7 +55,7 @@ const postCustomers = (_d) => __awaiter(void 0, [_d], void 0, function* ({ curre
55
55
  },
56
56
  where: queryWhere,
57
57
  take: pageLimit,
58
- skip: currentPage === 1 ? 0 : currentPage - 1 * pageLimit,
58
+ skip: (currentPage - 1) * pageLimit,
59
59
  }),
60
60
  ]);
61
61
  return customers;
@@ -49,7 +49,7 @@ const postExpenses = (_c) => __awaiter(void 0, [_c], void 0, function* ({ curren
49
49
  },
50
50
  where: queryWhere,
51
51
  take: pageLimit,
52
- skip: currentPage === 1 ? 0 : currentPage - 1 * pageLimit,
52
+ skip: (currentPage - 1) * pageLimit,
53
53
  }),
54
54
  ]);
55
55
  return expenses;
@@ -52,7 +52,7 @@ const postExpenseCategories = (_c) => __awaiter(void 0, [_c], void 0, function*
52
52
  },
53
53
  where: queryWhere,
54
54
  take: pageLimit,
55
- skip: currentPage === 1 ? 0 : currentPage - 1 * pageLimit,
55
+ skip: (currentPage - 1) * pageLimit,
56
56
  }),
57
57
  ]);
58
58
  }
@@ -49,7 +49,7 @@ const postLeads = (_c) => __awaiter(void 0, [_c], void 0, function* ({ currentPa
49
49
  },
50
50
  where: queryWhere,
51
51
  take: pageLimit,
52
- skip: currentPage === 1 ? 0 : currentPage - 1 * pageLimit,
52
+ skip: (currentPage - 1) * pageLimit,
53
53
  }),
54
54
  ]);
55
55
  return leads;
@@ -43,7 +43,7 @@ const postPayments = (_c) => __awaiter(void 0, [_c], void 0, function* ({ curren
43
43
  },
44
44
  where: queryWhere,
45
45
  take: pageLimit,
46
- skip: currentPage === 1 ? 0 : currentPage - 1 * pageLimit,
46
+ skip: (currentPage - 1) * pageLimit,
47
47
  }),
48
48
  ]);
49
49
  return payments;
@@ -8,6 +8,12 @@ interface GetProductByIdArgs {
8
8
  }
9
9
  interface PostProductsArgs {
10
10
  currentPage: number;
11
+ include: {
12
+ [key: string]: any;
13
+ };
14
+ orderBy: {
15
+ [key: string]: any;
16
+ };
11
17
  pageLimit: number;
12
18
  prisma: any;
13
19
  queryWhere: {
@@ -35,7 +41,7 @@ interface DeleteProductArgs {
35
41
  }
36
42
  export declare const getProducts: ({ prisma, }: GetProductsArgs) => Promise<Array<ProductBE>>;
37
43
  export declare const getProductById: ({ prisma, id, }: GetProductByIdArgs) => Promise<ProductBE>;
38
- export declare const postProducts: ({ currentPage, pageLimit, prisma, queryWhere, }: PostProductsArgs) => Promise<Array<ProductBE>>;
44
+ export declare const postProducts: ({ currentPage, include, orderBy, pageLimit, prisma, queryWhere, }: PostProductsArgs) => Promise<Array<ProductBE>>;
39
45
  export declare const postProduct: ({ prisma, id, authorName, buyPrice, currency, description, image, isbn, name, productCategoryId, quantity, ref, salePrice, }: PostProductArgs) => Promise<Array<ProductBE>>;
40
46
  export declare const deleteProduct: ({ prisma, id, }: DeleteProductArgs) => Promise<ProductBE>;
41
47
  export {};
@@ -37,22 +37,17 @@ const getProductById = (_b) => __awaiter(void 0, [_b], void 0, function* ({ pris
37
37
  return product;
38
38
  });
39
39
  exports.getProductById = getProductById;
40
- const postProducts = (_c) => __awaiter(void 0, [_c], void 0, function* ({ currentPage, pageLimit, prisma, queryWhere, }) {
40
+ const postProducts = (_c) => __awaiter(void 0, [_c], void 0, function* ({ currentPage, include, orderBy, pageLimit, prisma, queryWhere, }) {
41
41
  const products = yield prisma.$transaction([
42
42
  prisma.product.count({
43
43
  where: queryWhere,
44
44
  }),
45
45
  prisma.product.findMany({
46
- orderBy: {
47
- createdAt: 'desc',
48
- },
49
- include: {
50
- productCategory: true,
51
- quotesInvoices: true,
52
- },
53
- where: queryWhere,
46
+ include,
47
+ orderBy,
48
+ skip: (currentPage - 1) * pageLimit,
54
49
  take: pageLimit,
55
- skip: currentPage === 1 ? 0 : currentPage - 1 * pageLimit,
50
+ where: queryWhere,
56
51
  }),
57
52
  ]);
58
53
  return products;
@@ -49,7 +49,7 @@ const postProfiles = (_d) => __awaiter(void 0, [_d], void 0, function* ({ curren
49
49
  },
50
50
  where: queryWhere,
51
51
  take: pageLimit,
52
- skip: currentPage === 1 ? 0 : currentPage - 1 * pageLimit,
52
+ skip: (currentPage - 1) * pageLimit,
53
53
  }),
54
54
  ]);
55
55
  return profiles;
@@ -61,7 +61,7 @@ const postQuotesInvoices = (_c) => __awaiter(void 0, [_c], void 0, function* ({
61
61
  },
62
62
  where: queryWhere,
63
63
  take: pageLimit,
64
- skip: currentPage === 1 ? 0 : currentPage - 1 * pageLimit,
64
+ skip: (currentPage - 1) * pageLimit,
65
65
  }),
66
66
  ]);
67
67
  return quotesInvoices;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-pakistan/util-functions",
3
- "version": "1.23.10",
3
+ "version": "1.23.12",
4
4
  "description": "A library of all util functions",
5
5
  "main": "index.js",
6
6
  "scripts": {