rerobe-js-orm 2.4.6 → 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/Product/ProductFormStateFactory.d.ts +1 -1
- package/lib/factories/FormState/Product/ProductFormStateFactory.js +2 -2
- package/lib/factories/FormState/ProductCollection/ProductCollectionFormStateFactory.d.ts +5 -0
- package/lib/factories/FormState/ProductCollection/ProductCollectionFormStateFactory.js +10 -0
- package/lib/factories/Order/OrderFromApp.js +3 -1
- package/lib/factories/Order/OrderFromFormState.js +13 -12
- package/lib/factories/Order/OrderFromShopifyWebhook.js +126 -10
- package/lib/factories/Order/RefundFromFormState.js +4 -1
- package/lib/factories/Product/ProductFromFormState.js +33 -8
- 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/form-states/Order/RefundFormState.d.ts +3 -1
- package/lib/form-states/Order/RefundFormState.js +24 -29
- package/lib/form-states/Product/ProductFormState.d.ts +7 -1
- package/lib/form-states/Product/ProductFormState.js +22 -2
- package/lib/form-states/ProductCollection/ProductCollectionFormState.d.ts +12 -0
- package/lib/form-states/ProductCollection/ProductCollectionFormState.js +80 -0
- package/lib/helpers/OrderHelpers.d.ts +4 -2
- package/lib/helpers/OrderHelpers.js +66 -12
- 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 +203 -1
- package/lib/index.d.ts +3 -1
- package/lib/index.js +5 -1
- package/lib/models/Order.d.ts +2 -0
- package/lib/models/Order.js +3 -0
- package/lib/models/Product.d.ts +1 -0
- package/lib/models/Product.js +34 -1
- package/lib/models/ProductCollection.d.ts +15 -0
- package/lib/models/ProductCollection.js +34 -0
- package/lib/models/User.js +5 -0
- 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 +46 -9
- package/lib/types/rerobe-product-types.d.ts +29 -0
- package/lib/types/rerobe-user-types.d.ts +27 -21
- package/package.json +3 -2
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import FormStateFactory from '../FormStateFactory';
|
|
2
2
|
import ProductFormState from '../../../form-states/Product/ProductFormState';
|
|
3
3
|
export default class ProductFormStateFactory extends FormStateFactory {
|
|
4
|
-
createFormState(props?: CompleteProduct): ProductFormState;
|
|
4
|
+
createFormState(props?: CompleteProduct, opts?: any): ProductFormState;
|
|
5
5
|
}
|
|
@@ -3,8 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
const FormStateFactory_1 = require("../FormStateFactory");
|
|
4
4
|
const ProductFormState_1 = require("../../../form-states/Product/ProductFormState");
|
|
5
5
|
class ProductFormStateFactory extends FormStateFactory_1.default {
|
|
6
|
-
createFormState(props) {
|
|
7
|
-
return new ProductFormState_1.default(props);
|
|
6
|
+
createFormState(props, opts) {
|
|
7
|
+
return new ProductFormState_1.default(props, opts);
|
|
8
8
|
}
|
|
9
9
|
}
|
|
10
10
|
exports.default = ProductFormStateFactory;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import FormStateFactory from '../FormStateFactory';
|
|
2
|
+
import ProductCollectionFormState from '../../../form-states/ProductCollection/ProductCollectionFormState';
|
|
3
|
+
export default class ProductCollectionFormStateFactory extends FormStateFactory {
|
|
4
|
+
createFormState(props?: any, opts?: any): ProductCollectionFormState;
|
|
5
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const FormStateFactory_1 = require("../FormStateFactory");
|
|
4
|
+
const ProductCollectionFormState_1 = require("../../../form-states/ProductCollection/ProductCollectionFormState");
|
|
5
|
+
class ProductCollectionFormStateFactory extends FormStateFactory_1.default {
|
|
6
|
+
createFormState(props, opts) {
|
|
7
|
+
return new ProductCollectionFormState_1.default(props, opts);
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
exports.default = ProductCollectionFormStateFactory;
|
|
@@ -6,7 +6,7 @@ const OrderHelpers_1 = require("../../helpers/OrderHelpers");
|
|
|
6
6
|
const orderHelpers = new OrderHelpers_1.default();
|
|
7
7
|
class OrderFromApp extends OrderFactory_1.default {
|
|
8
8
|
createOrder(order) {
|
|
9
|
-
const { id, orderNumber, amount, currencyCode = 'SEK', shippingDetails, appliedDiscount, products, paymentType, paymentMethod, shippingType, shopifyId, shopifyOrderNumber, state, userId, email, salesChannel, tags, paymentDetails, financialStatus, fulfillmentStatus, } = order;
|
|
9
|
+
const { id, orderNumber, amount, currencyCode = 'SEK', shippingDetails, appliedDiscount, products, paymentType, paymentMethod, shippingType, shopifyId, ribbnOrderNumber, shopifyOrderNumber, state, userId, email, customerName, salesChannel, tags, paymentDetails, financialStatus, fulfillmentStatus, } = order;
|
|
10
10
|
let discount = 0;
|
|
11
11
|
let shippingFee = 0;
|
|
12
12
|
let subTotal = 0;
|
|
@@ -52,12 +52,14 @@ class OrderFromApp extends OrderFactory_1.default {
|
|
|
52
52
|
paymentType: paymentType ? this.utilities.constantCase(paymentType) : Order_1.default.PAYMENT_TYPES.creditCard,
|
|
53
53
|
shippingType: shippingType ? this.utilities.constantCase(shippingType) : Order_1.default.SHIPPING_TYPES.localPickUp,
|
|
54
54
|
shopifyId,
|
|
55
|
+
ribbnOrderNumber,
|
|
55
56
|
shopifyOrderNumber,
|
|
56
57
|
shippingAddress: shippingDetails && shippingDetails.deliveryAddress ? shippingDetails.deliveryAddress : null,
|
|
57
58
|
lineItems,
|
|
58
59
|
state,
|
|
59
60
|
userId,
|
|
60
61
|
email,
|
|
62
|
+
customerName,
|
|
61
63
|
paymentDetails,
|
|
62
64
|
tags,
|
|
63
65
|
salesChannel,
|
|
@@ -4,7 +4,7 @@ const OrderFactory_1 = require("./OrderFactory");
|
|
|
4
4
|
const Order_1 = require("../../models/Order");
|
|
5
5
|
class OrderFromFormState extends OrderFactory_1.default {
|
|
6
6
|
createOrder(fs) {
|
|
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;
|
|
8
8
|
const currencyCode = fs.fields.currencyCode.inputValue || 'SEK';
|
|
9
9
|
const customer = fs.fields.customer.selectedValue || {};
|
|
10
10
|
const firstName = fs.fields.firstName.inputValue;
|
|
@@ -17,13 +17,14 @@ class OrderFromFormState extends OrderFactory_1.default {
|
|
|
17
17
|
documentId: ((_c = fs.props) === null || _c === void 0 ? void 0 : _c.documentId) || '',
|
|
18
18
|
name: ((_d = fs.props) === null || _d === void 0 ? void 0 : _d.name) || '',
|
|
19
19
|
orderNumber: (_e = fs.props) === null || _e === void 0 ? void 0 : _e.orderNumber,
|
|
20
|
-
|
|
20
|
+
ribbnOrderNumber: (_f = fs.props) === null || _f === void 0 ? void 0 : _f.ribbnOrderNumber,
|
|
21
|
+
state: ((_g = fs.props) === null || _g === void 0 ? void 0 : _g.state) || Order_1.default.ORDER_STATES.draft,
|
|
21
22
|
currencyCode: fs.fields.currencyCode.inputValue,
|
|
22
|
-
statusUrl: ((
|
|
23
|
-
processedAt: ((
|
|
23
|
+
statusUrl: ((_h = fs.props) === null || _h === void 0 ? void 0 : _h.statusUrl) || '',
|
|
24
|
+
processedAt: ((_j = fs.props) === null || _j === void 0 ? void 0 : _j.processedAt) || new Date().toUTCString(),
|
|
24
25
|
financialStatus: fs.fields.financialStatus.selectedValue,
|
|
25
26
|
fulfillmentStatus: fs.fields.fulfillmentStatus.selectedValue,
|
|
26
|
-
fulfillments: ((
|
|
27
|
+
fulfillments: ((_k = fs.props) === null || _k === void 0 ? void 0 : _k.fulfillments) || [],
|
|
27
28
|
shippingAddress: fs.fields.shippingAddress.selectedValue || {
|
|
28
29
|
id: '',
|
|
29
30
|
address1: '',
|
|
@@ -34,7 +35,7 @@ class OrderFromFormState extends OrderFactory_1.default {
|
|
|
34
35
|
province: '',
|
|
35
36
|
zip: '',
|
|
36
37
|
},
|
|
37
|
-
shippingDiscountAllocations: ((
|
|
38
|
+
shippingDiscountAllocations: ((_l = fs.props) === null || _l === void 0 ? void 0 : _l.shippingDiscountAllocations) || [],
|
|
38
39
|
shippingLine: fs.fields.shippingLine
|
|
39
40
|
? fs.fields.shippingLine.selectedValue
|
|
40
41
|
: {
|
|
@@ -55,9 +56,9 @@ class OrderFromFormState extends OrderFactory_1.default {
|
|
|
55
56
|
originalTotalPrice: { amount: fs.fields.originalTotalPrice.inputValue || 0, currencyCode },
|
|
56
57
|
lineItems: fs.fields.lineItems.selectedValues || [],
|
|
57
58
|
cancelReason: fs.fields.cancelReason.selectedValue || '',
|
|
58
|
-
canceledAt: ((
|
|
59
|
-
customerUrl: ((
|
|
60
|
-
discountApplications: ((
|
|
59
|
+
canceledAt: ((_m = fs.props) === null || _m === void 0 ? void 0 : _m.canceledAt) || '',
|
|
60
|
+
customerUrl: ((_o = fs.props) === null || _o === void 0 ? void 0 : _o.customerUrl) || '',
|
|
61
|
+
discountApplications: ((_p = fs.props) === null || _p === void 0 ? void 0 : _p.discountApplications) || [],
|
|
61
62
|
physicalLocation: fs.fields.physicalLocation.selectedValue || {
|
|
62
63
|
id: '',
|
|
63
64
|
activatable: true,
|
|
@@ -76,7 +77,7 @@ class OrderFromFormState extends OrderFactory_1.default {
|
|
|
76
77
|
},
|
|
77
78
|
notes: fs.fields.notes.inputValue || '',
|
|
78
79
|
userId: (customer === null || customer === void 0 ? void 0 : customer.uid) || '',
|
|
79
|
-
customerName: ((
|
|
80
|
+
customerName: ((_q = fs.props) === null || _q === void 0 ? void 0 : _q.customerName) ||
|
|
80
81
|
(customer.displayName ? customer.displayName : '') ||
|
|
81
82
|
(customer.firstName && customer.lastName ? `${customer.firstName} ${customer.lastName}` : '') ||
|
|
82
83
|
(firstName && lastName ? `${firstName} ${lastName}` : ''),
|
|
@@ -84,9 +85,9 @@ class OrderFromFormState extends OrderFactory_1.default {
|
|
|
84
85
|
phone: (customer === null || customer === void 0 ? void 0 : customer.phone) || fs.fields.phone.inputValue || '',
|
|
85
86
|
paymentMethod: fs.fields.paymentMethod.selectedValue || '',
|
|
86
87
|
paymentDetails: fs.fields.paymentDetails.selectedValue || {},
|
|
87
|
-
merchantId: ((
|
|
88
|
+
merchantId: ((_r = fs.props) === null || _r === void 0 ? void 0 : _r.merchantId) || '',
|
|
88
89
|
tags: fs.fields.tags.selectedValues || [],
|
|
89
|
-
refunds: ((
|
|
90
|
+
refunds: ((_s = fs.props) === null || _s === void 0 ? void 0 : _s.refunds) || [],
|
|
90
91
|
};
|
|
91
92
|
return new Order_1.default(Object.assign({}, orderAttributes));
|
|
92
93
|
}
|
|
@@ -4,6 +4,18 @@ const OrderFactory_1 = require("./OrderFactory");
|
|
|
4
4
|
const Order_1 = require("../../models/Order");
|
|
5
5
|
const OrderHelpers_1 = require("../../helpers/OrderHelpers");
|
|
6
6
|
const orderHelpers = new OrderHelpers_1.default();
|
|
7
|
+
const fulfillmentStatusRestMapping = {
|
|
8
|
+
fulfilled: 'FULFILLED',
|
|
9
|
+
null: '',
|
|
10
|
+
partial: 'PARTIALLY_FULFILLED',
|
|
11
|
+
restocked: 'RESTOCKED',
|
|
12
|
+
pending: 'PENDING_FULFILLMENT',
|
|
13
|
+
open: 'OPEN',
|
|
14
|
+
success: 'SUCCESS',
|
|
15
|
+
cancelled: 'CANCELED',
|
|
16
|
+
error: 'ERROR',
|
|
17
|
+
failure: 'FAILURE',
|
|
18
|
+
};
|
|
7
19
|
class OrderFromShopifyWebhook extends OrderFactory_1.default {
|
|
8
20
|
createOrder(order) {
|
|
9
21
|
const { id, financial_status, fulfillment_status, cancel_reason, line_items, discount_applications, shipping_address, subtotal_price_set, total_price_set, total_shipping_price_set, currency, cancelled_at, closed_at, created_at, order_number, processed_at, updated_at, shipping_lines, tax_lines, name, total_discounts, tags = '', } = order;
|
|
@@ -78,23 +90,123 @@ class OrderFromShopifyWebhook extends OrderFactory_1.default {
|
|
|
78
90
|
}
|
|
79
91
|
: null;
|
|
80
92
|
const fulfillments = order.fulfillments
|
|
81
|
-
? order.fulfillments.map((item) => (
|
|
93
|
+
? order.fulfillments.map((item) => ({
|
|
94
|
+
name: item.name,
|
|
95
|
+
id: item.id,
|
|
96
|
+
createdAt: item.created_at,
|
|
97
|
+
updatedAt: item.updated_at,
|
|
98
|
+
location: {
|
|
82
99
|
id: item.location_id || '',
|
|
83
|
-
},
|
|
84
|
-
|
|
85
|
-
|
|
100
|
+
},
|
|
101
|
+
shipmentStatus: item.shipment_status ? item.shipment_status.toUpperCase() : '',
|
|
102
|
+
service: {
|
|
86
103
|
serviceType: item.service ? item.service.toUpperCase() : '',
|
|
87
|
-
},
|
|
104
|
+
},
|
|
105
|
+
status: item.status ? item.status.toUpperCase() : '',
|
|
106
|
+
trackingInfo: {
|
|
88
107
|
company: item.tracking_company,
|
|
89
108
|
number: item.tracking_numbers && !!item.tracking_numbers.length ? item.tracking_numbers[0] : '',
|
|
90
109
|
url: item.tracking_urls && !!item.tracking_urls.length ? item.tracking_urls[0] : '',
|
|
91
|
-
},
|
|
110
|
+
},
|
|
111
|
+
fulfillmentLineItems: item.line_items
|
|
92
112
|
? item.line_items.map((lineItem) => ({
|
|
93
|
-
lineItem,
|
|
113
|
+
lineItem: { shopifyProductId: lineItem === null || lineItem === void 0 ? void 0 : lineItem.product_id },
|
|
94
114
|
quantity: lineItem.quantity,
|
|
95
115
|
}))
|
|
96
|
-
: []
|
|
116
|
+
: [],
|
|
117
|
+
}))
|
|
118
|
+
: [];
|
|
119
|
+
const refunds = order.refunds
|
|
120
|
+
? order.refunds.map((rawRefundItem) => {
|
|
121
|
+
const currencyCode = currency;
|
|
122
|
+
const refundedShippingAmount = !rawRefundItem.order_adjustments.length
|
|
123
|
+
? 0
|
|
124
|
+
: rawRefundItem.order_adjustments.reduce((result, item) => {
|
|
125
|
+
if (item.kind === 'shipping_refund') {
|
|
126
|
+
result = result - Number(item.amount);
|
|
127
|
+
}
|
|
128
|
+
return result;
|
|
129
|
+
}, 0);
|
|
130
|
+
const totalRefundedAmount = !rawRefundItem.transactions.length
|
|
131
|
+
? 0
|
|
132
|
+
: rawRefundItem.transactions.reduce((result, item) => {
|
|
133
|
+
if (item.kind === 'refund') {
|
|
134
|
+
result = result + Number(item.amount);
|
|
135
|
+
}
|
|
136
|
+
return result;
|
|
137
|
+
}, 0);
|
|
138
|
+
let refundDiscountAmount = 0;
|
|
139
|
+
const subtotalRefundedAmount = !rawRefundItem.refund_line_items.length
|
|
140
|
+
? 0
|
|
141
|
+
: rawRefundItem.refund_line_items.reduce((result, item) => {
|
|
142
|
+
if (item.line_item) {
|
|
143
|
+
const itemSubtotal = Number(Number(item.line_item.price) * item.quantity);
|
|
144
|
+
result = result + itemSubtotal;
|
|
145
|
+
refundDiscountAmount = refundDiscountAmount + itemSubtotal - Number(item.subtotal);
|
|
146
|
+
}
|
|
147
|
+
return result;
|
|
148
|
+
}, 0);
|
|
149
|
+
let refundLineItems = !rawRefundItem.refund_line_items || !rawRefundItem.refund_line_items.length
|
|
150
|
+
? []
|
|
151
|
+
: rawRefundItem.refund_line_items.map((item) => {
|
|
152
|
+
var _a, _b;
|
|
153
|
+
const quantityRefund = !item.location_id ? item.quantity : 0;
|
|
154
|
+
const quantityCancel = item.location_id ? item.quantity : 0;
|
|
155
|
+
const discountRefundAmount = Number(Number((_a = item.line_item) === null || _a === void 0 ? void 0 : _a.price) * item.quantity) - Number(item.subtotal);
|
|
156
|
+
const subtotalRefundAmount = !item.location_id ? item.subtotal : 0;
|
|
157
|
+
const subtotalCanceledAmount = item.location_id ? item.subtotal : 0;
|
|
158
|
+
return {
|
|
159
|
+
lineItem: { shopifyProductId: (_b = item.line_item) === null || _b === void 0 ? void 0 : _b.product_id },
|
|
160
|
+
quantityRefund,
|
|
161
|
+
quantityCancel,
|
|
162
|
+
discountRefund: { currencyCode, amount: discountRefundAmount },
|
|
163
|
+
subtotalRefund: { currencyCode, amount: subtotalRefundAmount },
|
|
164
|
+
subtotalCanceled: { currencyCode, amount: subtotalCanceledAmount },
|
|
165
|
+
};
|
|
166
|
+
});
|
|
167
|
+
if (refundLineItems.length) {
|
|
168
|
+
refundLineItems = refundLineItems.reduce((result, item) => {
|
|
169
|
+
var _a;
|
|
170
|
+
const existedLineItemsIds = !result.length ? [] : result.map((itm) => itm.lineItem.shopifyProductId);
|
|
171
|
+
const existedLineItemIdx = existedLineItemsIds.indexOf((_a = item.lineItem) === null || _a === void 0 ? void 0 : _a.shopifyProductId);
|
|
172
|
+
if (existedLineItemIdx < 0) {
|
|
173
|
+
result.push(item);
|
|
174
|
+
}
|
|
175
|
+
else {
|
|
176
|
+
result[existedLineItemIdx] = {
|
|
177
|
+
lineItem: result[existedLineItemIdx].lineItem,
|
|
178
|
+
quantityRefund: result[existedLineItemIdx].quantityRefund + item.quantityRefund,
|
|
179
|
+
quantityCancel: result[existedLineItemIdx].quantityCancel + item.quantityCancel,
|
|
180
|
+
discountRefund: Object.assign(Object.assign({}, result[existedLineItemIdx].discountRefund), { amount: result[existedLineItemIdx].discountRefund.amount + item.discountRefund.amount }),
|
|
181
|
+
subtotalRefund: Object.assign(Object.assign({}, result[existedLineItemIdx].subtotalRefund), { amount: result[existedLineItemIdx].subtotalRefund.amount + item.subtotalRefund.amount }),
|
|
182
|
+
subtotalCanceled: Object.assign(Object.assign({}, result[existedLineItemIdx].subtotalCanceled), { amount: result[existedLineItemIdx].subtotalCanceled.amount + item.subtotalCanceled.amount }),
|
|
183
|
+
};
|
|
184
|
+
}
|
|
185
|
+
return result;
|
|
186
|
+
}, []);
|
|
187
|
+
}
|
|
188
|
+
return {
|
|
189
|
+
documentId: rawRefundItem.id,
|
|
190
|
+
createdAt: rawRefundItem.created_at,
|
|
191
|
+
note: rawRefundItem.note,
|
|
192
|
+
totalRefunded: { amount: totalRefundedAmount, currencyCode },
|
|
193
|
+
subtotalRefunded: { amount: subtotalRefundedAmount, currencyCode },
|
|
194
|
+
refundDiscount: { amount: refundDiscountAmount, currencyCode },
|
|
195
|
+
refundShipping: { amount: refundedShippingAmount, currencyCode },
|
|
196
|
+
totalTax: { amount: 0, currencyCode },
|
|
197
|
+
refundLineItems,
|
|
198
|
+
};
|
|
199
|
+
})
|
|
97
200
|
: [];
|
|
201
|
+
const totalRefunded = {
|
|
202
|
+
currencyCode: currency,
|
|
203
|
+
amount: !refunds || !refunds.length
|
|
204
|
+
? 0
|
|
205
|
+
: refunds.reduce((result, item) => {
|
|
206
|
+
result = result + Number(item.totalRefunded.amount);
|
|
207
|
+
return result;
|
|
208
|
+
}, 0),
|
|
209
|
+
};
|
|
98
210
|
const taxLines = tax_lines
|
|
99
211
|
? tax_lines.map((item) => ({
|
|
100
212
|
rate: item.rate,
|
|
@@ -150,13 +262,17 @@ class OrderFromShopifyWebhook extends OrderFactory_1.default {
|
|
|
150
262
|
},
|
|
151
263
|
source: '',
|
|
152
264
|
};
|
|
153
|
-
|
|
265
|
+
// @ts-ignore
|
|
266
|
+
const fulfillmentStatus = !fulfillment_status ? '' : fulfillmentStatusRestMapping[fulfillment_status];
|
|
267
|
+
const rerobeOrder = new Order_1.default(Object.assign(Object.assign({}, order), { id: orderHelpers.getOrderIdFromShopifyObj(order), shopifyId: `gid://shopify/Order/${id}`, shopifyOrderNumber: name ? Number(name.split('#')[1]) : 0, financialStatus: financial_status ? financial_status.toUpperCase() : '', fulfillmentStatus, cancelReason: cancel_reason ? cancel_reason.toUpperCase() : '', lineItems,
|
|
154
268
|
subtotalPrice,
|
|
155
269
|
totalPrice,
|
|
156
270
|
totalShippingPrice,
|
|
157
|
-
totalDiscount,
|
|
271
|
+
totalDiscount,
|
|
272
|
+
totalRefunded, canceledAt: cancelled_at, closedAt: closed_at, createdAt: created_at, orderNumber: order_number, processedAt: processed_at, updatedAt: updated_at, shippingAddress,
|
|
158
273
|
discountApplications,
|
|
159
274
|
fulfillments,
|
|
275
|
+
refunds,
|
|
160
276
|
taxLines,
|
|
161
277
|
shippingLine, state: Order_1.default.ORDER_STATES.completed, shippingType: orderHelpers.getShippingTypeFromShopifyObj(shipping_lines), paymentType: orderHelpers.getPaymentTypeUsingTags(tags), salesChannel: orderHelpers.getSalesChannelUsingTags(tags), tags: tags ? tags.split(', ') : [] }));
|
|
162
278
|
return rerobeOrder.toObj();
|
|
@@ -10,6 +10,9 @@ class RefundFromFormState extends RefundFactory_1.default {
|
|
|
10
10
|
currencyCode = ((_a = fs.fields.refundLineItems.selectedValues[0].subtotalRefund) === null || _a === void 0 ? void 0 : _a.currencyCode) || '';
|
|
11
11
|
}
|
|
12
12
|
const subtotalRefundedAmount = fs.fields.subtotalRefunded.inputValue;
|
|
13
|
+
const preparedRefundLineItems = !fs.fields.refundLineItems.selectedValues.length
|
|
14
|
+
? []
|
|
15
|
+
: fs.fields.refundLineItems.selectedValues.filter(({ quantityRefund, quantityCancel }) => quantityRefund + quantityCancel > 0);
|
|
13
16
|
const refundAttributes = {
|
|
14
17
|
documentId: ((_b = fs.props) === null || _b === void 0 ? void 0 : _b.documentId) || '',
|
|
15
18
|
totalRefunded: { amount: fs.fields.totalRefunded.inputValue || 0, currencyCode },
|
|
@@ -17,7 +20,7 @@ class RefundFromFormState extends RefundFactory_1.default {
|
|
|
17
20
|
refundDiscount: { amount: fs.fields.refundDiscount.inputValue || 0, currencyCode },
|
|
18
21
|
refundShipping: { amount: fs.fields.refundShipping.inputValue || 0, currencyCode },
|
|
19
22
|
totalTax: { amount: fs.fields.totalTax.inputValue || 0, currencyCode },
|
|
20
|
-
refundLineItems:
|
|
23
|
+
refundLineItems: preparedRefundLineItems,
|
|
21
24
|
note: fs.fields.note.inputValue || '',
|
|
22
25
|
};
|
|
23
26
|
return new Refund_1.default(Object.assign({}, refundAttributes));
|
|
@@ -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;
|
|
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,
|
|
@@ -28,10 +28,10 @@ class ProductFromFormState extends ProductFactory_1.default {
|
|
|
28
28
|
quantity: props.fields.quantity.inputValue,
|
|
29
29
|
merchants: ((_l = props.props) === null || _l === void 0 ? void 0 : _l.merchants) || [],
|
|
30
30
|
editorAuthorizations: props.fields.editorAuthorizations.selectedValue,
|
|
31
|
-
rfidTag:
|
|
31
|
+
rfidTag: props.fields.rfidTag.inputValue || '',
|
|
32
32
|
};
|
|
33
33
|
const productFilterAttributes = {
|
|
34
|
-
documentId: (
|
|
34
|
+
documentId: (_m = props.props) === null || _m === void 0 ? void 0 : _m.documentId,
|
|
35
35
|
brand: props.fields.brand.selectedValue,
|
|
36
36
|
clothingSize: props.fields.clothingSize.selectedValues,
|
|
37
37
|
color: props.fields.color.selectedValue,
|
|
@@ -45,10 +45,12 @@ class ProductFromFormState extends ProductFactory_1.default {
|
|
|
45
45
|
productStyle: props.fields.productStyle.selectedValues,
|
|
46
46
|
shoeSize: props.fields.shoeSize.selectedValue,
|
|
47
47
|
measurements: props.fields.measurements.selectedValue || {},
|
|
48
|
+
featuredCollections: props.fields.featuredCollections.selectedValues || [],
|
|
49
|
+
tags: props.fields.tags.selectedValues || [],
|
|
48
50
|
};
|
|
49
51
|
const consignmentAttributes = {
|
|
50
52
|
previousSellers: props.fields.previousSellers.selectedValues,
|
|
51
|
-
sellRequestId: ((
|
|
53
|
+
sellRequestId: ((_o = props.props) === null || _o === void 0 ? void 0 : _o.sellRequestId) || '',
|
|
52
54
|
publishType: props.fields.publishType.selectedValue,
|
|
53
55
|
conditionRemarks: props.fields.conditionRemarks.inputValue,
|
|
54
56
|
productRemarks: props.fields.productRemarks.inputValue,
|
|
@@ -61,20 +63,43 @@ class ProductFromFormState extends ProductFactory_1.default {
|
|
|
61
63
|
nextAvailableSeason: props.fields.nextAvailableSeason.selectedValue,
|
|
62
64
|
notesForProductionTeam: props.fields.notesForProductionTeam.inputValue,
|
|
63
65
|
reviewedBy: props.fields.reviewedBy.selectedValue,
|
|
64
|
-
sellRequestImageUrls: ((
|
|
66
|
+
sellRequestImageUrls: ((_p = props.props) === null || _p === void 0 ? void 0 : _p.sellRequestImageUrls) || [],
|
|
65
67
|
dateSold: props.fields.dateSold.selectedValue || '',
|
|
66
68
|
dateInQualityControl: props.fields.dateInQualityControl.selectedValue || '',
|
|
67
69
|
dateInPendingPublication: props.fields.dateInPendingPublication.selectedValue || '',
|
|
68
70
|
dateListedOnline: props.fields.dateListedOnline.selectedValue || '',
|
|
69
71
|
salesChannel: props.fields.salesChannel.selectedValues || [],
|
|
70
72
|
sizeComment: props.fields.sizeComment.selectedValue,
|
|
71
|
-
salePrice: ((
|
|
73
|
+
salePrice: ((_q = props.props) === null || _q === void 0 ? void 0 : _q.salePrice) || '',
|
|
72
74
|
isOnSale: props.fields.isOnSale.selectedValue || '',
|
|
73
75
|
discountType: props.fields.discountType.selectedValue || '',
|
|
74
76
|
discountValue: props.fields.discountValue.inputValue || '',
|
|
75
|
-
selectedForClearance: ((
|
|
77
|
+
selectedForClearance: ((_r = props.props) === null || _r === void 0 ? void 0 : _r.selectedForClearance) || '',
|
|
78
|
+
locationIds: props.fields.locationIds.selectedValues || [],
|
|
76
79
|
};
|
|
77
|
-
|
|
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));
|
|
78
103
|
}
|
|
79
104
|
}
|
|
80
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;
|
|
@@ -6,9 +6,11 @@ export default class RefundFormState extends FormState {
|
|
|
6
6
|
constructor(props?: any);
|
|
7
7
|
createRefund(): Refund;
|
|
8
8
|
updateTotalRefunded(): void;
|
|
9
|
+
getUpdatedRefundLineItem(lineItem: ReRobeOrderLineItem, quantityRefund: number | string, quantityCancel: number | string, unitOrderDiscountAmount: number): RefundLineItem;
|
|
9
10
|
refundLineItemChangeHandler(val: {
|
|
10
11
|
lineItemLike: ReRobeOrderLineItem | RefundLineItem;
|
|
11
|
-
|
|
12
|
+
quantityRefund: number | string;
|
|
13
|
+
quantityCancel: number | string;
|
|
12
14
|
unitOrderDiscount: number;
|
|
13
15
|
}): void;
|
|
14
16
|
private fieldFactory;
|
|
@@ -25,54 +25,49 @@ class RefundFormState extends FormState_1.default {
|
|
|
25
25
|
Number(this.fields.refundShipping.inputValue) +
|
|
26
26
|
Number(this.fields.totalTax.inputValue)).toFixed(2);
|
|
27
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
|
+
}
|
|
28
45
|
refundLineItemChangeHandler(val) {
|
|
29
|
-
var _a, _b;
|
|
30
46
|
const currentLineItems = this.fields.refundLineItems.selectedValues;
|
|
31
47
|
const unitOrderDiscountAmount = val.unitOrderDiscount || 0;
|
|
32
48
|
// Add new product to line items
|
|
33
49
|
if (val.lineItemLike.productId) {
|
|
34
50
|
const lineItem = val.lineItemLike;
|
|
35
|
-
const
|
|
36
|
-
|
|
37
|
-
const subtotalLineItem = Number(Number((_a = lineItem.originalUnitPrice) === null || _a === void 0 ? void 0 : _a.amount) * quantity);
|
|
38
|
-
const lineItemToUpdate = {
|
|
39
|
-
lineItem,
|
|
40
|
-
quantityRefund: quantity,
|
|
41
|
-
discountRefund: Object.assign(Object.assign({}, lineItem.originalUnitPrice), { amount: discountRefundAmount }),
|
|
42
|
-
subtotalRefund: Object.assign(Object.assign({}, lineItem.originalUnitPrice), { amount: subtotalLineItem - discountRefundAmount }),
|
|
43
|
-
};
|
|
44
|
-
this.fields.refundLineItems.selectedValues = [...currentLineItems, lineItemToUpdate];
|
|
51
|
+
const newRefundLineItem = this.getUpdatedRefundLineItem(lineItem, val.quantityRefund, val.quantityCancel, unitOrderDiscountAmount);
|
|
52
|
+
this.fields.refundLineItems.selectedValues = [...currentLineItems, newRefundLineItem];
|
|
45
53
|
}
|
|
46
54
|
// Update quantity of a line item
|
|
47
|
-
if (val.
|
|
55
|
+
if ((val.quantityRefund || val.quantityCancel) && val.lineItemLike.lineItem) {
|
|
48
56
|
const refundLineItem = val.lineItemLike;
|
|
49
|
-
const
|
|
50
|
-
const
|
|
51
|
-
const subtotalLineItem = Number(Number((_b = refundLineItem.lineItem.originalUnitPrice) === null || _b === void 0 ? void 0 : _b.amount) * quantity);
|
|
52
|
-
const updatedLineItem = {
|
|
53
|
-
lineItem: refundLineItem.lineItem,
|
|
54
|
-
quantityRefund: quantity,
|
|
55
|
-
discountRefund: Object.assign(Object.assign({}, refundLineItem.lineItem.originalTotalPrice), { amount: discountRefundAmount }),
|
|
56
|
-
subtotalRefund: Object.assign(Object.assign({}, refundLineItem.lineItem.originalTotalPrice), { amount: subtotalLineItem }),
|
|
57
|
-
};
|
|
57
|
+
const { lineItem, quantityRefund: prevQuantityRefund, quantityCancel: prevQuantityCancel } = refundLineItem;
|
|
58
|
+
const updatedRefundLineItem = this.getUpdatedRefundLineItem(lineItem, val.quantityRefund || prevQuantityRefund, val.quantityCancel || prevQuantityCancel, unitOrderDiscountAmount);
|
|
58
59
|
const lineItemToUpdateIndex = currentLineItems.findIndex((li) => li.lineItem.productId === refundLineItem.lineItem.productId);
|
|
59
60
|
const lineItemsClone = [...currentLineItems];
|
|
60
|
-
lineItemsClone.splice(lineItemToUpdateIndex, 1,
|
|
61
|
+
lineItemsClone.splice(lineItemToUpdateIndex, 1, updatedRefundLineItem);
|
|
61
62
|
this.fields.refundLineItems.selectedValues = lineItemsClone;
|
|
62
63
|
}
|
|
63
|
-
// Remove a line item
|
|
64
|
-
if (val.lineItemLike.quantityRefund && !val.quantity) {
|
|
65
|
-
const refundLineItem = val.lineItemLike;
|
|
66
|
-
const newLineItems = currentLineItems.filter((li) => li.lineItem.productId !== refundLineItem.lineItem.productId);
|
|
67
|
-
this.fields.refundLineItems.selectedValues = newLineItems;
|
|
68
|
-
}
|
|
69
64
|
// Update discount price
|
|
70
65
|
this.fields.refundDiscount.inputValue = this.fields.refundLineItems.selectedValues
|
|
71
66
|
.map((item) => { var _a; return Number((_a = item.discountRefund) === null || _a === void 0 ? void 0 : _a.amount); })
|
|
72
67
|
.reduce((a, b) => a + b, 0);
|
|
73
68
|
// Update subtotal price
|
|
74
69
|
this.fields.subtotalRefunded.inputValue = this.fields.refundLineItems.selectedValues
|
|
75
|
-
.map((item) => { var _a; return Number((_a = item.
|
|
70
|
+
.map((item) => { var _a; return Number(Number((_a = item.lineItem.originalUnitPrice) === null || _a === void 0 ? void 0 : _a.amount) * (item.quantityRefund + item.quantityCancel)); })
|
|
76
71
|
.reduce((a, b) => a + b, 0);
|
|
77
72
|
// Update total price
|
|
78
73
|
this.updateTotalRefunded();
|
|
@@ -3,7 +3,13 @@ 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;
|
|
@@ -5,9 +5,10 @@ const options_1 = require("./options");
|
|
|
5
5
|
const Product_1 = require("../../models/Product");
|
|
6
6
|
const ProductFromFormState_1 = require("../../factories/Product/ProductFromFormState");
|
|
7
7
|
class ProductFormState extends FormState_1.default {
|
|
8
|
-
constructor(props) {
|
|
8
|
+
constructor(props, opts) {
|
|
9
9
|
super();
|
|
10
10
|
this.props = new Product_1.default(props).toObj();
|
|
11
|
+
this.opts = opts;
|
|
11
12
|
// ProductAttributesFormFields
|
|
12
13
|
this.fields.availableForSale = this.fieldFactory('singleSelect', 'availableForSale', options_1.availableForSaleOptions);
|
|
13
14
|
this.fields.description = this.fieldFactory('textInput', 'description');
|
|
@@ -68,6 +69,10 @@ class ProductFormState extends FormState_1.default {
|
|
|
68
69
|
this.fields.editorAuthorizations = this.fieldFactory('singleSelect', 'editorAuthorizations', Object.keys(new Product_1.default().toObj()).map((v) => ({ label: this.utilities.startCase(v), value: v })));
|
|
69
70
|
this.fields.vendorId = this.fieldFactory('singleSelect', 'vendorId');
|
|
70
71
|
this.fields.vendorName = this.fieldFactory('singleSelect', 'vendorName');
|
|
72
|
+
this.fields.rfidTag = this.fieldFactory('textInput', 'rfidTag');
|
|
73
|
+
this.fields.locationIds = this.fieldFactory('multiSelect', 'locationIds');
|
|
74
|
+
this.fields.featuredCollections = this.fieldFactory('multiSelect', 'featuredCollections');
|
|
75
|
+
this.fields.tags = this.fieldFactory('multiSelect', 'tags');
|
|
71
76
|
}
|
|
72
77
|
autoCreateTitle() {
|
|
73
78
|
return this.createProduct().autoCreateTitle();
|
|
@@ -505,6 +510,21 @@ class ProductFormState extends FormState_1.default {
|
|
|
505
510
|
}
|
|
506
511
|
hidden = this.props.productStyle.length < 1;
|
|
507
512
|
}
|
|
513
|
+
if (fieldKey === 'tags') {
|
|
514
|
+
if (this.props.tags && Array.isArray(this.props.tags) && this.props.tags.length > 0) {
|
|
515
|
+
this.props.tags.forEach((tag) => {
|
|
516
|
+
if (!options.map((o) => o.value).includes(tag)) {
|
|
517
|
+
options.splice(0, 0, { label: tag, value: tag });
|
|
518
|
+
}
|
|
519
|
+
});
|
|
520
|
+
}
|
|
521
|
+
hidden = Boolean(this.props.tags && Array.isArray(this.props.tags) && this.props.tags.length < 1);
|
|
522
|
+
}
|
|
523
|
+
if (fieldKey === 'featuredCollections') {
|
|
524
|
+
if (this.opts && this.opts.featuredCollectionOpts && this.opts.featuredCollectionOpts.length > 0) {
|
|
525
|
+
options = this.utilities.uniqObjArray([...options, ...this.opts.featuredCollectionOpts.map((o) => ({ label: o.label, value: o.value }))], 'value');
|
|
526
|
+
}
|
|
527
|
+
}
|
|
508
528
|
if (fieldKey === 'clothingSize') {
|
|
509
529
|
if (this.props.gender === 'Woman') {
|
|
510
530
|
options = [
|
|
@@ -604,7 +624,7 @@ class ProductFormState extends FormState_1.default {
|
|
|
604
624
|
onChangeHandler = (val) => this.priceInputChangeHandler(val);
|
|
605
625
|
}
|
|
606
626
|
if (fieldKey === 'reRobeCommission') {
|
|
607
|
-
inputValue = this.props[fieldKey] || '0.
|
|
627
|
+
inputValue = this.props[fieldKey] || '0.5';
|
|
608
628
|
valid = true;
|
|
609
629
|
}
|
|
610
630
|
if (fieldKey === 'discountValue') {
|