@react-pakistan/util-functions 1.24.56 → 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: ({ prisma, id, authorName, buyPrice, currency, description, image, isbn, name, productCategoryId, quantity, ref, salePrice, }: PostProductArgs) => Promise<Array<ProductBE>>;
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 prisma = _b.prisma, id = _b.id, authorName = _b.authorName, buyPrice = _b.buyPrice, currency = _b.currency, description = _b.description, image = _b.image, isbn = _b.isbn, name = _b.name, productCategoryId = _b.productCategoryId, quantity = _b.quantity, ref = _b.ref, salePrice = _b.salePrice;
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: return [4 /*yield*/, prisma.product.upsert({
113
- where: {
114
- id: id,
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 [2 /*return*/, product];
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
  }); };
@@ -11,11 +11,9 @@
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.urlToSentenceCase = void 0;
13
13
  var urlToSentenceCase = function (url) {
14
- var chunks = url.split('/');
14
+ var _a, _b;
15
+ var chunks = url === null || url === void 0 ? void 0 : url.split('/');
15
16
  var pageName = chunks[chunks.length - 1];
16
- return pageName
17
- .split('-')
18
- .map(function (_str) { return _str.charAt(0).toUpperCase() + _str.slice(1); })
19
- .join(' ');
17
+ return (_b = (_a = pageName === null || pageName === void 0 ? void 0 : pageName.split('-')) === null || _a === void 0 ? void 0 : _a.map(function (_str) { return _str.charAt(0).toUpperCase() + _str.slice(1); })) === null || _b === void 0 ? void 0 : _b.join(' ');
20
18
  };
21
19
  exports.urlToSentenceCase = urlToSentenceCase;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-pakistan/util-functions",
3
- "version": "1.24.56",
3
+ "version": "1.24.58",
4
4
  "description": "A library of all util functions",
5
5
  "main": "index.js",
6
6
  "scripts": {