rerobe-js-orm 2.4.2 → 2.4.8
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.
- package/lib/factories/FormState/Address/AddressFormStateFactory.d.ts +1 -1
- package/lib/factories/FormState/Address/AddressFormStateFactory.js +1 -1
- package/lib/factories/FormState/Merchant/MerchantFormStateFactory.d.ts +1 -1
- package/lib/factories/FormState/Merchant/MerchantFormStateFactory.js +1 -1
- package/lib/factories/FormState/Order/OrderFormStateFactory.d.ts +1 -1
- package/lib/factories/FormState/Order/OrderFormStateFactory.js +1 -1
- package/lib/factories/FormState/Order/RefundFormStateFactory.d.ts +5 -0
- package/lib/factories/FormState/Order/RefundFormStateFactory.js +10 -0
- package/lib/factories/FormState/PickUp/PickUpFormStateFactory.d.ts +1 -1
- package/lib/factories/FormState/PickUp/PickUpFormStateFactory.js +1 -1
- package/lib/factories/FormState/Product/ProductFormStateFactory.d.ts +2 -2
- package/lib/factories/FormState/Product/ProductFormStateFactory.js +3 -3
- package/lib/factories/FormState/ProductCollection/ProductCollectionFormStateFactory.d.ts +5 -0
- package/lib/factories/FormState/ProductCollection/ProductCollectionFormStateFactory.js +10 -0
- package/lib/factories/FormState/SellRequest/SellRequestFormStateFactory.d.ts +1 -1
- package/lib/factories/FormState/SellRequest/SellRequestFormStateFactory.js +1 -1
- package/lib/factories/FormState/User/UserFormStateFactory.d.ts +1 -1
- package/lib/factories/FormState/User/UserFormStateFactory.js +1 -1
- package/lib/factories/Merchant/MerchantFactory.d.ts +1 -1
- package/lib/factories/Merchant/MerchantFromFormState.d.ts +1 -1
- package/lib/factories/Merchant/MerchantFromFormState.js +13 -1
- package/lib/factories/Order/OrderFactory.d.ts +1 -1
- package/lib/factories/Order/OrderFromApp.js +4 -2
- package/lib/factories/Order/OrderFromFormState.d.ts +1 -1
- package/lib/factories/Order/OrderFromFormState.js +17 -15
- package/lib/factories/Order/OrderFromShopifyWebhook.js +126 -10
- package/lib/factories/Order/RefundFactory.d.ts +5 -0
- package/lib/factories/Order/RefundFactory.js +6 -0
- package/lib/factories/Order/RefundFromFormState.d.ts +5 -0
- package/lib/factories/Order/RefundFromFormState.js +29 -0
- package/lib/factories/PayoutAccount/PayoutAccountFromFormState.d.ts +1 -1
- package/lib/factories/Product/ProductFactory.d.ts +1 -1
- package/lib/factories/Product/ProductFromFormState.d.ts +1 -1
- package/lib/factories/Product/ProductFromFormState.js +29 -3
- package/lib/factories/ProductCollection/ProductCollectionFactory.d.ts +5 -0
- package/lib/factories/ProductCollection/ProductCollectionFactory.js +6 -0
- package/lib/factories/ProductCollection/ProductCollectionFromFormState.d.ts +5 -0
- package/lib/factories/ProductCollection/ProductCollectionFromFormState.js +29 -0
- package/lib/factories/User/UserFactory.d.ts +1 -1
- package/lib/factories/User/UserFromFormState.d.ts +1 -1
- package/lib/{models/FormStates → form-states}/Address/AddressFormState.d.ts +0 -0
- package/lib/{models/FormStates → form-states}/Address/AddressFormState.js +1 -3
- package/lib/{models/FormStates → form-states}/FormState.d.ts +1 -1
- package/lib/{models/FormStates → form-states}/FormState.js +1 -1
- package/lib/{models/FormStates → form-states}/Merchant/MerchantFormState.d.ts +1 -1
- package/lib/{models/FormStates → form-states}/Merchant/MerchantFormState.js +19 -4
- package/lib/form-states/Merchant/WebhookFormState.d.ts +8 -0
- package/lib/form-states/Merchant/WebhookFormState.js +49 -0
- package/lib/{models/FormStates → form-states}/Merchant/options.d.ts +8 -0
- package/lib/{models/FormStates → form-states}/Merchant/options.js +15 -2
- package/lib/{models/FormStates → form-states}/Order/OrderFormState.d.ts +2 -2
- package/lib/{models/FormStates → form-states}/Order/OrderFormState.js +12 -13
- package/lib/form-states/Order/RefundFormState.d.ts +17 -0
- package/lib/form-states/Order/RefundFormState.js +122 -0
- package/lib/{models/FormStates → form-states}/Order/options.d.ts +0 -0
- package/lib/{models/FormStates → form-states}/Order/options.js +1 -1
- package/lib/{models/FormStates → form-states}/PayoutAccount/PayoutAccountFormState.d.ts +1 -1
- package/lib/{models/FormStates → form-states}/PayoutAccount/PayoutAccountFormState.js +2 -2
- package/lib/{models/FormStates → form-states}/PayoutAccount/options.d.ts +0 -0
- package/lib/{models/FormStates → form-states}/PayoutAccount/options.js +0 -0
- package/lib/{models/FormStates → form-states}/PickUp/PickUpFormState.d.ts +0 -0
- package/lib/{models/FormStates → form-states}/PickUp/PickUpFormState.js +0 -0
- package/lib/{models/FormStates → form-states}/Product/ProductFormState.d.ts +8 -2
- package/lib/{models/FormStates → form-states}/Product/ProductFormState.js +24 -4
- package/lib/{models/FormStates → form-states}/Product/options.d.ts +0 -0
- package/lib/form-states/Product/options.js +3455 -0
- package/lib/form-states/ProductCollection/ProductCollectionFormState.d.ts +12 -0
- package/lib/form-states/ProductCollection/ProductCollectionFormState.js +80 -0
- package/lib/{models/FormStates → form-states}/SellRequest/SellRequestFormState.d.ts +0 -0
- package/lib/{models/FormStates → form-states}/SellRequest/SellRequestFormState.js +1 -1
- package/lib/{models/FormStates → form-states}/User/UserFormState.d.ts +1 -1
- package/lib/{models/FormStates → form-states}/User/UserFormState.js +2 -2
- package/lib/helpers/AnalyticsHelpers.js +3 -3
- package/lib/helpers/OrderHelpers.d.ts +5 -0
- package/lib/helpers/OrderHelpers.js +107 -0
- package/lib/helpers/ProductCollectionHelpers.d.ts +4 -0
- package/lib/helpers/ProductCollectionHelpers.js +27 -0
- package/lib/helpers/ReRobeProductHelpers.d.ts +6 -0
- package/lib/helpers/ReRobeProductHelpers.js +221 -41
- package/lib/helpers/Utilities.d.ts +1 -0
- package/lib/helpers/Utilities.js +10 -0
- package/lib/index.d.ts +7 -3
- package/lib/index.js +11 -3
- package/lib/models/Merchant.d.ts +16 -0
- package/lib/models/Merchant.js +40 -0
- package/lib/models/Order.d.ts +4 -0
- package/lib/models/Order.js +7 -1
- package/lib/models/Product.d.ts +1 -0
- package/lib/models/Product.js +37 -3
- package/lib/models/ProductCollection.d.ts +15 -0
- package/lib/models/ProductCollection.js +34 -0
- package/lib/models/Refund.d.ts +13 -0
- package/lib/models/Refund.js +40 -0
- package/lib/models/User.js +7 -2
- package/lib/types/merchant-types.d.ts +46 -13
- package/lib/types/product-collection-types.d.ts +63 -0
- package/lib/types/product-collection-types.js +13 -0
- package/lib/types/rerobe-order-types.d.ts +88 -26
- package/lib/types/rerobe-product-types.d.ts +30 -0
- package/lib/types/rerobe-user-types.d.ts +27 -21
- package/lib/types/rerobe-user-types.js +0 -1
- package/package.json +3 -2
- package/lib/models/FormStates/Product/options.js +0 -3453
|
@@ -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;
|
|
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;
|
|
8
8
|
const productAttributes = {
|
|
9
9
|
availableForSale: props.fields.availableForSale.selectedValue,
|
|
10
10
|
description: props.fields.description.inputValue,
|
|
@@ -27,7 +27,8 @@ class ProductFromFormState extends ProductFactory_1.default {
|
|
|
27
27
|
compareAtPrice: props.fields.compareAtPrice.inputValue,
|
|
28
28
|
quantity: props.fields.quantity.inputValue,
|
|
29
29
|
merchants: ((_l = props.props) === null || _l === void 0 ? void 0 : _l.merchants) || [],
|
|
30
|
-
editorAuthorizations: props.fields.editorAuthorizations.selectedValue
|
|
30
|
+
editorAuthorizations: props.fields.editorAuthorizations.selectedValue,
|
|
31
|
+
rfidTag: props.fields.rfidTag.inputValue || '',
|
|
31
32
|
};
|
|
32
33
|
const productFilterAttributes = {
|
|
33
34
|
documentId: (_m = props.props) === null || _m === void 0 ? void 0 : _m.documentId,
|
|
@@ -44,6 +45,8 @@ class ProductFromFormState extends ProductFactory_1.default {
|
|
|
44
45
|
productStyle: props.fields.productStyle.selectedValues,
|
|
45
46
|
shoeSize: props.fields.shoeSize.selectedValue,
|
|
46
47
|
measurements: props.fields.measurements.selectedValue || {},
|
|
48
|
+
featuredCollections: props.fields.featuredCollections.selectedValues || [],
|
|
49
|
+
tags: props.fields.tags.selectedValues || [],
|
|
47
50
|
};
|
|
48
51
|
const consignmentAttributes = {
|
|
49
52
|
previousSellers: props.fields.previousSellers.selectedValues,
|
|
@@ -72,8 +75,31 @@ class ProductFromFormState extends ProductFactory_1.default {
|
|
|
72
75
|
discountType: props.fields.discountType.selectedValue || '',
|
|
73
76
|
discountValue: props.fields.discountValue.inputValue || '',
|
|
74
77
|
selectedForClearance: ((_r = props.props) === null || _r === void 0 ? void 0 : _r.selectedForClearance) || '',
|
|
78
|
+
locationIds: props.fields.locationIds.selectedValues || [],
|
|
75
79
|
};
|
|
76
|
-
|
|
80
|
+
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,
|
|
101
|
+
};
|
|
102
|
+
return new Product_1.default(Object.assign(Object.assign(Object.assign(Object.assign({}, productAttributes), productFilterAttributes), consignmentAttributes), timestampAttributes));
|
|
77
103
|
}
|
|
78
104
|
}
|
|
79
105
|
exports.default = ProductFromFormState;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import Base from '../../Base';
|
|
2
|
+
import ProductCollectionFormState from '../../form-states/ProductCollection/ProductCollectionFormState';
|
|
3
|
+
export default abstract class ProductCollectionFactory extends Base {
|
|
4
|
+
abstract createProductCollection(refund: ProductCollectionFormState): ProductCollectionType;
|
|
5
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import ProductCollectionFormState from '../../form-states/ProductCollection/ProductCollectionFormState';
|
|
2
|
+
import ProductCollectionFactory from './ProductCollectionFactory';
|
|
3
|
+
export default class ProductCollectionFromFormState extends ProductCollectionFactory {
|
|
4
|
+
createProductCollection(fs: ProductCollectionFormState): ProductCollectionType;
|
|
5
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const ProductCollectionFactory_1 = require("./ProductCollectionFactory");
|
|
4
|
+
const ProductCollection_1 = require("../../models/ProductCollection");
|
|
5
|
+
// @ts-ignore
|
|
6
|
+
const lodash_1 = require("lodash");
|
|
7
|
+
class ProductCollectionFromFormState extends ProductCollectionFactory_1.default {
|
|
8
|
+
createProductCollection(fs) {
|
|
9
|
+
var _a;
|
|
10
|
+
let collectionId = fs.fields.collectionId.inputValue;
|
|
11
|
+
if (!collectionId) {
|
|
12
|
+
collectionId = lodash_1.camelCase(fs.fields.title.inputValue) + new Date().toISOString().split('T')[0];
|
|
13
|
+
}
|
|
14
|
+
const productCollectionAttributes = {
|
|
15
|
+
documentId: ((_a = fs.props) === null || _a === void 0 ? void 0 : _a.documentId) || '',
|
|
16
|
+
preTitle: fs.fields.preTitle.inputValue || '',
|
|
17
|
+
title: fs.fields.title.inputValue || '',
|
|
18
|
+
subTitle: fs.fields.subTitle.inputValue || '',
|
|
19
|
+
description: fs.fields.description.inputValue || '',
|
|
20
|
+
type: fs.fields.type.selectedValue || '',
|
|
21
|
+
imgUrl: fs.fields.imgUrl.inputValue || '',
|
|
22
|
+
refinements: fs.fields.refinements.selectedValue || {},
|
|
23
|
+
tags: fs.fields.tags.selectedValues || [],
|
|
24
|
+
collectionId,
|
|
25
|
+
};
|
|
26
|
+
return new ProductCollection_1.default(Object.assign({}, productCollectionAttributes));
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
exports.default = ProductCollectionFromFormState;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import User from '../../models/User';
|
|
2
|
-
import UserFormState from '../../
|
|
2
|
+
import UserFormState from '../../form-states/User/UserFormState';
|
|
3
3
|
import Base from '../../Base';
|
|
4
4
|
export default abstract class UserFactory extends Base {
|
|
5
5
|
abstract createUser(props: UserFormState | UserRespFromShopifyWebhook | UserObjForAuthTemplateMethod): User;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import UserFactory from './UserFactory';
|
|
2
2
|
import User from '../../models/User';
|
|
3
|
-
import UserFormState from '../../
|
|
3
|
+
import UserFormState from '../../form-states/User/UserFormState';
|
|
4
4
|
export default class UserFromFormState extends UserFactory {
|
|
5
5
|
createUser(props: UserFormState): User;
|
|
6
6
|
}
|
|
File without changes
|
|
@@ -32,9 +32,7 @@ class AddressFormState extends FormState_1.default {
|
|
|
32
32
|
zip: this.fields.zip.inputValue,
|
|
33
33
|
};
|
|
34
34
|
}
|
|
35
|
-
fieldFactory(fieldType, fieldKey
|
|
36
|
-
const options = fieldOptions || [];
|
|
37
|
-
const hidden = false;
|
|
35
|
+
fieldFactory(fieldType, fieldKey) {
|
|
38
36
|
if (fieldType === 'textInput') {
|
|
39
37
|
const inputValue = this.props[fieldKey] || '';
|
|
40
38
|
const valid = !!this.props[fieldKey];
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const FormState_1 = require("../FormState");
|
|
4
|
-
const Merchant_1 = require("../../Merchant");
|
|
5
|
-
const MerchantFromFormState_1 = require("
|
|
4
|
+
const Merchant_1 = require("../../models/Merchant");
|
|
5
|
+
const MerchantFromFormState_1 = require("../../factories/Merchant/MerchantFromFormState");
|
|
6
6
|
const options_1 = require("./options");
|
|
7
7
|
class MerchantFormState extends FormState_1.default {
|
|
8
8
|
constructor(props) {
|
|
@@ -21,6 +21,7 @@ class MerchantFormState extends FormState_1.default {
|
|
|
21
21
|
this.fields.timeZone = this.fieldFactory('singleSelect', 'timeZone', options_1.timeZoneOptions);
|
|
22
22
|
this.fields.unitSystem = this.fieldFactory('singleSelect', 'unitSystem', options_1.unitSystemOptions);
|
|
23
23
|
this.fields.defaultWeightUnit = this.fieldFactory('singleSelect', 'defaultWeightUnit');
|
|
24
|
+
this.fields.webhooks = this.fieldFactory('multiSelect', 'webhooks');
|
|
24
25
|
}
|
|
25
26
|
createMerchant() {
|
|
26
27
|
const merchantFactory = new MerchantFromFormState_1.default();
|
|
@@ -28,7 +29,7 @@ class MerchantFormState extends FormState_1.default {
|
|
|
28
29
|
}
|
|
29
30
|
fieldFactory(fieldType, fieldKey, fieldOptions) {
|
|
30
31
|
const options = fieldOptions || [];
|
|
31
|
-
if (fieldType === 'textInput' && fieldKey !== 'address') {
|
|
32
|
+
if (fieldType === 'textInput' && fieldKey !== 'address' && fieldKey !== 'webhooks') {
|
|
32
33
|
const inputValue = this.props[fieldKey] || '';
|
|
33
34
|
const valid = !!this.props[fieldKey];
|
|
34
35
|
let onChangeHandler = (val) => this.textInputChangeHandler(fieldKey, String(val));
|
|
@@ -50,7 +51,21 @@ class MerchantFormState extends FormState_1.default {
|
|
|
50
51
|
onChangeHandler,
|
|
51
52
|
};
|
|
52
53
|
}
|
|
53
|
-
if (fieldType === '
|
|
54
|
+
if (fieldType === 'multiSelect') {
|
|
55
|
+
let selectedValues = [];
|
|
56
|
+
let valid = false;
|
|
57
|
+
if (fieldKey === 'webhooks') {
|
|
58
|
+
selectedValues = this.props.webhooks || [];
|
|
59
|
+
valid = true;
|
|
60
|
+
}
|
|
61
|
+
return {
|
|
62
|
+
options,
|
|
63
|
+
selectedValues,
|
|
64
|
+
valid,
|
|
65
|
+
onChangeHandler: (val) => this.multiSelectChangeHandler(fieldKey, val),
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
if (fieldType === 'singleSelect' && fieldKey !== 'webhooks') {
|
|
54
69
|
let selectedValue = '';
|
|
55
70
|
let valid = true;
|
|
56
71
|
let onChangeHandler = (val) => this.singleSelectChangeHandler(fieldKey, val);
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const FormState_1 = require("../FormState");
|
|
4
|
+
const options_1 = require("./options");
|
|
5
|
+
class WebhookFormState extends FormState_1.default {
|
|
6
|
+
constructor(props) {
|
|
7
|
+
super();
|
|
8
|
+
this.props = {
|
|
9
|
+
event: (props === null || props === void 0 ? void 0 : props.event) || '',
|
|
10
|
+
callBackUrl: (props === null || props === void 0 ? void 0 : props.callBackUrl) || '',
|
|
11
|
+
};
|
|
12
|
+
this.fields.event = this.fieldFactory('singleSelect', 'event', options_1.webhookKeyOptions);
|
|
13
|
+
this.fields.callBackUrl = this.fieldFactory('textInput', 'callBackUrl');
|
|
14
|
+
}
|
|
15
|
+
toObj() {
|
|
16
|
+
return {
|
|
17
|
+
event: this.fields.event.selectedValue,
|
|
18
|
+
callBackUrl: this.fields.callBackUrl.inputValue,
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
fieldFactory(fieldType, fieldKey, fieldOptions) {
|
|
22
|
+
if (fieldType === 'singleSelect') {
|
|
23
|
+
const options = fieldOptions || [];
|
|
24
|
+
const selectedValue = this.props[fieldKey] || '';
|
|
25
|
+
const valid = !!this.props[fieldKey];
|
|
26
|
+
const onChangeHandler = (val) => this.singleSelectChangeHandler(fieldKey, String(val));
|
|
27
|
+
return {
|
|
28
|
+
options,
|
|
29
|
+
selectedValue,
|
|
30
|
+
valid,
|
|
31
|
+
onChangeHandler,
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
if (fieldType === 'textInput') {
|
|
35
|
+
const inputValue = this.props[fieldKey] || '';
|
|
36
|
+
const valid = !!this.props[fieldKey];
|
|
37
|
+
const onChangeHandler = (val) => this.textInputChangeHandler(fieldKey, String(val));
|
|
38
|
+
return {
|
|
39
|
+
inputValue,
|
|
40
|
+
valid,
|
|
41
|
+
onChangeHandler,
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
return {
|
|
45
|
+
valid: false,
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
exports.default = WebhookFormState;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.timeZoneOptions = exports.currencyOptions = exports.imperialWeightOptions = exports.metricWeightOptions = exports.unitSystemOptions = exports.industryOptions = exports.paymentTierOptions = exports.merchantTypeOptions = void 0;
|
|
4
|
-
const Merchant_1 = require("../../Merchant");
|
|
3
|
+
exports.httpRequestMethodOptions = exports.webhookKeyOptions = exports.timeZoneOptions = exports.currencyOptions = exports.imperialWeightOptions = exports.metricWeightOptions = exports.unitSystemOptions = exports.industryOptions = exports.paymentTierOptions = exports.merchantTypeOptions = void 0;
|
|
4
|
+
const Merchant_1 = require("../../models/Merchant");
|
|
5
5
|
const merchantTypeOptions = [
|
|
6
6
|
{ label: 'Individual', value: Merchant_1.default.MERCHANT_TYPES.individual },
|
|
7
7
|
{ label: 'Business', value: Merchant_1.default.MERCHANT_TYPES.business },
|
|
@@ -362,3 +362,16 @@ const tzArr = [
|
|
|
362
362
|
];
|
|
363
363
|
const timeZoneOptions = tzArr.map((tz) => ({ label: `${tz[2]}`, value: `${tz[2]}` }));
|
|
364
364
|
exports.timeZoneOptions = timeZoneOptions;
|
|
365
|
+
const webhookKeyOptions = [
|
|
366
|
+
{ label: 'Create Product', value: Merchant_1.default.RIBBN_WEBHOOK_EVENT_DICT.productCreate },
|
|
367
|
+
{ label: 'Update Product', value: Merchant_1.default.RIBBN_WEBHOOK_EVENT_DICT.productUpdate },
|
|
368
|
+
{ label: 'Delete Product', value: Merchant_1.default.RIBBN_WEBHOOK_EVENT_DICT.productDelete },
|
|
369
|
+
];
|
|
370
|
+
exports.webhookKeyOptions = webhookKeyOptions;
|
|
371
|
+
const httpRequestMethodOptions = [
|
|
372
|
+
{ label: 'GET', value: 'GET' },
|
|
373
|
+
{ label: 'POST', value: 'POST' },
|
|
374
|
+
{ label: 'PUT', value: 'PUT' },
|
|
375
|
+
{ label: 'DELETE', value: 'DELETE' },
|
|
376
|
+
];
|
|
377
|
+
exports.httpRequestMethodOptions = httpRequestMethodOptions;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import FormState from '../FormState';
|
|
2
|
-
import Order from '../../Order';
|
|
3
|
-
import OrderHelpers from '
|
|
2
|
+
import Order from '../../models/Order';
|
|
3
|
+
import OrderHelpers from '../../helpers/OrderHelpers';
|
|
4
4
|
export default class OrderFormState extends FormState {
|
|
5
5
|
fields: OrderAttributesFormFields;
|
|
6
6
|
props: CompleteOrder;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const FormState_1 = require("../FormState");
|
|
4
|
-
const Order_1 = require("../../Order");
|
|
5
|
-
const OrderFromFormState_1 = require("
|
|
6
|
-
const OrderHelpers_1 = require("
|
|
4
|
+
const Order_1 = require("../../models/Order");
|
|
5
|
+
const OrderFromFormState_1 = require("../../factories/Order/OrderFromFormState");
|
|
6
|
+
const OrderHelpers_1 = require("../../helpers/OrderHelpers");
|
|
7
7
|
const options_1 = require("./options");
|
|
8
8
|
class OrderFormState extends FormState_1.default {
|
|
9
9
|
constructor(props, opts) {
|
|
@@ -55,7 +55,7 @@ class OrderFormState extends FormState_1.default {
|
|
|
55
55
|
const lineItem = val.lineItemLike;
|
|
56
56
|
const quantity = val.quantity;
|
|
57
57
|
const updatedLineItem = Object.assign(Object.assign({}, lineItem), { quantity, originalTotalPrice: Object.assign(Object.assign({}, lineItem.originalTotalPrice), { amount: Number((_a = lineItem.originalUnitPrice) === null || _a === void 0 ? void 0 : _a.amount) * quantity }) });
|
|
58
|
-
const lineItemToUpdateIndex = currentlineItems.findIndex((li) =>
|
|
58
|
+
const lineItemToUpdateIndex = currentlineItems.findIndex((li) => li.productId === lineItem.productId);
|
|
59
59
|
const lineItemsClone = [...currentlineItems];
|
|
60
60
|
lineItemsClone.splice(lineItemToUpdateIndex, 1, updatedLineItem);
|
|
61
61
|
const newLineItems = lineItemsClone;
|
|
@@ -64,7 +64,7 @@ class OrderFormState extends FormState_1.default {
|
|
|
64
64
|
// Remove a line item
|
|
65
65
|
if (val.lineItemLike.productId && !val.quantity) {
|
|
66
66
|
const lineItem = val.lineItemLike;
|
|
67
|
-
const newLineItems = currentlineItems.filter((li) =>
|
|
67
|
+
const newLineItems = currentlineItems.filter((li) => li.productId !== lineItem.productId);
|
|
68
68
|
this.fields.lineItems.selectedValues = newLineItems;
|
|
69
69
|
}
|
|
70
70
|
// Update subtotal price
|
|
@@ -72,17 +72,19 @@ class OrderFormState extends FormState_1.default {
|
|
|
72
72
|
.map((item) => { var _a; return Number((_a = item.originalTotalPrice) === null || _a === void 0 ? void 0 : _a.amount); })
|
|
73
73
|
.reduce((a, b) => a + b, 0);
|
|
74
74
|
// Update total price
|
|
75
|
-
this.fields.totalPrice.inputValue = Number(
|
|
75
|
+
this.fields.totalPrice.inputValue = Number(Number(this.fields.subtotalPrice.inputValue) -
|
|
76
|
+
Number(this.fields.totalDiscount.inputValue) +
|
|
77
|
+
Number(this.fields.totalShippingPrice.inputValue)).toFixed(2);
|
|
76
78
|
}
|
|
77
79
|
discountChangeHandler(val) {
|
|
78
80
|
this.fields.totalDiscount.inputValue = val;
|
|
79
81
|
// Update total price
|
|
80
|
-
this.fields.totalPrice.inputValue = Number(
|
|
82
|
+
this.fields.totalPrice.inputValue = Number(Number(this.fields.subtotalPrice.inputValue) - Number(val) + Number(this.fields.totalShippingPrice.inputValue)).toFixed(2);
|
|
81
83
|
}
|
|
82
84
|
shippingPriceChangeHandler(val) {
|
|
83
85
|
this.fields.totalShippingPrice.inputValue = val;
|
|
84
86
|
// Update total price
|
|
85
|
-
this.fields.totalPrice.inputValue = Number(
|
|
87
|
+
this.fields.totalPrice.inputValue = Number(Number(this.fields.subtotalPrice.inputValue) - Number(this.fields.totalDiscount.inputValue) + Number(val)).toFixed(2);
|
|
86
88
|
}
|
|
87
89
|
fieldFactory(fieldType, fieldKey, fieldOptions) {
|
|
88
90
|
let options = fieldOptions || [];
|
|
@@ -148,14 +150,11 @@ class OrderFormState extends FormState_1.default {
|
|
|
148
150
|
selectedValues = this.props.tags;
|
|
149
151
|
}
|
|
150
152
|
if (typeof this.props.tags === 'string') {
|
|
151
|
-
selectedValues = this.props.tags.split(',').map((s) =>
|
|
153
|
+
selectedValues = this.props.tags.split(',').map((s) => String(s).trim());
|
|
152
154
|
}
|
|
153
155
|
}
|
|
154
156
|
if (this.opts && this.opts.tagOptions && this.opts.tagOptions.length > 0) {
|
|
155
|
-
options = this.utilities.uniqObjArray([
|
|
156
|
-
...options,
|
|
157
|
-
...this.opts.tagOptions.map((t) => ({ label: t, value: t })),
|
|
158
|
-
], 'value');
|
|
157
|
+
options = this.utilities.uniqObjArray([...options, ...this.opts.tagOptions.map((t) => ({ label: t, value: t }))], 'value');
|
|
159
158
|
}
|
|
160
159
|
valid = true;
|
|
161
160
|
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import FormState from '../FormState';
|
|
2
|
+
import Refund from '../../models/Refund';
|
|
3
|
+
export default class RefundFormState extends FormState {
|
|
4
|
+
fields: OrderRefundFormFields;
|
|
5
|
+
props: CompleteRefund;
|
|
6
|
+
constructor(props?: any);
|
|
7
|
+
createRefund(): Refund;
|
|
8
|
+
updateTotalRefunded(): void;
|
|
9
|
+
getUpdatedRefundLineItem(lineItem: ReRobeOrderLineItem, quantityRefund: number | string, quantityCancel: number | string, unitOrderDiscountAmount: number): RefundLineItem;
|
|
10
|
+
refundLineItemChangeHandler(val: {
|
|
11
|
+
lineItemLike: ReRobeOrderLineItem | RefundLineItem;
|
|
12
|
+
quantityRefund: number | string;
|
|
13
|
+
quantityCancel: number | string;
|
|
14
|
+
unitOrderDiscount: number;
|
|
15
|
+
}): void;
|
|
16
|
+
private fieldFactory;
|
|
17
|
+
}
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const FormState_1 = require("../FormState");
|
|
4
|
+
const RefundFromFormState_1 = require("../../factories/Order/RefundFromFormState");
|
|
5
|
+
const Refund_1 = require("../../models/Refund");
|
|
6
|
+
class RefundFormState extends FormState_1.default {
|
|
7
|
+
constructor(props) {
|
|
8
|
+
super();
|
|
9
|
+
this.props = new Refund_1.default(props).toObj();
|
|
10
|
+
this.fields.totalRefunded = this.fieldFactory('textInput', 'totalRefunded');
|
|
11
|
+
this.fields.subtotalRefunded = this.fieldFactory('textInput', 'subtotalRefunded');
|
|
12
|
+
this.fields.refundDiscount = this.fieldFactory('textInput', 'refundDiscount');
|
|
13
|
+
this.fields.refundShipping = this.fieldFactory('textInput', 'refundShipping');
|
|
14
|
+
this.fields.totalTax = this.fieldFactory('textInput', 'totalTax');
|
|
15
|
+
this.fields.refundLineItems = this.fieldFactory('multiSelect', 'refundLineItems');
|
|
16
|
+
this.fields.note = this.fieldFactory('textInput', 'note');
|
|
17
|
+
}
|
|
18
|
+
createRefund() {
|
|
19
|
+
const refundFactory = new RefundFromFormState_1.default();
|
|
20
|
+
return refundFactory.createRefund(this);
|
|
21
|
+
}
|
|
22
|
+
updateTotalRefunded() {
|
|
23
|
+
this.fields.totalRefunded.inputValue = Number(Number(this.fields.subtotalRefunded.inputValue) -
|
|
24
|
+
Number(this.fields.refundDiscount.inputValue) +
|
|
25
|
+
Number(this.fields.refundShipping.inputValue) +
|
|
26
|
+
Number(this.fields.totalTax.inputValue)).toFixed(2);
|
|
27
|
+
}
|
|
28
|
+
getUpdatedRefundLineItem(lineItem, quantityRefund, quantityCancel, unitOrderDiscountAmount) {
|
|
29
|
+
var _a;
|
|
30
|
+
const lineItemPriceAmount = Number((_a = lineItem.originalUnitPrice) === null || _a === void 0 ? void 0 : _a.amount);
|
|
31
|
+
const quantityRefundValue = Number(quantityRefund || 0);
|
|
32
|
+
const quantityCancelValue = Number(quantityCancel || 0);
|
|
33
|
+
const discountTotalRefundAmount = Number(unitOrderDiscountAmount * (quantityRefundValue + quantityCancelValue));
|
|
34
|
+
const subtotalRefundWithoutDiscount = Number((lineItemPriceAmount - unitOrderDiscountAmount) * quantityRefundValue);
|
|
35
|
+
const subtotalCanceledWithoutDiscount = Number((lineItemPriceAmount - unitOrderDiscountAmount) * quantityCancelValue);
|
|
36
|
+
return {
|
|
37
|
+
lineItem,
|
|
38
|
+
quantityRefund: quantityRefundValue,
|
|
39
|
+
quantityCancel: quantityCancelValue,
|
|
40
|
+
discountRefund: Object.assign(Object.assign({}, lineItem.originalUnitPrice), { amount: discountTotalRefundAmount }),
|
|
41
|
+
subtotalRefund: Object.assign(Object.assign({}, lineItem.originalUnitPrice), { amount: subtotalRefundWithoutDiscount }),
|
|
42
|
+
subtotalCanceled: Object.assign(Object.assign({}, lineItem.originalUnitPrice), { amount: subtotalCanceledWithoutDiscount }),
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
refundLineItemChangeHandler(val) {
|
|
46
|
+
const currentLineItems = this.fields.refundLineItems.selectedValues;
|
|
47
|
+
const unitOrderDiscountAmount = val.unitOrderDiscount || 0;
|
|
48
|
+
// Add new product to line items
|
|
49
|
+
if (val.lineItemLike.productId) {
|
|
50
|
+
const lineItem = val.lineItemLike;
|
|
51
|
+
const newRefundLineItem = this.getUpdatedRefundLineItem(lineItem, val.quantityRefund, val.quantityCancel, unitOrderDiscountAmount);
|
|
52
|
+
this.fields.refundLineItems.selectedValues = [...currentLineItems, newRefundLineItem];
|
|
53
|
+
}
|
|
54
|
+
// Update quantity of a line item
|
|
55
|
+
if ((val.quantityRefund || val.quantityCancel) && val.lineItemLike.lineItem) {
|
|
56
|
+
const refundLineItem = val.lineItemLike;
|
|
57
|
+
const { lineItem, quantityRefund: prevQuantityRefund, quantityCancel: prevQuantityCancel } = refundLineItem;
|
|
58
|
+
const updatedRefundLineItem = this.getUpdatedRefundLineItem(lineItem, val.quantityRefund || prevQuantityRefund, val.quantityCancel || prevQuantityCancel, unitOrderDiscountAmount);
|
|
59
|
+
const lineItemToUpdateIndex = currentLineItems.findIndex((li) => li.lineItem.productId === refundLineItem.lineItem.productId);
|
|
60
|
+
const lineItemsClone = [...currentLineItems];
|
|
61
|
+
lineItemsClone.splice(lineItemToUpdateIndex, 1, updatedRefundLineItem);
|
|
62
|
+
this.fields.refundLineItems.selectedValues = lineItemsClone;
|
|
63
|
+
}
|
|
64
|
+
// Update discount price
|
|
65
|
+
this.fields.refundDiscount.inputValue = this.fields.refundLineItems.selectedValues
|
|
66
|
+
.map((item) => { var _a; return Number((_a = item.discountRefund) === null || _a === void 0 ? void 0 : _a.amount); })
|
|
67
|
+
.reduce((a, b) => a + b, 0);
|
|
68
|
+
// Update subtotal price
|
|
69
|
+
this.fields.subtotalRefunded.inputValue = this.fields.refundLineItems.selectedValues
|
|
70
|
+
.map((item) => { var _a; return Number(Number((_a = item.lineItem.originalUnitPrice) === null || _a === void 0 ? void 0 : _a.amount) * (item.quantityRefund + item.quantityCancel)); })
|
|
71
|
+
.reduce((a, b) => a + b, 0);
|
|
72
|
+
// Update total price
|
|
73
|
+
this.updateTotalRefunded();
|
|
74
|
+
}
|
|
75
|
+
fieldFactory(fieldType, fieldKey, fieldOptions) {
|
|
76
|
+
const options = fieldOptions || [];
|
|
77
|
+
if (fieldType === 'textInput') {
|
|
78
|
+
let inputValue = this.props[fieldKey] || '';
|
|
79
|
+
let onChangeHandler = (val) => this.textInputChangeHandler(fieldKey, String(val));
|
|
80
|
+
const amountTypeFields = ['totalRefunded', 'subtotalRefunded', 'refundDiscount', 'refundShipping', 'totalTax'];
|
|
81
|
+
if (amountTypeFields.includes(fieldKey.toString())) {
|
|
82
|
+
// @ts-ignore
|
|
83
|
+
inputValue = this.props[fieldKey] ? this.props[fieldKey].amount : 0;
|
|
84
|
+
}
|
|
85
|
+
if (fieldKey === 'subtotalRefunded' ||
|
|
86
|
+
fieldKey === 'refundDiscount' ||
|
|
87
|
+
fieldKey === 'refundShipping' ||
|
|
88
|
+
fieldKey === 'totalTax') {
|
|
89
|
+
onChangeHandler = (val) => {
|
|
90
|
+
this.fields[fieldKey].inputValue = String(val);
|
|
91
|
+
this.updateTotalRefunded();
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
const valid = !!this.props[fieldKey];
|
|
95
|
+
return {
|
|
96
|
+
inputValue,
|
|
97
|
+
valid,
|
|
98
|
+
onChangeHandler,
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
if (fieldType === 'multiSelect') {
|
|
102
|
+
let selectedValues = [];
|
|
103
|
+
let valid = true;
|
|
104
|
+
let onChangeHandler = (val) => this.multiSelectChangeHandler(fieldKey, val);
|
|
105
|
+
if (fieldKey === 'refundLineItems') {
|
|
106
|
+
selectedValues = this.props.refundLineItems || [];
|
|
107
|
+
valid = this.props.refundLineItems && this.props.refundLineItems.length > 0;
|
|
108
|
+
onChangeHandler = (val) => this.refundLineItemChangeHandler(val);
|
|
109
|
+
}
|
|
110
|
+
return {
|
|
111
|
+
options,
|
|
112
|
+
selectedValues,
|
|
113
|
+
valid,
|
|
114
|
+
onChangeHandler,
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
return {
|
|
118
|
+
valid: false,
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
exports.default = RefundFormState;
|
|
File without changes
|
|
@@ -31,6 +31,6 @@ const cancelTypeOptions = [
|
|
|
31
31
|
exports.cancelTypeOptions = cancelTypeOptions;
|
|
32
32
|
const defaultTags = [
|
|
33
33
|
{ label: 'store', value: 'store' },
|
|
34
|
-
{ label: 'third-party-channel', value: 'third-party-channel' }
|
|
34
|
+
{ label: 'third-party-channel', value: 'third-party-channel' },
|
|
35
35
|
];
|
|
36
36
|
exports.defaultTags = defaultTags;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import FormState from '../FormState';
|
|
2
|
-
import PayoutAccount from '
|
|
2
|
+
import PayoutAccount from '../../models/PayoutAccount';
|
|
3
3
|
export default class PayoutAccountFormState extends FormState {
|
|
4
4
|
fields: PayoutAccountFormFields;
|
|
5
5
|
props: PayoutAccountObj;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const FormState_1 = require("../FormState");
|
|
4
|
-
const PayoutAccount_1 = require("
|
|
4
|
+
const PayoutAccount_1 = require("../../models/PayoutAccount");
|
|
5
5
|
const options_1 = require("./options");
|
|
6
|
-
const PayoutAccountFromFormState_1 = require("
|
|
6
|
+
const PayoutAccountFromFormState_1 = require("../../factories/PayoutAccount/PayoutAccountFromFormState");
|
|
7
7
|
class PayoutAccountFormState extends FormState_1.default {
|
|
8
8
|
constructor(props) {
|
|
9
9
|
super();
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -1,9 +1,15 @@
|
|
|
1
1
|
import FormState from '../FormState';
|
|
2
|
-
import Product from '
|
|
2
|
+
import Product from '../../models/Product';
|
|
3
3
|
export default class ProductFormState extends FormState {
|
|
4
4
|
fields: ProductFormFields;
|
|
5
5
|
props: CompleteProduct;
|
|
6
|
-
|
|
6
|
+
opts: {
|
|
7
|
+
featuredCollectionOpts: {
|
|
8
|
+
label: string;
|
|
9
|
+
value: string;
|
|
10
|
+
}[];
|
|
11
|
+
};
|
|
12
|
+
constructor(props?: any, opts?: any);
|
|
7
13
|
autoCreateTitle(): string;
|
|
8
14
|
autoCreateDescription(): string;
|
|
9
15
|
createProduct(): Product;
|