rerobe-js-orm 2.4.81 → 2.4.85

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.
@@ -4,7 +4,7 @@ const ProductFactory_1 = require("./ProductFactory");
4
4
  const Product_1 = require("../../models/Product");
5
5
  class ProductFromFormState extends ProductFactory_1.default {
6
6
  createProduct(props) {
7
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11;
7
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13;
8
8
  const productAttributes = {
9
9
  availableForSale: props.fields.availableForSale.selectedValue,
10
10
  description: props.fields.description.inputValue,
@@ -76,28 +76,31 @@ class ProductFromFormState extends ProductFactory_1.default {
76
76
  discountValue: props.fields.discountValue.inputValue || '',
77
77
  selectedForClearance: ((_r = props.props) === null || _r === void 0 ? void 0 : _r.selectedForClearance) || '',
78
78
  locationIds: props.fields.locationIds.selectedValues || [],
79
+ inventoryLocations: props.fields.inventoryLocations.selectedValues || [],
79
80
  };
80
81
  const timestampAttributes = {
81
- sellRequestReviewTimestamp: (_s = props.props) === null || _s === void 0 ? void 0 : _s.sellRequestReviewTimestamp,
82
- sellRequestReviewDraftTimestamp: (_t = props.props) === null || _t === void 0 ? void 0 : _t.sellRequestReviewDraftTimestamp,
83
- rejectedTimestamp: (_u = props.props) === null || _u === void 0 ? void 0 : _u.rejectedTimestamp,
84
- holdTimestamp: (_v = props.props) === null || _v === void 0 ? void 0 : _v.holdTimestamp,
85
- acceptedTimestamp: (_w = props.props) === null || _w === void 0 ? void 0 : _w.acceptedTimestamp,
86
- sellerToDropOffTimestamp: (_x = props.props) === null || _x === void 0 ? void 0 : _x.sellerToDropOffTimestamp,
87
- sellerToShipTimestamp: (_y = props.props) === null || _y === void 0 ? void 0 : _y.sellerToShipTimestamp,
88
- sellerToGetPickUpTimestamp: (_z = props.props) === null || _z === void 0 ? void 0 : _z.sellerToGetPickUpTimestamp,
89
- qualityControlTimestamp: (_0 = props.props) === null || _0 === void 0 ? void 0 : _0.qualityControlTimestamp,
90
- pendingPublicationTimestamp: (_1 = props.props) === null || _1 === void 0 ? void 0 : _1.pendingPublicationTimestamp,
91
- listedTimestamp: (_2 = props.props) === null || _2 === void 0 ? void 0 : _2.listedTimestamp,
92
- clearanceTimestamp: (_3 = props.props) === null || _3 === void 0 ? void 0 : _3.clearanceTimestamp,
93
- reservedTimestamp: (_4 = props.props) === null || _4 === void 0 ? void 0 : _4.reservedTimestamp,
94
- soldTimestamp: (_5 = props.props) === null || _5 === void 0 ? void 0 : _5.soldTimestamp,
95
- returnedTimestamp: (_6 = props.props) === null || _6 === void 0 ? void 0 : _6.returnedTimestamp,
96
- soldSellerToBePaidTimestamp: (_7 = props.props) === null || _7 === void 0 ? void 0 : _7.soldSellerToBePaidTimestamp,
97
- soldSellerPaidTimestamp: (_8 = props.props) === null || _8 === void 0 ? void 0 : _8.soldSellerPaidTimestamp,
98
- sellerSelfRejectTimestamp: (_9 = props.props) === null || _9 === void 0 ? void 0 : _9.sellerSelfRejectTimestamp,
99
- liquidationRequestedTimestamp: (_10 = props.props) === null || _10 === void 0 ? void 0 : _10.liquidationRequestedTimestamp,
100
- sellerLiquidatedTimestamp: (_11 = props.props) === null || _11 === void 0 ? void 0 : _11.sellerLiquidatedTimestamp,
82
+ createdAtTimestamp: (_s = props.props) === null || _s === void 0 ? void 0 : _s.createdAtTimestamp,
83
+ updatedAtTimestamp: (_t = props.props) === null || _t === void 0 ? void 0 : _t.updatedAtTimestamp,
84
+ sellRequestReviewTimestamp: (_u = props.props) === null || _u === void 0 ? void 0 : _u.sellRequestReviewTimestamp,
85
+ sellRequestReviewDraftTimestamp: (_v = props.props) === null || _v === void 0 ? void 0 : _v.sellRequestReviewDraftTimestamp,
86
+ rejectedTimestamp: (_w = props.props) === null || _w === void 0 ? void 0 : _w.rejectedTimestamp,
87
+ holdTimestamp: (_x = props.props) === null || _x === void 0 ? void 0 : _x.holdTimestamp,
88
+ acceptedTimestamp: (_y = props.props) === null || _y === void 0 ? void 0 : _y.acceptedTimestamp,
89
+ sellerToDropOffTimestamp: (_z = props.props) === null || _z === void 0 ? void 0 : _z.sellerToDropOffTimestamp,
90
+ sellerToShipTimestamp: (_0 = props.props) === null || _0 === void 0 ? void 0 : _0.sellerToShipTimestamp,
91
+ sellerToGetPickUpTimestamp: (_1 = props.props) === null || _1 === void 0 ? void 0 : _1.sellerToGetPickUpTimestamp,
92
+ qualityControlTimestamp: (_2 = props.props) === null || _2 === void 0 ? void 0 : _2.qualityControlTimestamp,
93
+ pendingPublicationTimestamp: (_3 = props.props) === null || _3 === void 0 ? void 0 : _3.pendingPublicationTimestamp,
94
+ listedTimestamp: (_4 = props.props) === null || _4 === void 0 ? void 0 : _4.listedTimestamp,
95
+ clearanceTimestamp: (_5 = props.props) === null || _5 === void 0 ? void 0 : _5.clearanceTimestamp,
96
+ reservedTimestamp: (_6 = props.props) === null || _6 === void 0 ? void 0 : _6.reservedTimestamp,
97
+ soldTimestamp: (_7 = props.props) === null || _7 === void 0 ? void 0 : _7.soldTimestamp,
98
+ returnedTimestamp: (_8 = props.props) === null || _8 === void 0 ? void 0 : _8.returnedTimestamp,
99
+ soldSellerToBePaidTimestamp: (_9 = props.props) === null || _9 === void 0 ? void 0 : _9.soldSellerToBePaidTimestamp,
100
+ soldSellerPaidTimestamp: (_10 = props.props) === null || _10 === void 0 ? void 0 : _10.soldSellerPaidTimestamp,
101
+ sellerSelfRejectTimestamp: (_11 = props.props) === null || _11 === void 0 ? void 0 : _11.sellerSelfRejectTimestamp,
102
+ liquidationRequestedTimestamp: (_12 = props.props) === null || _12 === void 0 ? void 0 : _12.liquidationRequestedTimestamp,
103
+ sellerLiquidatedTimestamp: (_13 = props.props) === null || _13 === void 0 ? void 0 : _13.sellerLiquidatedTimestamp,
101
104
  };
102
105
  return new Product_1.default(Object.assign(Object.assign(Object.assign(Object.assign({}, productAttributes), productFilterAttributes), consignmentAttributes), timestampAttributes));
103
106
  }
@@ -24,5 +24,6 @@ export default class ProductFormState extends FormState {
24
24
  private discountTypeChangeHandler;
25
25
  private discountValueChangeHandler;
26
26
  private calculateSalePrice;
27
+ private inventoryLocationsChangeHandler;
27
28
  private fieldFactory;
28
29
  }
@@ -71,6 +71,7 @@ class ProductFormState extends FormState_1.default {
71
71
  this.fields.vendorName = this.fieldFactory('singleSelect', 'vendorName');
72
72
  this.fields.rfidTag = this.fieldFactory('textInput', 'rfidTag');
73
73
  this.fields.locationIds = this.fieldFactory('multiSelect', 'locationIds');
74
+ this.fields.inventoryLocations = this.fieldFactory('multiSelect', 'inventoryLocations');
74
75
  this.fields.featuredCollections = this.fieldFactory('multiSelect', 'featuredCollections');
75
76
  this.fields.tags = this.fieldFactory('multiSelect', 'tags');
76
77
  }
@@ -413,6 +414,24 @@ class ProductFormState extends FormState_1.default {
413
414
  }
414
415
  return '';
415
416
  }
417
+ inventoryLocationsChangeHandler(val) {
418
+ const { id, incomingAmount, availableAmount } = val;
419
+ const existingIds = this.fields.inventoryLocations.selectedValues.map((i) => i.id);
420
+ if (existingIds.includes(id)) {
421
+ const foundInd = this.fields.inventoryLocations.selectedValues.findIndex((i) => i.id === id);
422
+ const foundI = this.fields.inventoryLocations.selectedValues[foundInd];
423
+ // Delete case: val is exact same object
424
+ if (incomingAmount === foundI.incomingAmount && availableAmount === foundI.availableAmount) {
425
+ this.fields.inventoryLocations.selectedValues.splice(foundInd, 1);
426
+ }
427
+ else {
428
+ this.fields.inventoryLocations.selectedValues.splice(foundInd, 1, val);
429
+ }
430
+ }
431
+ else {
432
+ this.multiSelectChangeHandler('inventoryLocations', val);
433
+ }
434
+ }
416
435
  fieldFactory(fieldType, fieldKey, fieldOptions) {
417
436
  let options = fieldOptions || [];
418
437
  let hidden = false;
@@ -499,6 +518,7 @@ class ProductFormState extends FormState_1.default {
499
518
  };
500
519
  }
501
520
  if (fieldType === 'multiSelect') {
521
+ let onChangeHandler = (val) => this.multiSelectChangeHandler(fieldKey, val);
502
522
  if (fieldKey === 'productStyle') {
503
523
  options = this.setProductStylesFromCategoryAndType(this.props.productCategory, this.props.productType);
504
524
  if (this.props.productStyle && this.props.productStyle.length > 0) {
@@ -608,12 +628,15 @@ class ProductFormState extends FormState_1.default {
608
628
  }
609
629
  hidden = this.props.productCategory !== 'Clothing' || this.props.productType === 'Jeans';
610
630
  }
631
+ if (fieldKey === 'inventoryLocations') {
632
+ onChangeHandler = (val) => this.inventoryLocationsChangeHandler(val);
633
+ }
611
634
  return {
612
635
  options,
613
636
  hidden,
614
637
  selectedValues: this.props[fieldKey] || [],
615
638
  valid: this.props[fieldKey].length > 0,
616
- onChangeHandler: (val) => this.multiSelectChangeHandler(fieldKey, val),
639
+ onChangeHandler,
617
640
  };
618
641
  }
619
642
  if (fieldType === 'textInput') {
@@ -16,6 +16,15 @@ class OrderHelpers {
16
16
  }
17
17
  getShippingTypeFromShopifyObj(shippingLines) {
18
18
  if (shippingLines && shippingLines[0]) {
19
+ if (shippingLines[0].title === 'Local pickup') {
20
+ return Order_1.default.SHIPPING_TYPES.localPickUp;
21
+ }
22
+ if (shippingLines[0].title === 'Shipping fee') {
23
+ return Order_1.default.SHIPPING_TYPES.shipping;
24
+ }
25
+ if (shippingLines[0].title === 'Localy delivery') {
26
+ return Order_1.default.SHIPPING_TYPES.localDelivery;
27
+ }
19
28
  return shippingLines[0].price_set.shop_money.amount > 0
20
29
  ? Order_1.default.SHIPPING_TYPES.localDelivery
21
30
  : Order_1.default.SHIPPING_TYPES.localPickUp;
@@ -226,7 +226,7 @@ class ReRobeProductHelpers {
226
226
  static createTimestampsForStates(productObj) {
227
227
  const docFieldsToUpdate = {};
228
228
  if (productObj) {
229
- const { dateSold, status, sellRequestReviewDraftTimestamp, sellRequestReviewTimestamp, rejectedTimestamp, holdTimestamp, acceptedTimestamp, sellerToDropOffTimestamp, sellerToShipTimestamp, sellerToGetPickUpTimestamp, qualityControlTimestamp, pendingPublicationTimestamp, listedTimestamp, clearanceTimestamp, reservedTimestamp, soldTimestamp, soldSellerToBePaidTimestamp, soldSellerPaidTimestamp, returnedTimestamp, sellerSelfRejectTimestamp, liquidationRequestedTimestamp, sellerLiquidatedTimestamp, } = productObj;
229
+ const { status, sellRequestReviewDraftTimestamp, sellRequestReviewTimestamp, rejectedTimestamp, holdTimestamp, acceptedTimestamp, sellerToDropOffTimestamp, sellerToShipTimestamp, sellerToGetPickUpTimestamp, qualityControlTimestamp, pendingPublicationTimestamp, listedTimestamp, clearanceTimestamp, reservedTimestamp, soldTimestamp, soldSellerToBePaidTimestamp, soldSellerPaidTimestamp, returnedTimestamp, sellerSelfRejectTimestamp, liquidationRequestedTimestamp, sellerLiquidatedTimestamp, } = productObj;
230
230
  if (status === ProductStateManager_1.default.PRODUCT_STATES.sellRequestReviewDraft && !sellRequestReviewDraftTimestamp) {
231
231
  docFieldsToUpdate.sellRequestReviewDraftTimestamp = new Date().getTime();
232
232
  }
@@ -273,8 +273,7 @@ class ReRobeProductHelpers {
273
273
  const timeNow = new Date().getTime();
274
274
  docFieldsToUpdate.soldSellerToBePaidTimestamp = timeNow;
275
275
  if (!soldTimestamp) {
276
- docFieldsToUpdate.soldTimestamp =
277
- dateSold && typeof dateSold === 'string' ? new Date(dateSold).getTime() : timeNow;
276
+ docFieldsToUpdate.soldTimestamp = timeNow;
278
277
  }
279
278
  }
280
279
  if (status === ProductStateManager_1.default.PRODUCT_STATES.soldSellerPaid && !soldSellerPaidTimestamp) {
@@ -284,8 +283,7 @@ class ReRobeProductHelpers {
284
283
  docFieldsToUpdate.soldSellerToBePaidTimestamp = timeNow;
285
284
  }
286
285
  if (!soldTimestamp) {
287
- docFieldsToUpdate.soldTimestamp =
288
- dateSold && typeof dateSold === 'string' ? new Date(dateSold).getTime() : timeNow;
286
+ docFieldsToUpdate.soldTimestamp = timeNow;
289
287
  }
290
288
  }
291
289
  if (status === ProductStateManager_1.default.PRODUCT_STATES.returned && !returnedTimestamp) {
@@ -178,7 +178,7 @@ Order.ORDER_STATES = {
178
178
  };
179
179
  Order.SALES_CHANNELS = {
180
180
  mobileApp: 'MOBILE_APP',
181
- webApp: 'WEB_APP',
181
+ webApp: 'DRAFT_ORDER',
182
182
  store: 'STORE',
183
183
  onlineStore: 'ONLINE_STORE',
184
184
  thirdParty: 'THIRD_PARTY',
@@ -80,8 +80,11 @@ class Product extends Base_1.default {
80
80
  discountValue: (props === null || props === void 0 ? void 0 : props.discountValue) || '',
81
81
  selectedForClearance: (props === null || props === void 0 ? void 0 : props.selectedForClearance) || '',
82
82
  locationIds: (props === null || props === void 0 ? void 0 : props.locationIds) || [],
83
+ inventoryLocations: (props === null || props === void 0 ? void 0 : props.inventoryLocations) || [],
83
84
  };
84
85
  this.timestampAttributes = {
86
+ createdAtTimestamp: (props === null || props === void 0 ? void 0 : props.createdAtTimestamp) ? Number(props === null || props === void 0 ? void 0 : props.createdAtTimestamp) : null,
87
+ updatedAtTimestamp: (props === null || props === void 0 ? void 0 : props.updatedAtTimestamp) ? Number(props === null || props === void 0 ? void 0 : props.updatedAtTimestamp) : null,
85
88
  sellRequestReviewDraftTimestamp: (props === null || props === void 0 ? void 0 : props.sellRequestReviewDraftTimestamp)
86
89
  ? Number(props === null || props === void 0 ? void 0 : props.sellRequestReviewDraftTimestamp)
87
90
  : null,
@@ -69,8 +69,11 @@ declare type ProductConsignmentAttributes = {
69
69
  discountValue: string;
70
70
  selectedForClearance: string;
71
71
  locationIds?: string[];
72
+ inventoryLocations: InventoryLocation[];
72
73
  };
73
74
  declare type ProductTimestampAttributes = {
75
+ createdAtTimestamp: number | null;
76
+ updatedAtTimestamp: number | null;
74
77
  sellRequestReviewTimestamp: number | null;
75
78
  sellRequestReviewDraftTimestamp: number | null;
76
79
  rejectedTimestamp: number | null;
@@ -188,6 +191,7 @@ declare type ProductConsignmentAttributesFormFields = {
188
191
  discountType: SingleSelectFormField<string>;
189
192
  discountValue: TextInputFormField<string>;
190
193
  locationIds: MultiSelectFormField<string>;
194
+ inventoryLocations: MultiSelectFormField<InventoryLocation>;
191
195
  };
192
196
  declare type ProductFormFields = ProductAttributesFormFields & ProductFilterAttributesFormFields & ProductConsignmentAttributesFormFields;
193
197
  interface ParamsForBuildProductInputObjForShopify {
@@ -221,3 +225,9 @@ declare type ProductLineItem = {
221
225
  image: string;
222
226
  quantity: number;
223
227
  };
228
+ declare type InventoryLocation = {
229
+ id: string;
230
+ name: string;
231
+ incomingAmount: number;
232
+ availableAmount: number;
233
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rerobe-js-orm",
3
- "version": "2.4.81",
3
+ "version": "2.4.85",
4
4
  "description": "ReRobe's Javascript ORM Framework",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",