rerobe-js-orm 2.9.7 → 2.9.9
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/Order/OrderFromFormState.d.ts +0 -1
- package/lib/factories/Order/OrderFromFormState.js +24 -40
- package/lib/form-states/FormState.d.ts +1 -4
- package/lib/form-states/FormState.js +10 -8
- package/lib/form-states/Order/OrderFormState.d.ts +3 -0
- package/lib/form-states/Order/OrderFormState.js +59 -3
- package/lib/helpers/OrderHelpers.js +1 -1
- package/lib/helpers/Utilities.d.ts +1 -0
- package/lib/helpers/Utilities.js +9 -0
- package/lib/models/Order.d.ts +3 -0
- package/lib/models/Order.js +12 -0
- package/lib/types/merchant-types.d.ts +1 -0
- package/lib/types/rerobe-order-types.d.ts +20 -0
- package/package.json +1 -1
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import OrderFactory from './OrderFactory';
|
|
2
2
|
import OrderFormState from '../../form-states/Order/OrderFormState';
|
|
3
3
|
export default class OrderFromFormState extends OrderFactory {
|
|
4
|
-
getCustomerNameFromOrderFormState(fs: OrderFormState): string;
|
|
5
4
|
createOrder(fs: OrderFormState): ReRobeOrderObj;
|
|
6
5
|
}
|
|
@@ -4,44 +4,25 @@ const OrderFactory_1 = require("./OrderFactory");
|
|
|
4
4
|
const Order_1 = require("../../models/Order");
|
|
5
5
|
const order_constants_1 = require("../../constants/order-constants");
|
|
6
6
|
class OrderFromFormState extends OrderFactory_1.default {
|
|
7
|
-
getCustomerNameFromOrderFormState(fs) {
|
|
8
|
-
var _a, _b;
|
|
9
|
-
const customer = fs.fields.customer.selectedValue || {};
|
|
10
|
-
const firstName = fs.fields.firstName.inputValue;
|
|
11
|
-
const lastName = fs.fields.lastName.inputValue;
|
|
12
|
-
if ((_a = fs.props) === null || _a === void 0 ? void 0 : _a.customerName) {
|
|
13
|
-
return (_b = fs.props) === null || _b === void 0 ? void 0 : _b.customerName;
|
|
14
|
-
}
|
|
15
|
-
if (customer.displayName) {
|
|
16
|
-
return customer.displayName;
|
|
17
|
-
}
|
|
18
|
-
if (customer.firstName || customer.lastName) {
|
|
19
|
-
return `${customer.firstName} ${customer.lastName}`.trim();
|
|
20
|
-
}
|
|
21
|
-
if (firstName || lastName) {
|
|
22
|
-
return `${firstName} ${lastName}`.trim();
|
|
23
|
-
}
|
|
24
|
-
return '';
|
|
25
|
-
}
|
|
26
7
|
createOrder(fs) {
|
|
27
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u;
|
|
8
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v;
|
|
28
9
|
const currencyCode = fs.fields.currencyCode.inputValue || 'SEK';
|
|
29
10
|
const customer = fs.fields.customer.selectedValue || {};
|
|
30
11
|
const customerAttr = {
|
|
31
|
-
userId: (customer === null || customer === void 0 ? void 0 : customer.uid) || '',
|
|
32
|
-
customerName:
|
|
33
|
-
email:
|
|
34
|
-
phone:
|
|
35
|
-
customerUrl: ((
|
|
12
|
+
userId: (customer === null || customer === void 0 ? void 0 : customer.uid) || (customer === null || customer === void 0 ? void 0 : customer.documentId) || '',
|
|
13
|
+
customerName: ((_a = fs.props) === null || _a === void 0 ? void 0 : _a.customerName) || `${fs.fields.firstName.inputValue} ${fs.fields.lastName.inputValue}`.trim(),
|
|
14
|
+
email: fs.fields.email.inputValue || '',
|
|
15
|
+
phone: fs.fields.phone.inputValue || '',
|
|
16
|
+
customerUrl: ((_b = fs.props) === null || _b === void 0 ? void 0 : _b.customerUrl) || '',
|
|
36
17
|
};
|
|
37
18
|
const discountsAttr = {
|
|
38
19
|
appliedDiscount: {
|
|
39
|
-
amount: ((
|
|
40
|
-
value: ((
|
|
41
|
-
title: ((
|
|
20
|
+
amount: ((_c = fs.fields) === null || _c === void 0 ? void 0 : _c.totalDiscount.inputValue) || 0,
|
|
21
|
+
value: ((_d = fs.fields) === null || _d === void 0 ? void 0 : _d.totalDiscount.inputValue) || 0,
|
|
22
|
+
title: fs.fields.presentmentData.selectedValue.discountTitlePresentment || ((_e = fs.fields) === null || _e === void 0 ? void 0 : _e.discountTitle.inputValue) || '',
|
|
42
23
|
valueType: 'FIXED_AMOUNT',
|
|
43
24
|
},
|
|
44
|
-
discountApplications: ((
|
|
25
|
+
discountApplications: ((_f = fs.props) === null || _f === void 0 ? void 0 : _f.discountApplications) || [],
|
|
45
26
|
creditDiscount: { amount: fs.fields.creditDiscount.inputValue || 0, currencyCode },
|
|
46
27
|
saleDiscount: { amount: fs.fields.saleDiscount.inputValue || 0, currencyCode },
|
|
47
28
|
additionalDiscount: { amount: fs.fields.additionalDiscount.inputValue || 0, currencyCode },
|
|
@@ -57,11 +38,11 @@ class OrderFromFormState extends OrderFactory_1.default {
|
|
|
57
38
|
zip: '',
|
|
58
39
|
};
|
|
59
40
|
const shippingAndLocationAttr = {
|
|
60
|
-
fulfillmentLocations: ((
|
|
41
|
+
fulfillmentLocations: ((_g = fs.fields.shippingInfo.selectedValue) === null || _g === void 0 ? void 0 : _g.productsLocationsMapping) || [],
|
|
61
42
|
shippingAddress: fs.fields.shippingType.selectedValue === order_constants_1.SHIPPING_TYPES.localPickUp
|
|
62
43
|
? initShippingAddress
|
|
63
44
|
: fs.fields.shippingAddress.selectedValue || initShippingAddress,
|
|
64
|
-
shippingDiscountAllocations: ((
|
|
45
|
+
shippingDiscountAllocations: ((_h = fs.props) === null || _h === void 0 ? void 0 : _h.shippingDiscountAllocations) || [],
|
|
65
46
|
shippingLine: fs.fields.shippingLine
|
|
66
47
|
? fs.fields.shippingLine.selectedValue
|
|
67
48
|
: {
|
|
@@ -90,12 +71,15 @@ class OrderFromFormState extends OrderFactory_1.default {
|
|
|
90
71
|
},
|
|
91
72
|
};
|
|
92
73
|
const presentmentTotalPricesAttr = {
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
74
|
+
creditDiscountPresentment: fs.fields.presentmentData.selectedValue.creditDiscountPresentment,
|
|
75
|
+
saleDiscountPresentment: fs.fields.presentmentData.selectedValue.saleDiscountPresentment,
|
|
76
|
+
additionalDiscountPresentment: fs.fields.presentmentData.selectedValue.additionalDiscountPresentment,
|
|
77
|
+
subtotalPricePresentment: fs.fields.presentmentData.selectedValue.subtotalPricePresentment,
|
|
78
|
+
totalDiscountPresentment: fs.fields.presentmentData.selectedValue.totalDiscountPresentment,
|
|
79
|
+
totalPricePresentment: fs.fields.presentmentData.selectedValue.totalPricePresentment,
|
|
80
|
+
totalRefundedPresentment: fs.fields.presentmentData.selectedValue.totalRefundedPresentment,
|
|
81
|
+
totalShippingPricePresentment: fs.fields.presentmentData.selectedValue.totalShippingPricePresentment,
|
|
82
|
+
totalTaxPresentment: fs.fields.presentmentData.selectedValue.totalTaxPresentment,
|
|
99
83
|
};
|
|
100
84
|
const totalPricesAttr = {
|
|
101
85
|
subtotalPrice: { amount: fs.fields.subtotalPrice.inputValue || 0, currencyCode },
|
|
@@ -109,12 +93,12 @@ class OrderFromFormState extends OrderFactory_1.default {
|
|
|
109
93
|
originalTotalPrice: { amount: fs.fields.originalTotalPrice.inputValue || 0, currencyCode },
|
|
110
94
|
};
|
|
111
95
|
const statusesAttr = {
|
|
112
|
-
state: ((
|
|
96
|
+
state: ((_j = fs.props) === null || _j === void 0 ? void 0 : _j.state) || Order_1.default.ORDER_STATES.draft,
|
|
113
97
|
financialStatus: fs.fields.financialStatus.selectedValue,
|
|
114
98
|
fulfillmentStatus: fs.fields.fulfillmentStatus.selectedValue,
|
|
115
|
-
statusUrl: ((
|
|
99
|
+
statusUrl: ((_k = fs.props) === null || _k === void 0 ? void 0 : _k.statusUrl) || '',
|
|
116
100
|
};
|
|
117
|
-
const orderAttributes = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, totalPricesAttr), presentmentTotalPricesAttr), discountsAttr), shippingAndLocationAttr), customerAttr), statusesAttr), { id: ((
|
|
101
|
+
const orderAttributes = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, totalPricesAttr), presentmentTotalPricesAttr), discountsAttr), shippingAndLocationAttr), customerAttr), statusesAttr), { id: ((_l = fs.props) === null || _l === void 0 ? void 0 : _l.id) || '', documentId: ((_m = fs.props) === null || _m === void 0 ? void 0 : _m.documentId) || '', name: ((_o = fs.props) === null || _o === void 0 ? void 0 : _o.name) || '', orderNumber: (_p = fs.props) === null || _p === void 0 ? void 0 : _p.orderNumber, ribbnOrderNumber: (_q = fs.props) === null || _q === void 0 ? void 0 : _q.ribbnOrderNumber, merchantId: ((_r = fs.props) === null || _r === void 0 ? void 0 : _r.merchantId) || '', currencyCode: fs.fields.currencyCode.inputValue, lineItems: fs.fields.lineItems.selectedValues || [], fulfillments: ((_s = fs.props) === null || _s === void 0 ? void 0 : _s.fulfillments) || [], refunds: ((_t = fs.props) === null || _t === void 0 ? void 0 : _t.refunds) || [], paymentType: fs.fields.paymentType.selectedValue, paymentMethod: fs.fields.paymentMethod.selectedValue || '', paymentDetails: fs.fields.paymentDetails.selectedValue || {}, notes: fs.fields.notes.inputValue || '', tags: fs.fields.tags.selectedValues || [], cancelReason: fs.fields.cancelReason.selectedValue || '', canceledAt: ((_u = fs.props) === null || _u === void 0 ? void 0 : _u.canceledAt) || '', processedAt: ((_v = fs.props) === null || _v === void 0 ? void 0 : _v.processedAt) || new Date().toUTCString(), createdAtTimestamp: 0, updatedAtTimestamp: 0 });
|
|
118
102
|
return new Order_1.default(Object.assign({}, orderAttributes));
|
|
119
103
|
}
|
|
120
104
|
}
|
|
@@ -9,10 +9,7 @@ export default abstract class FormState extends Base {
|
|
|
9
9
|
onAddNewOptionToFormFieldOptions(key: keyof FormStateObject, option: FormFieldOption): void;
|
|
10
10
|
onSetNewFormFieldOptions(key: keyof FormStateObject, options: FormFieldOption[]): void;
|
|
11
11
|
editExistingOption(key: keyof FormStateObject, oldOptionValue: string, option: FormFieldOption): void;
|
|
12
|
-
|
|
13
|
-
[key: string]: string | number | null;
|
|
14
|
-
}): void;
|
|
15
|
-
setSingleSelectFormStateFields(formStateSlice: {
|
|
12
|
+
setFormStateFields(formStateSlice: {
|
|
16
13
|
[key: string]: any;
|
|
17
14
|
}): void;
|
|
18
15
|
}
|
|
@@ -50,16 +50,18 @@ class FormState extends Base_1.default {
|
|
|
50
50
|
formField.options[existingOptionIndex] = option;
|
|
51
51
|
}
|
|
52
52
|
}
|
|
53
|
-
|
|
53
|
+
setFormStateFields(formStateSlice) {
|
|
54
54
|
Object.keys(formStateSlice).forEach((key) => {
|
|
55
55
|
const field = this.fields[key];
|
|
56
|
-
field
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
field
|
|
56
|
+
if (field && Object.keys(field).includes('inputValue')) {
|
|
57
|
+
field.inputValue = formStateSlice[key] || '';
|
|
58
|
+
}
|
|
59
|
+
if (field && Object.keys(field).includes('selectedValue')) {
|
|
60
|
+
field.selectedValue = formStateSlice[key] || {};
|
|
61
|
+
}
|
|
62
|
+
if (field && Object.keys(field).includes('selectedValues')) {
|
|
63
|
+
field.selectedValues = formStateSlice[key] || [];
|
|
64
|
+
}
|
|
63
65
|
});
|
|
64
66
|
}
|
|
65
67
|
}
|
|
@@ -6,6 +6,8 @@ export default class OrderFormState extends FormState {
|
|
|
6
6
|
props: CompleteOrder;
|
|
7
7
|
opts: {
|
|
8
8
|
tagOptions: string[];
|
|
9
|
+
shippingTypeOptions: FormFieldOption[];
|
|
10
|
+
pickupLocationOptions: FormFieldOption[];
|
|
9
11
|
};
|
|
10
12
|
orderHelpers: OrderHelpers;
|
|
11
13
|
constructor(props?: any, opts?: any);
|
|
@@ -16,5 +18,6 @@ export default class OrderFormState extends FormState {
|
|
|
16
18
|
}): void;
|
|
17
19
|
discountChangeHandler(val: string): void;
|
|
18
20
|
shippingPriceChangeHandler(val: string): void;
|
|
21
|
+
customerChangeHandler(customer: UserAttributes): void;
|
|
19
22
|
private fieldFactory;
|
|
20
23
|
}
|
|
@@ -5,6 +5,7 @@ const Order_1 = require("../../models/Order");
|
|
|
5
5
|
const OrderFromFormState_1 = require("../../factories/Order/OrderFromFormState");
|
|
6
6
|
const OrderHelpers_1 = require("../../helpers/OrderHelpers");
|
|
7
7
|
const options_1 = require("./options");
|
|
8
|
+
const order_constants_1 = require("../../constants/order-constants");
|
|
8
9
|
class OrderFormState extends FormState_1.default {
|
|
9
10
|
constructor(props, opts) {
|
|
10
11
|
super();
|
|
@@ -45,6 +46,7 @@ class OrderFormState extends FormState_1.default {
|
|
|
45
46
|
this.fields.additionalDiscount = this.fieldFactory('textInput', 'additionalDiscount');
|
|
46
47
|
this.fields.shippingInfo = this.fieldFactory('singleSelect', 'shippingInfo');
|
|
47
48
|
this.fields.pickupLocation = this.fieldFactory('singleSelect', 'pickupLocation');
|
|
49
|
+
this.fields.presentmentData = this.fieldFactory('singleSelect', 'presentmentData');
|
|
48
50
|
}
|
|
49
51
|
createOrder() {
|
|
50
52
|
const orderFactory = new OrderFromFormState_1.default();
|
|
@@ -95,7 +97,15 @@ class OrderFormState extends FormState_1.default {
|
|
|
95
97
|
// Update total price
|
|
96
98
|
this.fields.totalPrice.inputValue = Number(Number(this.fields.subtotalPrice.inputValue) - Number(this.fields.totalDiscount.inputValue) + Number(val)).toFixed(2);
|
|
97
99
|
}
|
|
100
|
+
customerChangeHandler(customer) {
|
|
101
|
+
this.fields.customer.selectedValue = customer;
|
|
102
|
+
this.fields.email.inputValue = (customer === null || customer === void 0 ? void 0 : customer.email) || '';
|
|
103
|
+
this.fields.phone.inputValue = (customer === null || customer === void 0 ? void 0 : customer.phone) || '';
|
|
104
|
+
this.fields.firstName.inputValue = (customer === null || customer === void 0 ? void 0 : customer.displayName) || (customer === null || customer === void 0 ? void 0 : customer.firstName) || '';
|
|
105
|
+
this.fields.lastName.inputValue = !(customer === null || customer === void 0 ? void 0 : customer.displayName) && (customer === null || customer === void 0 ? void 0 : customer.lastName) ? customer === null || customer === void 0 ? void 0 : customer.lastName : '';
|
|
106
|
+
}
|
|
98
107
|
fieldFactory(fieldType, fieldKey, fieldOptions) {
|
|
108
|
+
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;
|
|
99
109
|
let options = fieldOptions || [];
|
|
100
110
|
const hidden = false;
|
|
101
111
|
if (fieldType === 'textInput') {
|
|
@@ -106,6 +116,9 @@ class OrderFormState extends FormState_1.default {
|
|
|
106
116
|
if (fieldKey === 'lastName') {
|
|
107
117
|
inputValue = this.props.name && this.props.name.split(' ').length > 1 ? this.props.name.split(' ')[1] : '';
|
|
108
118
|
}
|
|
119
|
+
if (fieldKey === 'discountTitle') {
|
|
120
|
+
inputValue = ((_b = (_a = this.props) === null || _a === void 0 ? void 0 : _a.appliedDiscount) === null || _b === void 0 ? void 0 : _b.title) || '';
|
|
121
|
+
}
|
|
109
122
|
if (fieldKey === 'subtotalPrice' ||
|
|
110
123
|
fieldKey === 'totalPrice' ||
|
|
111
124
|
fieldKey === 'totalDiscount' ||
|
|
@@ -116,7 +129,8 @@ class OrderFormState extends FormState_1.default {
|
|
|
116
129
|
fieldKey === 'creditDiscount' ||
|
|
117
130
|
fieldKey === 'saleDiscount' ||
|
|
118
131
|
fieldKey === 'additionalDiscount' ||
|
|
119
|
-
fieldKey === 'subTotalWithShipping'
|
|
132
|
+
fieldKey === 'subTotalWithShipping' ||
|
|
133
|
+
fieldKey === 'subTotalWithSalePriceIncluded') {
|
|
120
134
|
// @ts-ignore
|
|
121
135
|
inputValue = this.props[fieldKey] ? this.props[fieldKey].amount : 0;
|
|
122
136
|
}
|
|
@@ -136,15 +150,57 @@ class OrderFormState extends FormState_1.default {
|
|
|
136
150
|
}
|
|
137
151
|
if (fieldType === 'singleSelect') {
|
|
138
152
|
let selectedValue = this.props[fieldKey] || '';
|
|
153
|
+
if (fieldKey === 'pickupLocation') {
|
|
154
|
+
if (((_c = this.props) === null || _c === void 0 ? void 0 : _c.shippingType) === order_constants_1.SHIPPING_TYPES.localPickUp &&
|
|
155
|
+
((_d = this.props) === null || _d === void 0 ? void 0 : _d.fulfillmentLocations) &&
|
|
156
|
+
((_e = this.props.fulfillmentLocations[0]) === null || _e === void 0 ? void 0 : _e.location)) {
|
|
157
|
+
const location = this.props.fulfillmentLocations[0].location;
|
|
158
|
+
const locationId = location.locationId || location.documentId || '';
|
|
159
|
+
selectedValue = locationId;
|
|
160
|
+
options = [{ label: location.address1 ? this.utilities.getAddressLabel(location) : '', value: locationId }];
|
|
161
|
+
}
|
|
162
|
+
if ((_g = (_f = this.opts) === null || _f === void 0 ? void 0 : _f.pickupLocationOptions) === null || _g === void 0 ? void 0 : _g.length) {
|
|
163
|
+
options = this.utilities.uniqObjArray([...options, ...this.opts.pickupLocationOptions], 'value');
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
if (fieldKey === 'shippingInfo') {
|
|
167
|
+
selectedValue = {
|
|
168
|
+
productsLocationsMapping: ((_h = this.props) === null || _h === void 0 ? void 0 : _h.fulfillmentLocations) || [],
|
|
169
|
+
description: '',
|
|
170
|
+
price: ((_k = (_j = this.props) === null || _j === void 0 ? void 0 : _j.totalShippingPrice) === null || _k === void 0 ? void 0 : _k.amount) || 0,
|
|
171
|
+
disabled: false,
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
if (fieldKey === 'presentmentData') {
|
|
175
|
+
selectedValue = {
|
|
176
|
+
presentmentCurrencyCode: ((_m = (_l = this.props) === null || _l === void 0 ? void 0 : _l.totalPricePresentment) === null || _m === void 0 ? void 0 : _m.currencyCode) || '',
|
|
177
|
+
discountTitlePresentment: ((_p = (_o = this.props) === null || _o === void 0 ? void 0 : _o.appliedDiscount) === null || _p === void 0 ? void 0 : _p.title) || '',
|
|
178
|
+
subtotalPricePresentment: ((_q = this.props) === null || _q === void 0 ? void 0 : _q.subtotalPricePresentment) || { amount: 0 },
|
|
179
|
+
totalDiscountPresentment: ((_r = this.props) === null || _r === void 0 ? void 0 : _r.totalDiscountPresentment) || { amount: 0 },
|
|
180
|
+
totalShippingPricePresentment: ((_s = this.props) === null || _s === void 0 ? void 0 : _s.totalShippingPricePresentment) || { amount: 0 },
|
|
181
|
+
totalPricePresentment: ((_t = this.props) === null || _t === void 0 ? void 0 : _t.totalPricePresentment) || { amount: 0 },
|
|
182
|
+
totalRefundedPresentment: ((_u = this.props) === null || _u === void 0 ? void 0 : _u.totalRefundedPresentment) || { amount: 0 },
|
|
183
|
+
totalTaxPresentment: ((_v = this.props) === null || _v === void 0 ? void 0 : _v.totalTaxPresentment) || { amount: 0 },
|
|
184
|
+
creditDiscountPresentment: ((_w = this.props) === null || _w === void 0 ? void 0 : _w.creditDiscountPresentment) || { amount: 0 },
|
|
185
|
+
saleDiscountPresentment: ((_x = this.props) === null || _x === void 0 ? void 0 : _x.saleDiscountPresentment) || { amount: 0 },
|
|
186
|
+
additionalDiscountPresentment: ((_y = this.props) === null || _y === void 0 ? void 0 : _y.additionalDiscountPresentment) || { amount: 0 },
|
|
187
|
+
};
|
|
188
|
+
}
|
|
189
|
+
const valid = !!this.props[fieldKey];
|
|
190
|
+
let onChangeHandler = (val) => this.singleSelectChangeHandler(fieldKey, val);
|
|
139
191
|
if (fieldKey === 'customer') {
|
|
140
192
|
selectedValue = {
|
|
141
193
|
uid: this.props.userId,
|
|
142
194
|
email: this.props.email,
|
|
143
195
|
displayName: this.props.customerName,
|
|
144
196
|
};
|
|
197
|
+
onChangeHandler = (val) => this.customerChangeHandler(val);
|
|
198
|
+
}
|
|
199
|
+
if (fieldKey === 'shippingType') {
|
|
200
|
+
if ((_0 = (_z = this.opts) === null || _z === void 0 ? void 0 : _z.shippingTypeOptions) === null || _0 === void 0 ? void 0 : _0.length) {
|
|
201
|
+
options = this.utilities.uniqObjArray(this.opts.shippingTypeOptions, 'value');
|
|
202
|
+
}
|
|
145
203
|
}
|
|
146
|
-
const valid = !!this.props[fieldKey];
|
|
147
|
-
const onChangeHandler = (val) => this.singleSelectChangeHandler(fieldKey, val);
|
|
148
204
|
return {
|
|
149
205
|
options,
|
|
150
206
|
hidden,
|
|
@@ -85,7 +85,7 @@ class OrderHelpers {
|
|
|
85
85
|
shopifyProductId: product.shopifyId || null,
|
|
86
86
|
productId: product.documentId,
|
|
87
87
|
status: product.status || '',
|
|
88
|
-
isOnSale: product.isOnSale && product.clearanceTimestamp ? 'yes' : '',
|
|
88
|
+
isOnSale: product.isOnSale === 'yes' && product.clearanceTimestamp ? 'yes' : '',
|
|
89
89
|
salePrice: product.salePrice || '',
|
|
90
90
|
};
|
|
91
91
|
}
|
package/lib/helpers/Utilities.js
CHANGED
|
@@ -128,5 +128,14 @@ class Utilities {
|
|
|
128
128
|
// Capitalize each word and join the words together
|
|
129
129
|
return words.map((word) => word.charAt(0).toUpperCase() + word.slice(1)).join(' ');
|
|
130
130
|
}
|
|
131
|
+
getAddressLabel(address) {
|
|
132
|
+
const { address1 = '', address2 = '', zip = '', city = '', province = '', country = '' } = address;
|
|
133
|
+
return [address1, address2, zip, city, province, country].reduce((res, item) => {
|
|
134
|
+
if (item) {
|
|
135
|
+
return (res === null || res === void 0 ? void 0 : res.length) ? `${res}, ${item}` : item;
|
|
136
|
+
}
|
|
137
|
+
return res;
|
|
138
|
+
}, '');
|
|
139
|
+
}
|
|
131
140
|
}
|
|
132
141
|
exports.default = Utilities;
|
package/lib/models/Order.d.ts
CHANGED
|
@@ -94,6 +94,9 @@ export default class Order extends Base {
|
|
|
94
94
|
totalRefundedPresentment: Money;
|
|
95
95
|
totalShippingPricePresentment: Money;
|
|
96
96
|
totalTaxPresentment: Money;
|
|
97
|
+
creditDiscountPresentment: Money;
|
|
98
|
+
saleDiscountPresentment: Money;
|
|
99
|
+
additionalDiscountPresentment: Money;
|
|
97
100
|
createdAtTimestamp: number;
|
|
98
101
|
updatedAtTimestamp: number;
|
|
99
102
|
constructor(props?: any);
|
package/lib/models/Order.js
CHANGED
|
@@ -115,6 +115,15 @@ class Order extends Base_1.default {
|
|
|
115
115
|
this.totalTaxPresentment = (props === null || props === void 0 ? void 0 : props.totalTaxPresentment) || {
|
|
116
116
|
amount: 0,
|
|
117
117
|
};
|
|
118
|
+
this.creditDiscountPresentment = (props === null || props === void 0 ? void 0 : props.creditDiscountPresentment) || {
|
|
119
|
+
amount: 0,
|
|
120
|
+
};
|
|
121
|
+
this.saleDiscountPresentment = (props === null || props === void 0 ? void 0 : props.saleDiscountPresentment) || {
|
|
122
|
+
amount: 0,
|
|
123
|
+
};
|
|
124
|
+
this.additionalDiscountPresentment = (props === null || props === void 0 ? void 0 : props.additionalDiscountPresentment) || {
|
|
125
|
+
amount: 0,
|
|
126
|
+
};
|
|
118
127
|
this.createdAtTimestamp = (props === null || props === void 0 ? void 0 : props.createdAtTimestamp) || 0;
|
|
119
128
|
this.updatedAtTimestamp = (props === null || props === void 0 ? void 0 : props.updatedAtTimestamp) || 0;
|
|
120
129
|
}
|
|
@@ -173,6 +182,9 @@ class Order extends Base_1.default {
|
|
|
173
182
|
totalRefundedPresentment: this.totalRefundedPresentment,
|
|
174
183
|
totalShippingPricePresentment: this.totalShippingPricePresentment,
|
|
175
184
|
totalTaxPresentment: this.totalTaxPresentment,
|
|
185
|
+
creditDiscountPresentment: this.creditDiscountPresentment,
|
|
186
|
+
saleDiscountPresentment: this.saleDiscountPresentment,
|
|
187
|
+
additionalDiscountPresentment: this.additionalDiscountPresentment,
|
|
176
188
|
createdAtTimestamp: this.createdAtTimestamp,
|
|
177
189
|
updatedAtTimestamp: this.updatedAtTimestamp,
|
|
178
190
|
};
|
|
@@ -74,6 +74,9 @@ declare type ReRobeOrderObj = {
|
|
|
74
74
|
totalRefundedPresentment?: Money;
|
|
75
75
|
totalShippingPricePresentment?: Money;
|
|
76
76
|
totalTaxPresentment?: Money;
|
|
77
|
+
creditDiscountPresentment?: Money;
|
|
78
|
+
saleDiscountPresentment?: Money;
|
|
79
|
+
additionalDiscountPresentment?: Money;
|
|
77
80
|
createdAtTimestamp: number;
|
|
78
81
|
updatedAtTimestamp: number;
|
|
79
82
|
};
|
|
@@ -229,6 +232,9 @@ interface ReRobeOrderLineItem extends OrderLineItem {
|
|
|
229
232
|
status?: ProductSellStatusKeys | string;
|
|
230
233
|
isOnSale?: string;
|
|
231
234
|
salePrice?: string;
|
|
235
|
+
presentmentTotalPrice?: Money;
|
|
236
|
+
presentmentUnitPrice?: Money;
|
|
237
|
+
presentmentSalePrice?: Money;
|
|
232
238
|
}
|
|
233
239
|
declare type OrderLineItemConnection = {
|
|
234
240
|
edges: OrderLineItemEdge[];
|
|
@@ -664,6 +670,19 @@ declare type OrderShippingInfo = {
|
|
|
664
670
|
disabled: boolean;
|
|
665
671
|
productsLocationsMapping: ProductLocationMapping[];
|
|
666
672
|
};
|
|
673
|
+
declare type OrderPresentmentData = {
|
|
674
|
+
presentmentCurrencyCode?: string;
|
|
675
|
+
discountTitlePresentment?: string;
|
|
676
|
+
subtotalPricePresentment: Money;
|
|
677
|
+
totalDiscountPresentment: Money;
|
|
678
|
+
totalShippingPricePresentment: Money;
|
|
679
|
+
totalPricePresentment: Money;
|
|
680
|
+
totalRefundedPresentment?: Money;
|
|
681
|
+
totalTaxPresentment?: Money;
|
|
682
|
+
creditDiscountPresentment?: Money;
|
|
683
|
+
saleDiscountPresentment?: Money;
|
|
684
|
+
additionalDiscountPresentment?: Money;
|
|
685
|
+
};
|
|
667
686
|
declare type CompleteOrder = ReRobeOrderObj & {
|
|
668
687
|
[key: string]: any;
|
|
669
688
|
};
|
|
@@ -711,6 +730,7 @@ declare type OrderAttributesFormFields = {
|
|
|
711
730
|
additionalDiscount: TextInputFormField<string | number>;
|
|
712
731
|
shippingInfo: SingleSelectFormField<OrderShippingInfo>;
|
|
713
732
|
pickupLocation: SingleSelectFormField<string>;
|
|
733
|
+
presentmentData: SingleSelectFormField<OrderPresentmentData>;
|
|
714
734
|
};
|
|
715
735
|
declare type OrderRefundFormFields = {
|
|
716
736
|
totalRefunded: TextInputFormField<string | number>;
|