@react-pakistan/util-functions 1.24.57 → 1.24.58
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.
|
@@ -42,6 +42,6 @@ interface DeleteProductArgs {
|
|
|
42
42
|
export declare const getProducts: ({ prisma, }: GetProductsArgs) => Promise<Array<ProductBE>>;
|
|
43
43
|
export declare const getProductById: ({ prisma, id, }: GetProductByIdArgs) => Promise<ProductBE>;
|
|
44
44
|
export declare const postProducts: ({ currentPage, include, orderBy, pageLimit, prisma, queryWhere, }: PostProductsArgs) => Promise<Array<ProductBE>>;
|
|
45
|
-
export declare const postProduct: ({
|
|
45
|
+
export declare const postProduct: ({ authorName, buyPrice, currency, description, id, image, isbn, name, prisma, productCategoryId, quantity, ref, salePrice, }: PostProductArgs) => Promise<Array<ProductBE> | Error>;
|
|
46
46
|
export declare const deleteProduct: ({ prisma, id, }: DeleteProductArgs) => Promise<ProductBE>;
|
|
47
47
|
export {};
|
|
@@ -105,44 +105,53 @@ var postProducts = function (_a) { return __awaiter(void 0, [_a], void 0, functi
|
|
|
105
105
|
}); };
|
|
106
106
|
exports.postProducts = postProducts;
|
|
107
107
|
var postProduct = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
|
|
108
|
-
var product;
|
|
109
|
-
var
|
|
108
|
+
var product, error_1;
|
|
109
|
+
var authorName = _b.authorName, buyPrice = _b.buyPrice, currency = _b.currency, description = _b.description, id = _b.id, image = _b.image, isbn = _b.isbn, name = _b.name, prisma = _b.prisma, productCategoryId = _b.productCategoryId, quantity = _b.quantity, ref = _b.ref, salePrice = _b.salePrice;
|
|
110
110
|
return __generator(this, function (_c) {
|
|
111
111
|
switch (_c.label) {
|
|
112
|
-
case 0:
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
},
|
|
116
|
-
update: {
|
|
117
|
-
authorName: authorName,
|
|
118
|
-
buyPrice: buyPrice,
|
|
119
|
-
currency: currency,
|
|
120
|
-
description: description,
|
|
121
|
-
image: image,
|
|
122
|
-
isbn: isbn,
|
|
123
|
-
name: name,
|
|
124
|
-
productCategoryId: productCategoryId,
|
|
125
|
-
quantity: quantity,
|
|
126
|
-
ref: ref,
|
|
127
|
-
salePrice: salePrice,
|
|
128
|
-
},
|
|
129
|
-
create: {
|
|
130
|
-
authorName: authorName,
|
|
131
|
-
buyPrice: buyPrice,
|
|
132
|
-
currency: currency,
|
|
133
|
-
description: description,
|
|
134
|
-
image: image,
|
|
135
|
-
isbn: isbn,
|
|
136
|
-
name: name,
|
|
137
|
-
productCategoryId: productCategoryId,
|
|
138
|
-
quantity: quantity,
|
|
139
|
-
ref: ref,
|
|
140
|
-
salePrice: salePrice,
|
|
141
|
-
},
|
|
142
|
-
})];
|
|
112
|
+
case 0:
|
|
113
|
+
product = [];
|
|
114
|
+
_c.label = 1;
|
|
143
115
|
case 1:
|
|
116
|
+
_c.trys.push([1, 3, , 4]);
|
|
117
|
+
return [4 /*yield*/, prisma.product.upsert({
|
|
118
|
+
where: {
|
|
119
|
+
id: id,
|
|
120
|
+
},
|
|
121
|
+
update: {
|
|
122
|
+
authorName: authorName,
|
|
123
|
+
buyPrice: buyPrice,
|
|
124
|
+
currency: currency,
|
|
125
|
+
description: description,
|
|
126
|
+
image: image,
|
|
127
|
+
isbn: isbn,
|
|
128
|
+
name: name,
|
|
129
|
+
productCategoryId: productCategoryId,
|
|
130
|
+
quantity: quantity,
|
|
131
|
+
ref: ref,
|
|
132
|
+
salePrice: salePrice,
|
|
133
|
+
},
|
|
134
|
+
create: {
|
|
135
|
+
authorName: authorName,
|
|
136
|
+
buyPrice: buyPrice,
|
|
137
|
+
currency: currency,
|
|
138
|
+
description: description,
|
|
139
|
+
image: image,
|
|
140
|
+
isbn: isbn,
|
|
141
|
+
name: name,
|
|
142
|
+
productCategoryId: productCategoryId,
|
|
143
|
+
quantity: quantity,
|
|
144
|
+
ref: ref,
|
|
145
|
+
salePrice: salePrice,
|
|
146
|
+
},
|
|
147
|
+
})];
|
|
148
|
+
case 2:
|
|
144
149
|
product = _c.sent();
|
|
145
|
-
return [
|
|
150
|
+
return [3 /*break*/, 4];
|
|
151
|
+
case 3:
|
|
152
|
+
error_1 = _c.sent();
|
|
153
|
+
return [2 /*return*/, error_1];
|
|
154
|
+
case 4: return [2 /*return*/, product];
|
|
146
155
|
}
|
|
147
156
|
});
|
|
148
157
|
}); };
|