rerobe-js-orm 3.0.27 → 3.0.29
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.js +1 -1
- package/lib/factories/Order/OrderToShipmondo.d.ts +0 -0
- package/lib/factories/Order/OrderToShipmondo.js +53 -0
- package/lib/form-states/Order/OrderFormState.d.ts +1 -0
- package/lib/form-states/Order/OrderFormState.js +19 -1
- package/lib/types/rerobe-order-types.d.ts +1 -0
- package/package.json +1 -1
|
@@ -93,7 +93,7 @@ class OrderFromFormState extends OrderFactory_1.default {
|
|
|
93
93
|
originalTotalPrice: { amount: fs.fields.originalTotalPrice.inputValue || 0, currencyCode },
|
|
94
94
|
};
|
|
95
95
|
const statusesAttr = {
|
|
96
|
-
state: ((_h = fs.
|
|
96
|
+
state: ((_h = fs.fields) === null || _h === void 0 ? void 0 : _h.state.selectedValue) || Order_1.default.ORDER_STATES.draft,
|
|
97
97
|
financialStatus: fs.fields.financialStatus.selectedValue,
|
|
98
98
|
fulfillmentStatus: fs.fields.fulfillmentStatus.selectedValue,
|
|
99
99
|
statusUrl: ((_j = fs.props) === null || _j === void 0 ? void 0 : _j.statusUrl) || '',
|
|
File without changes
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// import OrderFactory from './OrderFactory';
|
|
3
|
+
// import Order from '../../models/Order';
|
|
4
|
+
// import OrderHelpers from '../../helpers/OrderHelpers';
|
|
5
|
+
// const orderHelpers: OrderHelpers = new OrderHelpers();
|
|
6
|
+
// export default class OrderToShipmondo extends OrderFactory {
|
|
7
|
+
// createOrder(order: ReRobeOrderObj): any {
|
|
8
|
+
// const { amount, currencyCode } = {
|
|
9
|
+
// amount: order.originalTotalPrice?.amount ?? 0,
|
|
10
|
+
// currencyCode: order.originalTotalPrice?.currencyCode ?? '',
|
|
11
|
+
// };
|
|
12
|
+
// const taxAmount = order.totalTax?.amount ?? 0;
|
|
13
|
+
// const shipmondoOrder = {
|
|
14
|
+
// order_id: order.orderNumber,
|
|
15
|
+
// ship_to: {
|
|
16
|
+
// name: '',
|
|
17
|
+
// address1: order.shippingAddress?.address1,
|
|
18
|
+
// zipcode: order.shippingAddress?.zip,
|
|
19
|
+
// city: order.shippingAddress?.zip,
|
|
20
|
+
// country_code: order.shippingAddress?.countryCode,
|
|
21
|
+
// },
|
|
22
|
+
// // bill_to: {
|
|
23
|
+
// // name,
|
|
24
|
+
// // address1: shipping_address,
|
|
25
|
+
// // zipcode: '',
|
|
26
|
+
// // city: '',
|
|
27
|
+
// // country_code: '',
|
|
28
|
+
// // },
|
|
29
|
+
// sender: {
|
|
30
|
+
// // name,
|
|
31
|
+
// // address1: shipping_address,
|
|
32
|
+
// // zipcode: '',
|
|
33
|
+
// // city: '',
|
|
34
|
+
// // country_code: '',
|
|
35
|
+
// },
|
|
36
|
+
// payment_details: {
|
|
37
|
+
// amount_including_vat: +amount + +taxAmount,
|
|
38
|
+
// currency_code: currencyCode,
|
|
39
|
+
// vat_amount: taxAmount,
|
|
40
|
+
// },
|
|
41
|
+
// order_lines: order.lineItems.map((item: ReRobeOrderLineItem) => ({
|
|
42
|
+
// line_type: 'item',
|
|
43
|
+
// item_name: item.title,
|
|
44
|
+
// quantity: item.quantity,
|
|
45
|
+
// unit_price_excluding_vat: item.presentmentUnitPrice?.amount,
|
|
46
|
+
// discount_amount_excluding_vat: item.discountedTotalPrice?.amount,
|
|
47
|
+
// currency_code: item.presentmentUnitPrice?.currencyCode || item.discountedTotalPrice?.currencyCode,
|
|
48
|
+
// image_url: item.image?.originalSrc,
|
|
49
|
+
// })),
|
|
50
|
+
// };
|
|
51
|
+
// return shipmondoOrder;
|
|
52
|
+
// }
|
|
53
|
+
// }
|
|
@@ -47,6 +47,7 @@ class OrderFormState extends FormState_1.default {
|
|
|
47
47
|
this.fields.shippingInfo = this.fieldFactory('singleSelect', 'shippingInfo');
|
|
48
48
|
this.fields.pickupLocation = this.fieldFactory('singleSelect', 'pickupLocation');
|
|
49
49
|
this.fields.presentmentData = this.fieldFactory('singleSelect', 'presentmentData');
|
|
50
|
+
this.fields.state = this.fieldFactory('singleSelect', 'state');
|
|
50
51
|
}
|
|
51
52
|
createOrder() {
|
|
52
53
|
const orderFactory = new OrderFromFormState_1.default();
|
|
@@ -97,6 +98,15 @@ class OrderFormState extends FormState_1.default {
|
|
|
97
98
|
// Update total price
|
|
98
99
|
this.fields.totalPrice.inputValue = Number(Number(this.fields.subtotalPrice.inputValue) - Number(this.fields.totalDiscount.inputValue) + Number(val)).toFixed(2);
|
|
99
100
|
}
|
|
101
|
+
orderStateChangeHandler(val) {
|
|
102
|
+
const values = Object.values(order_constants_1.ORDER_STATES);
|
|
103
|
+
if (!values.includes(val)) {
|
|
104
|
+
this.fields.state.selectedValue = order_constants_1.ORDER_STATES.draft;
|
|
105
|
+
}
|
|
106
|
+
else {
|
|
107
|
+
this.fields.state.selectedValue = val;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
100
110
|
fieldFactory(fieldType, fieldKey, fieldOptions) {
|
|
101
111
|
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;
|
|
102
112
|
let options = fieldOptions || [];
|
|
@@ -145,6 +155,7 @@ class OrderFormState extends FormState_1.default {
|
|
|
145
155
|
}
|
|
146
156
|
if (fieldType === 'singleSelect') {
|
|
147
157
|
let selectedValue = this.props[fieldKey] || '';
|
|
158
|
+
let onChangeHandler = (val) => this.singleSelectChangeHandler(fieldKey, val);
|
|
148
159
|
if (fieldKey === 'pickupLocation') {
|
|
149
160
|
if (((_c = this.props) === null || _c === void 0 ? void 0 : _c.shippingType) === order_constants_1.SHIPPING_TYPES.localPickUp &&
|
|
150
161
|
((_d = this.props) === null || _d === void 0 ? void 0 : _d.fulfillmentLocations) &&
|
|
@@ -188,8 +199,15 @@ class OrderFormState extends FormState_1.default {
|
|
|
188
199
|
displayName: this.props.customerName,
|
|
189
200
|
};
|
|
190
201
|
}
|
|
202
|
+
if (fieldKey === 'state') {
|
|
203
|
+
const values = Object.values(order_constants_1.ORDER_STATES);
|
|
204
|
+
if (!values.includes(selectedValue)) {
|
|
205
|
+
selectedValue = order_constants_1.ORDER_STATES.draft;
|
|
206
|
+
}
|
|
207
|
+
options = values.map((i) => ({ label: i, value: i }));
|
|
208
|
+
onChangeHandler = (val) => this.orderStateChangeHandler(val);
|
|
209
|
+
}
|
|
191
210
|
const valid = !!this.props[fieldKey];
|
|
192
|
-
const onChangeHandler = (val) => this.singleSelectChangeHandler(fieldKey, val);
|
|
193
211
|
if (fieldKey === 'shippingType') {
|
|
194
212
|
if ((_0 = (_z = this.opts) === null || _z === void 0 ? void 0 : _z.shippingTypeOptions) === null || _0 === void 0 ? void 0 : _0.length) {
|
|
195
213
|
options = this.utilities.uniqObjArray(this.opts.shippingTypeOptions, 'value');
|
|
@@ -731,6 +731,7 @@ declare type OrderAttributesFormFields = {
|
|
|
731
731
|
shippingInfo: SingleSelectFormField<OrderShippingInfo>;
|
|
732
732
|
pickupLocation: SingleSelectFormField<string>;
|
|
733
733
|
presentmentData: SingleSelectFormField<OrderPresentmentData>;
|
|
734
|
+
state: SingleSelectFormField<string>;
|
|
734
735
|
};
|
|
735
736
|
declare type OrderRefundFormFields = {
|
|
736
737
|
totalRefunded: TextInputFormField<string | number>;
|