@react-pakistan/util-functions 1.24.94 → 1.24.95
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.
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { ProductBE } from '../type';
|
|
2
2
|
type PrismaClient = any;
|
|
3
3
|
export interface ListProductArgs {
|
|
4
|
+
buyPriceMax?: string;
|
|
5
|
+
buyPriceMin?: string;
|
|
4
6
|
currentPage?: number;
|
|
5
7
|
includeProductCategory?: boolean;
|
|
6
8
|
includeQuotesInvoices?: boolean;
|
|
@@ -8,6 +10,9 @@ export interface ListProductArgs {
|
|
|
8
10
|
orderByDirection?: 'asc' | 'desc';
|
|
9
11
|
pageLimit?: number;
|
|
10
12
|
prisma: PrismaClient;
|
|
13
|
+
productCategoryId?: string;
|
|
14
|
+
salePriceMax?: string;
|
|
15
|
+
salePriceMin?: string;
|
|
11
16
|
searchQuery?: string;
|
|
12
17
|
}
|
|
13
18
|
export interface UnitProductByIdArgs {
|
|
@@ -39,7 +44,7 @@ export interface DeleteProductArgs {
|
|
|
39
44
|
* @param {ListProductArgs} args - Object containing prisma client, pagination, filtering, and ordering options
|
|
40
45
|
* @returns {Promise<[number, Array<ProductBE>]>} Tuple containing total count and array of products
|
|
41
46
|
*/
|
|
42
|
-
export declare const listProduct: ({ currentPage, includeProductCategory, includeQuotesInvoices, orderByColumn, orderByDirection, pageLimit, prisma, searchQuery, }: ListProductArgs) => Promise<[number, Array<ProductBE>]>;
|
|
47
|
+
export declare const listProduct: ({ buyPriceMax, buyPriceMin, currentPage, includeProductCategory, includeQuotesInvoices, orderByColumn, orderByDirection, pageLimit, prisma, salePriceMax, salePriceMin, searchQuery, }: ListProductArgs) => Promise<[number, Array<ProductBE>]>;
|
|
43
48
|
/**
|
|
44
49
|
* Retrieves a single product by its ID
|
|
45
50
|
* @param {UnitProductByIdArgs} args - Object containing prisma client, product ID, and optional query parameters
|
|
@@ -66,9 +66,9 @@ var multi_part_search_1 = require("../../../general/multi-part-search");
|
|
|
66
66
|
var listProduct = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
|
|
67
67
|
var include, orderBy, idSearchQuery, nameSearchQuery, refSearchQuery, where, _c, count, items;
|
|
68
68
|
var _d;
|
|
69
|
-
var _e = _b.
|
|
70
|
-
return __generator(this, function (
|
|
71
|
-
switch (
|
|
69
|
+
var _e = _b.buyPriceMax, buyPriceMax = _e === void 0 ? '' : _e, _f = _b.buyPriceMin, buyPriceMin = _f === void 0 ? '' : _f, _g = _b.currentPage, currentPage = _g === void 0 ? 1 : _g, _h = _b.includeProductCategory, includeProductCategory = _h === void 0 ? false : _h, _j = _b.includeQuotesInvoices, includeQuotesInvoices = _j === void 0 ? false : _j, _k = _b.orderByColumn, orderByColumn = _k === void 0 ? 'createdAt' : _k, _l = _b.orderByDirection, orderByDirection = _l === void 0 ? 'desc' : _l, _m = _b.pageLimit, pageLimit = _m === void 0 ? 5 : _m, prisma = _b.prisma, _o = _b.salePriceMax, salePriceMax = _o === void 0 ? '' : _o, _p = _b.salePriceMin, salePriceMin = _p === void 0 ? '' : _p, _q = _b.searchQuery, searchQuery = _q === void 0 ? '' : _q;
|
|
70
|
+
return __generator(this, function (_r) {
|
|
71
|
+
switch (_r.label) {
|
|
72
72
|
case 0:
|
|
73
73
|
if (!currentPage || currentPage < 1) {
|
|
74
74
|
throw new Error('Valid current page is required');
|
|
@@ -96,7 +96,20 @@ var listProduct = function (_a) { return __awaiter(void 0, [_a], void 0, functio
|
|
|
96
96
|
fullText: searchQuery,
|
|
97
97
|
});
|
|
98
98
|
where = {
|
|
99
|
-
OR: __spreadArray(__spreadArray(__spreadArray([], idSearchQuery, true), nameSearchQuery, true), refSearchQuery, true),
|
|
99
|
+
OR: __spreadArray(__spreadArray(__spreadArray(__spreadArray([], idSearchQuery, true), nameSearchQuery, true), refSearchQuery, true), [
|
|
100
|
+
{
|
|
101
|
+
buyPrice: {
|
|
102
|
+
lte: buyPriceMin ? buyPriceMin : undefined,
|
|
103
|
+
gte: buyPriceMax ? buyPriceMax : undefined,
|
|
104
|
+
},
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
salePrice: {
|
|
108
|
+
lte: salePriceMin ? salePriceMin : undefined,
|
|
109
|
+
gte: salePriceMax ? salePriceMax : undefined,
|
|
110
|
+
},
|
|
111
|
+
},
|
|
112
|
+
], false),
|
|
100
113
|
};
|
|
101
114
|
return [4 /*yield*/, prisma.$transaction([
|
|
102
115
|
prisma.product.count({
|
|
@@ -111,7 +124,7 @@ var listProduct = function (_a) { return __awaiter(void 0, [_a], void 0, functio
|
|
|
111
124
|
}),
|
|
112
125
|
])];
|
|
113
126
|
case 1:
|
|
114
|
-
_c =
|
|
127
|
+
_c = _r.sent(), count = _c[0], items = _c[1];
|
|
115
128
|
return [2 /*return*/, [count, items]];
|
|
116
129
|
}
|
|
117
130
|
});
|