@subiz/widget-v4 4.0.58 → 4.0.63
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/assets/img/caret.svg +1 -0
- package/assets/img/done_green.svg +4 -0
- package/assets/img/empty_1.svg +11 -0
- package/assets/img/ghn.svg +17 -0
- package/assets/img/ghtk.svg +18 -0
- package/assets/img/home.svg +1 -0
- package/assets/img/info.svg +1 -0
- package/assets/img/loader.svg +1 -0
- package/assets/img/map-pin.svg +1 -0
- package/assets/img/not_found_search.png +0 -0
- package/assets/img/package.svg +5 -0
- package/assets/img/package_fade.svg +1 -0
- package/assets/img/phone.svg +1 -0
- package/assets/img/search.svg +1 -0
- package/assets/img/shop.svg +1 -0
- package/assets/img/shop_faded.svg +1 -0
- package/assets/img/user.svg +1 -0
- package/assets/img/x.svg +5 -0
- package/assets/less/chatbox.less +35 -0
- package/assets/less/dropdown_select.less +130 -0
- package/assets/less/form.less +7 -20
- package/assets/less/order.less +489 -0
- package/assets/less/rating.less +3 -8
- package/compiled_src/call/call.js +12 -15
- package/compiled_src/chatbox/DropdownSelect.js +239 -0
- package/compiled_src/chatbox/Event.js +4 -2
- package/compiled_src/chatbox/Events.js +1 -0
- package/compiled_src/chatbox/MessageInput.js +4 -7
- package/compiled_src/chatbox/Order.js +281 -0
- package/compiled_src/chatbox/OrderAttachments.js +2 -1
- package/compiled_src/chatbox/Rating.js +7 -10
- package/compiled_src/chatbox/TextMessage.js +9 -2
- package/compiled_src/chatbox/Widget.js +40 -3
- package/compiled_src/chatbox/main.js +2 -1
- package/compiled_src/chatbox/spinner.js +1 -1
- package/compiled_src/chatbox/time.js +3 -1
- package/compiled_src/common.js +40 -1
- package/compiled_src/contact/contact.js +7 -12
- package/compiled_src/lib.js +9 -14
- package/compiled_src/notif/notif.js +12 -15
- package/compiled_src/order/address_picker.js +241 -0
- package/compiled_src/order/icon.js +62 -0
- package/compiled_src/order/index.js +113 -0
- package/compiled_src/order/order.js +1220 -0
- package/compiled_src/plugin.js +9 -42
- package/compiled_src/popup/countdown.js +4 -7
- package/compiled_src/popup/popup.js +40 -13
- package/compiled_src/store/api.js +80 -90
- package/compiled_src/store/api_fake.js +55 -82
- package/compiled_src/store/store.js +163 -158
- package/compiled_src/util/common.js +40 -4
- package/dist/0b82fa7e5c3b07b40a44.png +1 -0
- package/dist/0f4af006e38ee8b93633.png +1 -0
- package/dist/{74.js → 132.js} +2234 -236
- package/dist/178.js +341 -174
- package/dist/17e757ccadd.132.js +1 -0
- package/dist/17e757ccadd.178.js +1 -0
- package/dist/17e757ccadd.213.js +1 -0
- package/dist/17e757ccadd.335.js +1 -0
- package/dist/17e757ccadd.362.js +1 -0
- package/dist/17e757ccadd.441.js +1 -0
- package/dist/17e757ccadd.605.js +1 -0
- package/dist/17e757ccadd.678.js +1 -0
- package/dist/17e757ccadd.782.js +1 -0
- package/dist/17e757ccadd.app.js +1 -0
- package/dist/{17d938a5acb.index.html → 17e757ccadd.index.html} +3 -18
- package/dist/{17d938a5acb.library.html → 17e757ccadd.library.html} +3 -18
- package/dist/17e757ccadd.library.js +1 -0
- package/dist/{17d938a5acb.preview.html → 17e757ccadd.preview.html} +1 -1
- package/dist/17e757ccadd.preview.js +1 -0
- package/dist/17e757ccadd.screenshoot.js +1 -0
- package/dist/1ea1c6cd21d25176810c.png +1 -0
- package/dist/213.js +46 -87
- package/dist/292d42404e1b03398f61.png +1 -0
- package/dist/312d376370831b7bea83.png +1 -0
- package/dist/313d1bfc1cf776d1aefe.png +1 -0
- package/dist/335.js +408 -0
- package/dist/362.js +71 -21
- package/dist/441.js +69 -43
- package/dist/4aa58bb7a66bb44975aa.png +1 -0
- package/dist/56ce063bc6c81adb7322.png +1 -0
- package/dist/605.js +13 -79
- package/dist/678.js +70 -20
- package/dist/6a411166ef5cc79e0714.png +1 -0
- package/dist/6faf403782fefacc1649.png +1 -0
- package/dist/782.js +118 -21
- package/dist/79dca33c68fab79c067f.png +1 -0
- package/dist/82da1578fa84f9debaeb.png +1 -0
- package/dist/8b8e0f0824743974b282.png +1 -0
- package/dist/8d551390d81e39130a3c.png +1 -0
- package/dist/9fc61b9479877ebdb6c7.png +1 -0
- package/dist/HASH +1 -1
- package/dist/a165d31dcb3dc90f1057.png +1 -0
- package/dist/a98d4a5698812c4426b3.png +1 -0
- package/dist/assets/img/caret.998eb8f.svg +1 -0
- package/dist/assets/img/done_green.b817fd4.svg +4 -0
- package/dist/assets/img/empty_1.0b98af0.svg +11 -0
- package/dist/assets/img/ghn.070f8e3.svg +17 -0
- package/dist/assets/img/ghtk.326eac1.svg +18 -0
- package/dist/assets/img/info.ebce7ea.svg +1 -0
- package/dist/assets/img/loader.37000a7.svg +1 -0
- package/dist/assets/img/not_found_search.2ddb8d1.png +0 -0
- package/dist/assets/img/package.8d37d0f.svg +5 -0
- package/dist/assets/img/package_fade.763c001.svg +1 -0
- package/dist/assets/img/search.f9705ff.svg +1 -0
- package/dist/assets/img/shop.f7dc7d8.svg +1 -0
- package/dist/assets/img/shop_faded.df7845a.svg +1 -0
- package/dist/assets/img/x.26fdfa3.svg +5 -0
- package/dist/c41606bf9d1b604e46d5.png +1 -0
- package/dist/ce1f7450ce6c1aacd330.png +1 -0
- package/dist/cf8c01e88f4770a6e3e5.png +1 -0
- package/dist/dfbcfeab1d5622a737e2.png +1 -0
- package/dist/e4893ed8c2f7b8329919.png +1 -0
- package/dist/ec2ab4eb4ef73d186186.png +1 -0
- package/dist/screenshoot.html +1 -1
- package/dist/screenshoot.js +452 -389
- package/index.html +3 -18
- package/order.html +32 -0
- package/package.json +13 -14
- package/src/chatbox/DropdownSelect.js +229 -0
- package/src/chatbox/Event.js +2 -2
- package/src/chatbox/Events.js +43 -42
- package/src/chatbox/Order.js +232 -0
- package/src/chatbox/OrderAttachments.js +2 -1
- package/src/chatbox/TextMessage.js +21 -12
- package/src/chatbox/Widget.js +34 -4
- package/src/chatbox/main.js +2 -2
- package/src/chatbox/spinner.js +1 -1
- package/src/chatbox/time.js +1 -1
- package/src/common.js +52 -8
- package/src/contact/contact.js +1 -1
- package/src/order/address_picker.js +235 -0
- package/src/order/icon.js +32 -0
- package/src/order/index.js +86 -0
- package/src/order/order.js +1157 -0
- package/src/order/scratch +211 -0
- package/src/plugin.js +7 -52
- package/src/popup/popup.js +27 -2
- package/src/store/api.js +26 -1
- package/src/store/store.js +46 -9
- package/src/util/common.js +52 -4
- package/webpack.dev.js +2 -0
- package/dist/17d938a5acb.178.js +0 -1
- package/dist/17d938a5acb.213.js +0 -1
- package/dist/17d938a5acb.362.js +0 -1
- package/dist/17d938a5acb.441.js +0 -1
- package/dist/17d938a5acb.605.js +0 -1
- package/dist/17d938a5acb.619.js +0 -1
- package/dist/17d938a5acb.678.js +0 -1
- package/dist/17d938a5acb.74.js +0 -1
- package/dist/17d938a5acb.782.js +0 -1
- package/dist/17d938a5acb.app.js +0 -1
- package/dist/17d938a5acb.library.js +0 -1
- package/dist/17d938a5acb.preview.js +0 -1
- package/dist/17d938a5acb.screenshoot.js +0 -1
- package/dist/619.js +0 -777
|
@@ -0,0 +1,1220 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
|
|
8
|
+
var _index = _interopRequireDefault(require("../util/index.js"));
|
|
9
|
+
|
|
10
|
+
var _time = _interopRequireDefault(require("../chatbox/time.js"));
|
|
11
|
+
|
|
12
|
+
var common = _interopRequireWildcard(require("../common.js"));
|
|
13
|
+
|
|
14
|
+
var _DropdownSelect = _interopRequireDefault(require("../chatbox/DropdownSelect.js"));
|
|
15
|
+
|
|
16
|
+
var _address_picker = _interopRequireDefault(require("./address_picker.js"));
|
|
17
|
+
|
|
18
|
+
var _preact = require("preact");
|
|
19
|
+
|
|
20
|
+
var _icon = _interopRequireDefault(require("./icon.js"));
|
|
21
|
+
|
|
22
|
+
var _spinner = _interopRequireDefault(require("../chatbox/spinner.js"));
|
|
23
|
+
|
|
24
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
25
|
+
|
|
26
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
27
|
+
|
|
28
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
29
|
+
|
|
30
|
+
var checkedimg = require('../../assets/img/done_green.svg');
|
|
31
|
+
|
|
32
|
+
var ximg = require('../../assets/img/x.svg');
|
|
33
|
+
|
|
34
|
+
class Order extends common.Com {
|
|
35
|
+
state = {
|
|
36
|
+
loadProvince: true,
|
|
37
|
+
g_err: '',
|
|
38
|
+
fullname: '',
|
|
39
|
+
email: '',
|
|
40
|
+
phone: '',
|
|
41
|
+
loading: true,
|
|
42
|
+
order: {},
|
|
43
|
+
err: {},
|
|
44
|
+
selectedProvince: null,
|
|
45
|
+
selectedDistrict: null,
|
|
46
|
+
selectedWard: null,
|
|
47
|
+
street: '',
|
|
48
|
+
address: '',
|
|
49
|
+
sending: false,
|
|
50
|
+
step: ''
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
constructor(props) {
|
|
54
|
+
super(props);
|
|
55
|
+
this.load();
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
async load() {
|
|
59
|
+
if (!this.props.order_id) return;
|
|
60
|
+
let orderout = await this.props.store.fetchOrder(this.props.order_id);
|
|
61
|
+
this.setState({
|
|
62
|
+
loading: false
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
if (!orderout.error) {
|
|
66
|
+
this.setState({
|
|
67
|
+
order: orderout.body
|
|
68
|
+
});
|
|
69
|
+
} else {
|
|
70
|
+
this.setState({
|
|
71
|
+
error: orderout.error
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
let user = this.props.store.matchUser();
|
|
76
|
+
|
|
77
|
+
let attributes = _index.default.get(this.props.store.matchUser(), 'attributes', []);
|
|
78
|
+
|
|
79
|
+
let fullname = _index.default.get(_index.default.find(attributes, att => att.key === 'fullname'), 'text');
|
|
80
|
+
|
|
81
|
+
let email = _index.default.get(_index.default.find(attributes, att => att.key === 'emails'), 'text');
|
|
82
|
+
|
|
83
|
+
let phone = _index.default.get(_index.default.find(attributes, att => att.key === 'phones'), 'text');
|
|
84
|
+
|
|
85
|
+
this.setState({
|
|
86
|
+
fullname,
|
|
87
|
+
email,
|
|
88
|
+
phone
|
|
89
|
+
});
|
|
90
|
+
await this.props.store.fetchShippingAddresses();
|
|
91
|
+
let out = await this.props.store.list_provinces();
|
|
92
|
+
this.setState({
|
|
93
|
+
loadProvince: false
|
|
94
|
+
});
|
|
95
|
+
if (!out.error) this.setState({
|
|
96
|
+
provinces: _index.default.get(out, 'body.addresses')
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
isMobile() {
|
|
101
|
+
if (this.props.cid) return true;
|
|
102
|
+
if (this.props.isMobile) return true;
|
|
103
|
+
return this.props.store.isMobile();
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
onChangeShippingAddress(id) {
|
|
107
|
+
this.setState({
|
|
108
|
+
shipping_address: id,
|
|
109
|
+
err: {},
|
|
110
|
+
g_err: ''
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
renderMobileSuccess = order => {
|
|
115
|
+
return (0, _preact.h)("div", {
|
|
116
|
+
class: "order",
|
|
117
|
+
style: "height: 100% !important"
|
|
118
|
+
}, (0, _preact.h)("div", {
|
|
119
|
+
style: "display: flex !important; align-items: center !important; padding-top: 40px !important; padding-bottom: 20px !important; flex-direction: column !important; height: 100% !important"
|
|
120
|
+
}, (0, _preact.h)("img", {
|
|
121
|
+
style: "width: 60px !important; height: 60px !important;",
|
|
122
|
+
width: "60",
|
|
123
|
+
height: "60",
|
|
124
|
+
src: checkedimg
|
|
125
|
+
}), (0, _preact.h)("div", {
|
|
126
|
+
style: "margin-top: 20px !important; margin-bottom: 10px !important"
|
|
127
|
+
}, (0, _preact.h)("b", {
|
|
128
|
+
style: "font-size: 18px !important;"
|
|
129
|
+
}, "\u0110\u01A1n h\xE0ng c\u1EE7a b\u1EA1n \u0111\xE3 \u0111\u01B0\u1EE3c ghi nh\u1EADn")), (0, _preact.h)("div", {
|
|
130
|
+
class: "muted"
|
|
131
|
+
}, "T\xF4i s\u1EBD li\xEAn h\u1EC7 l\u1EA1i v\u1EDBi b\u1EA1n khi \u0111\u01A1n h\xE0ng \u0111\u01B0\u1EE3c x\u1EED l\xFD"), (0, _preact.h)("div", {
|
|
132
|
+
style: "flex:1 !important"
|
|
133
|
+
}), (0, _preact.h)("div", {
|
|
134
|
+
style: "margin-top: 20px !important; padding: 0px 20px 0 20px !important; width: 100% !important"
|
|
135
|
+
}, (0, _preact.h)("div", {
|
|
136
|
+
class: "order_btn order__btn__light",
|
|
137
|
+
onClick: this.close
|
|
138
|
+
}, this.props.t('close')))));
|
|
139
|
+
};
|
|
140
|
+
|
|
141
|
+
onChangeShipping(id) {
|
|
142
|
+
this.setState({
|
|
143
|
+
shipping: id,
|
|
144
|
+
err: {},
|
|
145
|
+
g_err: ''
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
onSelectProvince = async item => {
|
|
150
|
+
this.setState({
|
|
151
|
+
selectedProvince: item,
|
|
152
|
+
err: {},
|
|
153
|
+
g_err: ''
|
|
154
|
+
});
|
|
155
|
+
this.setState({
|
|
156
|
+
loadDistrict: true
|
|
157
|
+
});
|
|
158
|
+
let out = await this.props.store.list_districts({
|
|
159
|
+
id: item.id
|
|
160
|
+
});
|
|
161
|
+
this.setState({
|
|
162
|
+
loadDistrict: false
|
|
163
|
+
});
|
|
164
|
+
if (!out.error) this.setState({
|
|
165
|
+
districts: _index.default.get(out, 'body.addresses')
|
|
166
|
+
});
|
|
167
|
+
};
|
|
168
|
+
onSelectDistrict = async item => {
|
|
169
|
+
this.setState({
|
|
170
|
+
selectedDistrict: item,
|
|
171
|
+
err: {},
|
|
172
|
+
g_err: ''
|
|
173
|
+
});
|
|
174
|
+
this.setState({
|
|
175
|
+
loadWard: true
|
|
176
|
+
});
|
|
177
|
+
let out = await this.props.store.list_wards({
|
|
178
|
+
id: item.id
|
|
179
|
+
});
|
|
180
|
+
this.setState({
|
|
181
|
+
loadWard: false
|
|
182
|
+
});
|
|
183
|
+
if (!out.error) this.setState({
|
|
184
|
+
wards: _index.default.get(out, 'body.addresses')
|
|
185
|
+
});
|
|
186
|
+
};
|
|
187
|
+
onSelectWard = item => this.setState({
|
|
188
|
+
selectedWard: item,
|
|
189
|
+
err: {},
|
|
190
|
+
g_err: ''
|
|
191
|
+
});
|
|
192
|
+
onChangeFullname = e => this.setState({
|
|
193
|
+
fullname: e.target.value,
|
|
194
|
+
err: {},
|
|
195
|
+
g_err: ''
|
|
196
|
+
});
|
|
197
|
+
onChangeAddress = e => this.setState({
|
|
198
|
+
address: e,
|
|
199
|
+
err: {},
|
|
200
|
+
g_err: ''
|
|
201
|
+
});
|
|
202
|
+
onSelectAddress = addr => {
|
|
203
|
+
if (!addr) return;
|
|
204
|
+
this.setState({
|
|
205
|
+
address: [_index.default.trim(addr.address), _index.default.trim(addr.street)].join(' ').trim(),
|
|
206
|
+
street: addr.street,
|
|
207
|
+
err: {},
|
|
208
|
+
g_err: ''
|
|
209
|
+
});
|
|
210
|
+
this.onSelectWard({
|
|
211
|
+
id: addr.ward_id,
|
|
212
|
+
name: addr.ward
|
|
213
|
+
});
|
|
214
|
+
this.onSelectDistrict({
|
|
215
|
+
id: addr.district_id,
|
|
216
|
+
name: addr.district
|
|
217
|
+
});
|
|
218
|
+
this.onSelectProvince({
|
|
219
|
+
id: addr.province_id,
|
|
220
|
+
name: addr.province
|
|
221
|
+
});
|
|
222
|
+
};
|
|
223
|
+
onChangeEmail = e => this.setState({
|
|
224
|
+
email: e.target.value,
|
|
225
|
+
err: {},
|
|
226
|
+
g_err: ''
|
|
227
|
+
});
|
|
228
|
+
onChangePhone = e => this.setState({
|
|
229
|
+
phone: e.target.value,
|
|
230
|
+
err: {},
|
|
231
|
+
g_err: ''
|
|
232
|
+
});
|
|
233
|
+
onChangePaymentMethod = id => this.setState({
|
|
234
|
+
pm: id
|
|
235
|
+
});
|
|
236
|
+
|
|
237
|
+
renderDesktopPaymentMethod(order) {
|
|
238
|
+
return null;
|
|
239
|
+
let editmode = false;
|
|
240
|
+
|
|
241
|
+
if (!order.status || order.status == 'new') {
|
|
242
|
+
editmode = !order.user_confirmation;
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
if (editmode) {
|
|
246
|
+
let pms = this.props.store.matchPaymentMethods();
|
|
247
|
+
|
|
248
|
+
let $pms = _index.default.map(pms, pm => {
|
|
249
|
+
let $name = pm.description;
|
|
250
|
+
|
|
251
|
+
if (pm.method == 'bank_transfer') {
|
|
252
|
+
$name = pm.description + ' ' + pm.bank_name + ' ' + pm.bank_branch;
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
let cls = 'order__card';
|
|
256
|
+
let $desc = null;
|
|
257
|
+
|
|
258
|
+
if (this.state.pm === pm.id) {
|
|
259
|
+
cls += ' order__card__active';
|
|
260
|
+
$desc = (0, _preact.h)("div", {
|
|
261
|
+
class: "muted mt-1",
|
|
262
|
+
style: "margin-left: 26px !important;"
|
|
263
|
+
}, "Tr\u1EA3 ti\u1EC1n m\u1EB7t khi b\u1EA1n nh\u1EADn h\xE0ng");
|
|
264
|
+
|
|
265
|
+
if (pm.method == 'bank_transfer') {
|
|
266
|
+
$desc = (0, _preact.h)("div", {
|
|
267
|
+
class: "muted mt-1",
|
|
268
|
+
style: "margin-left: 26px !important;"
|
|
269
|
+
}, (0, _preact.h)("div", null, "STK: ", pm.bank_number), (0, _preact.h)("div", null, "Ch\u1EE7 t\xE0i kho\u1EA3n: ", pm.bank_owner));
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
return (0, _preact.h)("div", {
|
|
274
|
+
style: "width: 100% !important; margin-top: 10px !important;"
|
|
275
|
+
}, (0, _preact.h)("div", {
|
|
276
|
+
class: "radio"
|
|
277
|
+
}, (0, _preact.h)("input", {
|
|
278
|
+
type: "radio",
|
|
279
|
+
id: 'pm.' + pm.id,
|
|
280
|
+
onInput: e => this.onChangePaymentMethod(pm.id),
|
|
281
|
+
name: "pm",
|
|
282
|
+
checked: this.state.pm === pm.id
|
|
283
|
+
}), (0, _preact.h)("label", {
|
|
284
|
+
class: "radio--label",
|
|
285
|
+
style: `margin-left: 4px !important; font-weight: ${this.state.pm === pm.id ? 500 : 400} !important;`,
|
|
286
|
+
for: 'pm.' + pm.id
|
|
287
|
+
}, $name), (0, _preact.h)("div", {
|
|
288
|
+
class: "radio--check"
|
|
289
|
+
}, (0, _preact.h)("div", {
|
|
290
|
+
class: "inside"
|
|
291
|
+
})), $desc));
|
|
292
|
+
});
|
|
293
|
+
|
|
294
|
+
let seccls = 'card_section';
|
|
295
|
+
if (this.isMobile()) seccls = 'order_section';
|
|
296
|
+
return (0, _preact.h)(_preact.Fragment, null, (0, _preact.h)("div", {
|
|
297
|
+
class: "order_section__line"
|
|
298
|
+
}), (0, _preact.h)("div", {
|
|
299
|
+
class: seccls
|
|
300
|
+
}, (0, _preact.h)("div", {
|
|
301
|
+
class: "order_label"
|
|
302
|
+
}, this.props.t('payment')), (0, _preact.h)("div", {
|
|
303
|
+
class: "form",
|
|
304
|
+
style: "justify-content: space-between !important;"
|
|
305
|
+
}, $pms)));
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
let pm = order.payment_method || {
|
|
309
|
+
method: 'cod'
|
|
310
|
+
};
|
|
311
|
+
let $body = null;
|
|
312
|
+
if (pm.method === 'cash') $body = (0, _preact.h)("div", null, this.props.t('pm_cash'));
|
|
313
|
+
if (pm.method === 'cod') $body = (0, _preact.h)("div", null, this.props.t('pm_cod'));
|
|
314
|
+
|
|
315
|
+
if (pm.method === 'bank_transfer') {
|
|
316
|
+
let name = pm.bank_name;
|
|
317
|
+
if (pm.bank_branch) name += ' - ' + pm.bank_branch;
|
|
318
|
+
$body = (0, _preact.h)("div", null, (0, _preact.h)("div", null, "Ng\xE2n h\xE0ng: ", name), (0, _preact.h)("div", {
|
|
319
|
+
class: "mt-1"
|
|
320
|
+
}, "Ch\u1EE7 t\xE0i kho\u1EA3n: ", pm.bank_owner), (0, _preact.h)("div", {
|
|
321
|
+
class: "mt-1"
|
|
322
|
+
}, "S\u1ED1 t\xE0i kho\u1EA3n: ", pm.bank_number));
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
if (!$body) return null;
|
|
326
|
+
return (0, _preact.h)(_preact.Fragment, null, (0, _preact.h)("div", {
|
|
327
|
+
class: "order_label"
|
|
328
|
+
}, this.props.t('payment')), $body);
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
renderDesktopShipping(order) {
|
|
332
|
+
let editmode = false;
|
|
333
|
+
|
|
334
|
+
if (!order.status || order.status == 'new') {
|
|
335
|
+
editmode = !order.user_confirmation;
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
let user = this.props.store.matchUser();
|
|
339
|
+
|
|
340
|
+
if (editmode) {
|
|
341
|
+
let addresses = this.props.store.matchShippingAddresses();
|
|
342
|
+
|
|
343
|
+
let provinces = _index.default.map(this.state.provinces, province => ({
|
|
344
|
+
id: province.id,
|
|
345
|
+
name: province.province
|
|
346
|
+
}));
|
|
347
|
+
|
|
348
|
+
let districts = _index.default.map(this.state.districts, district => ({
|
|
349
|
+
id: district.id,
|
|
350
|
+
name: district.district
|
|
351
|
+
}));
|
|
352
|
+
|
|
353
|
+
let wards = _index.default.map(this.state.wards, ward => ({
|
|
354
|
+
id: ward.id,
|
|
355
|
+
name: ward.ward
|
|
356
|
+
}));
|
|
357
|
+
|
|
358
|
+
let cls = 'ship_card';
|
|
359
|
+
let $body = null;
|
|
360
|
+
let ship_icon_active = false;
|
|
361
|
+
|
|
362
|
+
if (this.state.shipping === 'ship') {
|
|
363
|
+
ship_icon_active = true;
|
|
364
|
+
|
|
365
|
+
let $preaddrs = _index.default.map(addresses, addr => {
|
|
366
|
+
let fulladdr = [addr.street, addr.ward, addr.district, addr.region, addr.country].filter(a => a).join(', ');
|
|
367
|
+
let $phone = null;
|
|
368
|
+
|
|
369
|
+
if (addr.phone) {
|
|
370
|
+
$phone = (0, _preact.h)(_preact.Fragment, null, "\xA0\xB7\xA0", this.props.t('phn'), " ", addr.phone);
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
return (0, _preact.h)("div", {
|
|
374
|
+
style: "margin-bottom: 15px !important"
|
|
375
|
+
}, (0, _preact.h)("div", {
|
|
376
|
+
class: "radio d-flex "
|
|
377
|
+
}, (0, _preact.h)("input", {
|
|
378
|
+
type: "radio",
|
|
379
|
+
id: 'shipping_addr.' + addr.id,
|
|
380
|
+
onInput: e => this.onChangeShippingAddress(addr.id),
|
|
381
|
+
name: "shipping_address",
|
|
382
|
+
checked: this.state.shipping_address === addr.id
|
|
383
|
+
}), (0, _preact.h)("label", {
|
|
384
|
+
class: "radio--label",
|
|
385
|
+
for: 'shipping_addr.' + addr.id,
|
|
386
|
+
style: `font-weight: ${this.state.shipping_address === addr.id ? 500 : 400} !important`
|
|
387
|
+
}, addr.fullname, $phone, (0, _preact.h)("div", {
|
|
388
|
+
class: "mt-1 muted"
|
|
389
|
+
}, "DC ", fulladdr)), (0, _preact.h)("div", {
|
|
390
|
+
class: "radio--check"
|
|
391
|
+
}, (0, _preact.h)("div", {
|
|
392
|
+
class: "inside"
|
|
393
|
+
}))));
|
|
394
|
+
});
|
|
395
|
+
|
|
396
|
+
$preaddrs.push((0, _preact.h)("div", {
|
|
397
|
+
style: ""
|
|
398
|
+
}, (0, _preact.h)("div", {
|
|
399
|
+
class: "radio d-flex "
|
|
400
|
+
}, (0, _preact.h)("input", {
|
|
401
|
+
type: "radio",
|
|
402
|
+
id: 'shipping_addr.new',
|
|
403
|
+
onInput: e => this.onChangeShippingAddress('new'),
|
|
404
|
+
name: "shipping_address",
|
|
405
|
+
checked: this.state.shipping_address === 'new'
|
|
406
|
+
}), (0, _preact.h)("label", {
|
|
407
|
+
class: "radio--label",
|
|
408
|
+
for: 'shipping_addr.new'
|
|
409
|
+
}, this.state.shipping_address === 'new' ? (0, _preact.h)("b", null, "T\u1EDBi \u0111\u1ECBa ch\u1EC9 kh\xE1c") : 'Tới địa chỉ khác'), (0, _preact.h)("div", {
|
|
410
|
+
class: "radio--check"
|
|
411
|
+
}, (0, _preact.h)("div", {
|
|
412
|
+
class: "inside"
|
|
413
|
+
})))));
|
|
414
|
+
let $new = (0, _preact.h)("div", {
|
|
415
|
+
style: "padding-left: 22px !important;"
|
|
416
|
+
}, (0, _preact.h)("div", {
|
|
417
|
+
class: "d-flex"
|
|
418
|
+
}, (0, _preact.h)("div", {
|
|
419
|
+
class: "mr-2",
|
|
420
|
+
style: "flex: 1 !important;"
|
|
421
|
+
}, (0, _preact.h)("div", {
|
|
422
|
+
class: "order_form_label"
|
|
423
|
+
}, this.props.t('fullname')), (0, _preact.h)("input", {
|
|
424
|
+
type: "text",
|
|
425
|
+
class: 'form-control ' + (this.state.err.name && 'err'),
|
|
426
|
+
onInput: this.onChangeFullname,
|
|
427
|
+
value: this.state.fullname
|
|
428
|
+
})), (0, _preact.h)("div", {
|
|
429
|
+
class: "ml-2",
|
|
430
|
+
style: "flex: 1 !important;"
|
|
431
|
+
}, (0, _preact.h)("div", {
|
|
432
|
+
class: "order_form_label"
|
|
433
|
+
}, this.props.t('phones')), (0, _preact.h)("input", {
|
|
434
|
+
type: "text",
|
|
435
|
+
class: 'form-control ' + (this.state.err.phone && 'err'),
|
|
436
|
+
onInput: this.onChangePhone,
|
|
437
|
+
value: this.state.phone
|
|
438
|
+
}))), (0, _preact.h)("div", {
|
|
439
|
+
class: "",
|
|
440
|
+
style: "width: 100% !important"
|
|
441
|
+
}, (0, _preact.h)("div", {
|
|
442
|
+
class: "order_form_label"
|
|
443
|
+
}, this.props.t('address')), (0, _preact.h)(_address_picker.default, {
|
|
444
|
+
initAddress: this.state.address,
|
|
445
|
+
store: this.props.store,
|
|
446
|
+
width: "100%",
|
|
447
|
+
onChangeAddress: this.onChangeAddress,
|
|
448
|
+
full: this.isMobile(),
|
|
449
|
+
onSelect: this.onSelectAddress,
|
|
450
|
+
extra_cls: this.state.err.address && 'err'
|
|
451
|
+
})), (0, _preact.h)("div", {
|
|
452
|
+
class: "d-flex",
|
|
453
|
+
style: "justify-content: space-between !important;"
|
|
454
|
+
}, (0, _preact.h)("div", {
|
|
455
|
+
style: "flex: 1 !important; overflow:hidden !important; margin-right: 7px !important;"
|
|
456
|
+
}, (0, _preact.h)("div", {
|
|
457
|
+
class: "order_form_label"
|
|
458
|
+
}, this.props.t('province')), (0, _preact.h)(_DropdownSelect.default, {
|
|
459
|
+
width: "194",
|
|
460
|
+
full: this.isMobile(),
|
|
461
|
+
has_search: true,
|
|
462
|
+
loading: this.state.loadProvince,
|
|
463
|
+
items: provinces,
|
|
464
|
+
selected: this.state.selectedProvince,
|
|
465
|
+
onSelect: this.onSelectProvince,
|
|
466
|
+
extra_cls: this.state.err.province && 'err'
|
|
467
|
+
})), (0, _preact.h)("div", {
|
|
468
|
+
style: "flex: 1 !important; overflow:hidden !important; margin-left: 7px !important;"
|
|
469
|
+
}, (0, _preact.h)("div", {
|
|
470
|
+
class: "order_form_label"
|
|
471
|
+
}, this.props.t('district')), (0, _preact.h)(_DropdownSelect.default, {
|
|
472
|
+
width: "194",
|
|
473
|
+
full: this.isMobile(),
|
|
474
|
+
selected: this.state.selectedDistrict,
|
|
475
|
+
has_search: true,
|
|
476
|
+
onSelect: this.onSelectDistrict,
|
|
477
|
+
loading: this.state.loadDistrict,
|
|
478
|
+
extra_cls: this.state.err.district && 'err',
|
|
479
|
+
items: districts
|
|
480
|
+
}))), (0, _preact.h)("div", {
|
|
481
|
+
class: "d-flex",
|
|
482
|
+
style: "justify-content: space-between !important;"
|
|
483
|
+
}, (0, _preact.h)("div", {
|
|
484
|
+
style: "flex: 1 !important; overflow:hidden !important; margin-right: 7px !important;"
|
|
485
|
+
}, (0, _preact.h)("div", {
|
|
486
|
+
class: "order_form_label"
|
|
487
|
+
}, this.props.t('ward')), (0, _preact.h)(_DropdownSelect.default, {
|
|
488
|
+
width: "194",
|
|
489
|
+
selected: this.state.selectedWard,
|
|
490
|
+
full: this.isMobile(),
|
|
491
|
+
has_search: true,
|
|
492
|
+
onSelect: this.onSelectWard,
|
|
493
|
+
extra_cls: this.state.err.ward && 'err',
|
|
494
|
+
loading: this.state.loadWard,
|
|
495
|
+
items: wards
|
|
496
|
+
})), (0, _preact.h)("div", {
|
|
497
|
+
style: "flex: 1 !important; margin-left: 7px !important;"
|
|
498
|
+
})));
|
|
499
|
+
cls += ' ship_card__active';
|
|
500
|
+
|
|
501
|
+
if (_index.default.size(addresses) == 0) {
|
|
502
|
+
$body = (0, _preact.h)("div", null, (0, _preact.h)("div", {
|
|
503
|
+
class: 'mt-3 mb-2 '
|
|
504
|
+
}, this.props.t('input_shipping_info')), $new);
|
|
505
|
+
} else {
|
|
506
|
+
if (this.state.shipping_address !== 'new') $new = null;
|
|
507
|
+
$body = (0, _preact.h)("div", null, (0, _preact.h)("div", {
|
|
508
|
+
class: "mt-3 mb-2",
|
|
509
|
+
style: "margin-bottom: 10px !important;"
|
|
510
|
+
}, "Vui l\xF2ng ch\u1ECDn \u0111\u1ECBa ch\u1EC9 giao h\xE0ng"), (0, _preact.h)("div", {
|
|
511
|
+
class: "form"
|
|
512
|
+
}, $preaddrs), $new);
|
|
513
|
+
}
|
|
514
|
+
}
|
|
515
|
+
|
|
516
|
+
let shopcls = 'ship_card';
|
|
517
|
+
let shop_icon_active = false;
|
|
518
|
+
|
|
519
|
+
if (this.state.shipping === 'shop') {
|
|
520
|
+
shop_icon_active = true;
|
|
521
|
+
shopcls += ' ship_card__active';
|
|
522
|
+
$body = (0, _preact.h)("div", null, (0, _preact.h)("div", {
|
|
523
|
+
class: "d-flex"
|
|
524
|
+
}, (0, _preact.h)("div", {
|
|
525
|
+
class: "mr-2",
|
|
526
|
+
style: "flex: 3 !important;"
|
|
527
|
+
}, (0, _preact.h)("div", {
|
|
528
|
+
class: "order_form_label"
|
|
529
|
+
}, this.props.t('fullname')), (0, _preact.h)("input", {
|
|
530
|
+
type: "text",
|
|
531
|
+
class: 'form-control ' + (this.state.err.name && 'err'),
|
|
532
|
+
onInput: this.onChangeFullname,
|
|
533
|
+
value: this.state.fullname
|
|
534
|
+
})), (0, _preact.h)("div", {
|
|
535
|
+
class: "ml-2",
|
|
536
|
+
style: "flex: 2 !important;"
|
|
537
|
+
}, (0, _preact.h)("div", {
|
|
538
|
+
class: "order_form_label"
|
|
539
|
+
}, this.props.t('phones')), (0, _preact.h)("input", {
|
|
540
|
+
type: "text",
|
|
541
|
+
class: 'form-control ' + (this.state.err.phone && 'err'),
|
|
542
|
+
onInput: this.onChangePhone,
|
|
543
|
+
value: this.state.phone
|
|
544
|
+
}))), (0, _preact.h)("div", null, (0, _preact.h)("div", {
|
|
545
|
+
class: "order_form_label"
|
|
546
|
+
}, this.props.t('email')), (0, _preact.h)("input", {
|
|
547
|
+
type: "text",
|
|
548
|
+
class: 'form-control ' + (this.state.err.email && 'err'),
|
|
549
|
+
onInput: this.onChangeEmail,
|
|
550
|
+
value: this.state.email
|
|
551
|
+
})));
|
|
552
|
+
}
|
|
553
|
+
|
|
554
|
+
let seccls = 'card_section';
|
|
555
|
+
if (this.isMobile()) seccls = 'order_section';
|
|
556
|
+
return (0, _preact.h)(_preact.Fragment, null, (0, _preact.h)("div", {
|
|
557
|
+
class: "order_section__line"
|
|
558
|
+
}), (0, _preact.h)("div", {
|
|
559
|
+
class: seccls
|
|
560
|
+
}, (0, _preact.h)("div", {
|
|
561
|
+
class: "order_label"
|
|
562
|
+
}, this.props.t('ship_to')), (0, _preact.h)("div", {
|
|
563
|
+
class: "d-flex"
|
|
564
|
+
}, (0, _preact.h)("div", {
|
|
565
|
+
class: shopcls + ' mr-3',
|
|
566
|
+
onClick: e => this.onChangeShipping('shop')
|
|
567
|
+
}, (0, _preact.h)(_icon.default, {
|
|
568
|
+
name: "shop",
|
|
569
|
+
active: shop_icon_active
|
|
570
|
+
}), " ", (0, _preact.h)("b", {
|
|
571
|
+
class: "ml-2"
|
|
572
|
+
}, "Nh\u1EADn h\xE0ng t\u1EA1i shop")), (0, _preact.h)("div", {
|
|
573
|
+
class: cls,
|
|
574
|
+
onClick: e => this.onChangeShipping('ship')
|
|
575
|
+
}, (0, _preact.h)(_icon.default, {
|
|
576
|
+
name: "package",
|
|
577
|
+
active: ship_icon_active
|
|
578
|
+
}), " ", (0, _preact.h)("b", {
|
|
579
|
+
class: "ml-2"
|
|
580
|
+
}, "Giao h\xE0ng cho t\xF4i"))), $body));
|
|
581
|
+
}
|
|
582
|
+
|
|
583
|
+
let addr = _index.default.get(order, 'shipping.address') || {};
|
|
584
|
+
let fulladdr = [addr.address, addr.ward, addr.district, addr.region, addr.country].filter(a => a).join(', ');
|
|
585
|
+
let $phone = null;
|
|
586
|
+
if (addr.phone) $phone = (0, _preact.h)("div", {
|
|
587
|
+
class: "mt-1 muted"
|
|
588
|
+
}, this.props.t('phn'), ":\xA0", addr.phone);
|
|
589
|
+
|
|
590
|
+
if (_index.default.get(order, 'shipping.pickup_at_shop')) {
|
|
591
|
+
fulladdr = 'Nhận hàng tại cửa hàng';
|
|
592
|
+
}
|
|
593
|
+
|
|
594
|
+
let $addr = fulladdr ? (0, _preact.h)("div", null, fulladdr) : (0, _preact.h)("i", {
|
|
595
|
+
class: "i muted"
|
|
596
|
+
}, "Ch\u01B0a c\xF3 \u0111\u1ECBa ch\u1EC9 giao h\xE0ng");
|
|
597
|
+
let seccls = 'card_section';
|
|
598
|
+
if (this.isMobile()) seccls = 'order_section';
|
|
599
|
+
return (0, _preact.h)("div", {
|
|
600
|
+
class: seccls
|
|
601
|
+
}, (0, _preact.h)("div", {
|
|
602
|
+
class: "order_label "
|
|
603
|
+
}, this.props.t('ship_to')), $addr, $phone);
|
|
604
|
+
}
|
|
605
|
+
|
|
606
|
+
renderDesktopSummary(order) {
|
|
607
|
+
let $deposit = null;
|
|
608
|
+
|
|
609
|
+
if (order.deposit > 0) {
|
|
610
|
+
$deposit = (0, _preact.h)("span", {
|
|
611
|
+
class: "muted"
|
|
612
|
+
}, "(c\u1ECDc ", _index.default.formatCurrency(order.deposit), ")");
|
|
613
|
+
}
|
|
614
|
+
|
|
615
|
+
let $discount = null;
|
|
616
|
+
|
|
617
|
+
if (order.total_discount > 0) {
|
|
618
|
+
$discount = (0, _preact.h)("div", {
|
|
619
|
+
class: "order_summary_line"
|
|
620
|
+
}, (0, _preact.h)("div", null, "Gi\u1EA3m gi\xE1"), (0, _preact.h)("div", null, _index.default.formatCurrency(order.total_discount)));
|
|
621
|
+
}
|
|
622
|
+
|
|
623
|
+
let $pay = null;
|
|
624
|
+
|
|
625
|
+
if ($deposit || order.payment_made) {
|
|
626
|
+
$pay = (0, _preact.h)(_preact.Fragment, null, (0, _preact.h)("div", {
|
|
627
|
+
class: "order_summary_line"
|
|
628
|
+
}, (0, _preact.h)("div", null, "B\u1EA1n \u0111\xE3 tr\u1EA3"), (0, _preact.h)("div", null, $deposit, " ", _index.default.formatCurrency(order.payment_made))), (0, _preact.h)("div", {
|
|
629
|
+
class: "order_summary_line"
|
|
630
|
+
}, (0, _preact.h)("div", null, "B\u1EA1n ch\u01B0a tr\u1EA3"), (0, _preact.h)("div", null, _index.default.formatCurrency((order.total || 0) - (order.payment_made || 0)))));
|
|
631
|
+
}
|
|
632
|
+
|
|
633
|
+
let $tax = (0, _preact.h)("div", {
|
|
634
|
+
class: "order_summary_line"
|
|
635
|
+
}, (0, _preact.h)("div", null, "Ti\u1EC1n thu\u1EBF"), (0, _preact.h)("div", null, _index.default.formatCurrency(order.total_tax)));
|
|
636
|
+
let $ship = (0, _preact.h)("div", {
|
|
637
|
+
class: "order_summary_line"
|
|
638
|
+
}, (0, _preact.h)("div", null, "Ph\xED v\u1EADn chuy\u1EC3n"), (0, _preact.h)("div", null, _index.default.get(order, 'shipping.fee', 0), " d"));
|
|
639
|
+
let editmode = false;
|
|
640
|
+
|
|
641
|
+
if (!order.status || order.status == 'new') {
|
|
642
|
+
editmode = !order.user_confirmation;
|
|
643
|
+
}
|
|
644
|
+
|
|
645
|
+
let $note = null;
|
|
646
|
+
|
|
647
|
+
if (editmode) {
|
|
648
|
+
$ship = null;
|
|
649
|
+
$tax = null;
|
|
650
|
+
$note = (0, _preact.h)("div", {
|
|
651
|
+
class: "muted"
|
|
652
|
+
}, (0, _preact.h)("img", {
|
|
653
|
+
class: "order_ship_icon",
|
|
654
|
+
src: require('../../assets/img/info.svg')
|
|
655
|
+
}), "\xA0 Ch\u01B0a bao g\u1ED3m thu\u1EBF v\xE0 ph\xED v\u1EADn chuy\u1EC3n");
|
|
656
|
+
}
|
|
657
|
+
|
|
658
|
+
let seccls = '';
|
|
659
|
+
if (this.isMobile()) seccls = 'order_section';
|
|
660
|
+
return (0, _preact.h)(_preact.Fragment, null, (0, _preact.h)("div", {
|
|
661
|
+
class: "order_section__line"
|
|
662
|
+
}), (0, _preact.h)("div", {
|
|
663
|
+
class: seccls
|
|
664
|
+
}, (0, _preact.h)("div", {
|
|
665
|
+
class: "order_label"
|
|
666
|
+
}, "T\xF3m t\u1EAFt"), (0, _preact.h)("div", {
|
|
667
|
+
class: "order_summary_line"
|
|
668
|
+
}, (0, _preact.h)("div", null, "T\u1ED5ng ti\u1EC1n h\xE0ng"), (0, _preact.h)("div", null, _index.default.formatCurrency(order.subtotal))), $tax, $discount, $ship, $note, (0, _preact.h)("div", {
|
|
669
|
+
class: "order_summary_line",
|
|
670
|
+
style: "margin-top: 10px !important; padding-top: 15px !important; border-top: 1px solid #eee !important"
|
|
671
|
+
}, (0, _preact.h)("div", null, "B\u1EA1n ph\u1EA3i tr\u1EA3"), (0, _preact.h)("div", {
|
|
672
|
+
class: "order__total"
|
|
673
|
+
}, _index.default.formatCurrency(order.total))), $pay));
|
|
674
|
+
}
|
|
675
|
+
|
|
676
|
+
renderStatusBadge(order) {
|
|
677
|
+
let status = order.status || 'new';
|
|
678
|
+
return (0, _preact.h)("div", {
|
|
679
|
+
style: "float: right !important;",
|
|
680
|
+
class: 'order_status order_status__' + status
|
|
681
|
+
}, status);
|
|
682
|
+
}
|
|
683
|
+
|
|
684
|
+
renderShippingInfo(order) {
|
|
685
|
+
if (order.status != 'new' || order.user_confirmation) {}
|
|
686
|
+
|
|
687
|
+
let shipping_provider = _index.default.get(order, 'shipping.shipping_provider');
|
|
688
|
+
|
|
689
|
+
if (!shipping_provider) return null;
|
|
690
|
+
|
|
691
|
+
let shipping_code = _index.default.get(order, 'shipping.shipping_code');
|
|
692
|
+
|
|
693
|
+
let $tracking_code = null;
|
|
694
|
+
if (shipping_code) $tracking_code = (0, _preact.h)("div", {
|
|
695
|
+
class: "muted",
|
|
696
|
+
style: "margin-top: 3px !important"
|
|
697
|
+
}, "V\u1EADn \u0111\u01A1n\xA0", (0, _preact.h)("a", {
|
|
698
|
+
class: "order_tracking_link",
|
|
699
|
+
target: "_blank",
|
|
700
|
+
href: 'https://giaohangtietkiem.vn/tra-cuu-van-don/' + shipping_code
|
|
701
|
+
}, shipping_code, "\xA0", (0, _preact.h)("img", {
|
|
702
|
+
class: "order_tracking_link_icon",
|
|
703
|
+
src: require('../../assets/img/external-link.svg')
|
|
704
|
+
})));
|
|
705
|
+
|
|
706
|
+
if (shipping_provider == 'ghtk') {
|
|
707
|
+
return (0, _preact.h)("div", {
|
|
708
|
+
class: "order_section"
|
|
709
|
+
}, (0, _preact.h)("div", {
|
|
710
|
+
class: "order_section_label"
|
|
711
|
+
}, "\u0110\u01A1n v\u1ECB v\u1EADn chuy\u1EC3n"), (0, _preact.h)("div", {
|
|
712
|
+
class: "d-flex align-items-center"
|
|
713
|
+
}, (0, _preact.h)("img", {
|
|
714
|
+
class: "order_shipping_provider_logo",
|
|
715
|
+
src: ShippingProvider.ghtk.logo
|
|
716
|
+
}), (0, _preact.h)("div", null, ShippingProvider.ghtk.name, $tracking_code)));
|
|
717
|
+
}
|
|
718
|
+
|
|
719
|
+
return null;
|
|
720
|
+
}
|
|
721
|
+
|
|
722
|
+
renderDesktopShippingInfo(order) {
|
|
723
|
+
let shipping_provider = _index.default.get(order, 'shipping.shipping_provider');
|
|
724
|
+
|
|
725
|
+
if (!shipping_provider) return null;
|
|
726
|
+
|
|
727
|
+
let shipping_code = _index.default.get(order, 'shipping.shipping_code');
|
|
728
|
+
|
|
729
|
+
let $tracking_code = null;
|
|
730
|
+
if (shipping_code) $tracking_code = (0, _preact.h)("div", {
|
|
731
|
+
class: "muted",
|
|
732
|
+
style: "margin-top: 3px !important"
|
|
733
|
+
}, "V\u1EADn \u0111\u01A1n\xA0", (0, _preact.h)("a", {
|
|
734
|
+
class: "order_tracking_link",
|
|
735
|
+
target: "_blank",
|
|
736
|
+
href: 'https://giaohangtietkiem.vn/tra-cuu-van-don/' + shipping_code
|
|
737
|
+
}, shipping_code, "\xA0", (0, _preact.h)("img", {
|
|
738
|
+
class: "order_tracking_link_icon",
|
|
739
|
+
src: require('../../assets/img/external-link.svg')
|
|
740
|
+
})));
|
|
741
|
+
|
|
742
|
+
if (shipping_provider == 'ghtk') {
|
|
743
|
+
return (0, _preact.h)(_preact.Fragment, null, (0, _preact.h)("div", {
|
|
744
|
+
class: "order_label"
|
|
745
|
+
}, "\u0110\u01A1n v\u1ECB v\u1EADn chuy\u1EC3n"), (0, _preact.h)("div", {
|
|
746
|
+
class: "d-flex align-items-center"
|
|
747
|
+
}, (0, _preact.h)("img", {
|
|
748
|
+
class: "order_shipping_provider_logo",
|
|
749
|
+
src: ShippingProvider.ghtk.logo
|
|
750
|
+
}), (0, _preact.h)("div", null, ShippingProvider.ghtk.name, $tracking_code)));
|
|
751
|
+
}
|
|
752
|
+
|
|
753
|
+
return null;
|
|
754
|
+
}
|
|
755
|
+
|
|
756
|
+
renderProducts(order) {
|
|
757
|
+
let $products = null;
|
|
758
|
+
$products = _index.default.map(order.items, item => {
|
|
759
|
+
if (!item || !item.product) return null;
|
|
760
|
+
let product = item.product;
|
|
761
|
+
return (0, _preact.h)("div", {
|
|
762
|
+
class: "order_attachment__product"
|
|
763
|
+
}, (0, _preact.h)("img", {
|
|
764
|
+
class: "order_attachment__product_img",
|
|
765
|
+
alt: '' + product.id,
|
|
766
|
+
src: _index.default.get(product, 'images.0') || require('../../assets/img/default.jpg')
|
|
767
|
+
}), (0, _preact.h)("div", {
|
|
768
|
+
style: "overflow: hidden !important;"
|
|
769
|
+
}, (0, _preact.h)("div", {
|
|
770
|
+
class: "order_attachment__product_name"
|
|
771
|
+
}, product.name), (0, _preact.h)("div", {
|
|
772
|
+
class: "order_attachment__product_desc"
|
|
773
|
+
}, product.description || product.long_description), (0, _preact.h)("div", {
|
|
774
|
+
class: "order_attachment__product_desc"
|
|
775
|
+
}, this.props.t('qty'), " ", item.quantity, "\xA0\xB7\xA0", _index.default.formatCurrency(product.price))));
|
|
776
|
+
});
|
|
777
|
+
if (!this.isMobile()) return (0, _preact.h)("div", null, (0, _preact.h)("div", {
|
|
778
|
+
class: "order_label"
|
|
779
|
+
}, this.props.t('product')), $products);
|
|
780
|
+
return (0, _preact.h)("div", {
|
|
781
|
+
class: "order_section"
|
|
782
|
+
}, (0, _preact.h)("div", {
|
|
783
|
+
class: "order_section_label"
|
|
784
|
+
}, this.props.t('product')), $products);
|
|
785
|
+
}
|
|
786
|
+
|
|
787
|
+
onChangeQuantity = (item, text) => {
|
|
788
|
+
let qty = parseInt(text) || 1;
|
|
789
|
+
item.quantity = qty;
|
|
790
|
+
this.forceUpdate();
|
|
791
|
+
};
|
|
792
|
+
|
|
793
|
+
renderDesktopProducts(order) {
|
|
794
|
+
let $products = null;
|
|
795
|
+
let editmode = false;
|
|
796
|
+
|
|
797
|
+
if (!order.status || order.status == 'new') {
|
|
798
|
+
editmode = !order.user_confirmation;
|
|
799
|
+
}
|
|
800
|
+
|
|
801
|
+
if (editmode) {
|
|
802
|
+
$products = _index.default.map(order.items, item => {
|
|
803
|
+
if (!item || !item.product) return null;
|
|
804
|
+
let product = item.product;
|
|
805
|
+
return (0, _preact.h)("div", {
|
|
806
|
+
class: "order_attachment__product"
|
|
807
|
+
}, (0, _preact.h)("img", {
|
|
808
|
+
class: "order_attachment__product_img",
|
|
809
|
+
alt: '' + product.id,
|
|
810
|
+
src: _index.default.get(product, 'images.0') || require('../../assets/img/default.jpg')
|
|
811
|
+
}), (0, _preact.h)("div", {
|
|
812
|
+
style: "overflow: hidden !important; flex: 1 !important"
|
|
813
|
+
}, (0, _preact.h)("div", {
|
|
814
|
+
class: "order_attachment__product_name"
|
|
815
|
+
}, product.name), (0, _preact.h)("div", {
|
|
816
|
+
class: "order_attachment__product_desc"
|
|
817
|
+
}, product.description || product.long_description), (0, _preact.h)("div", {
|
|
818
|
+
class: "order_attachment__product_desc"
|
|
819
|
+
}, _index.default.formatCurrency(product.price))), (0, _preact.h)("input", {
|
|
820
|
+
class: "form-control",
|
|
821
|
+
style: "text-align: center !important; font-weight: 400 !important; width: 50px !important",
|
|
822
|
+
value: item.quantity,
|
|
823
|
+
onInput: e => this.onChangeQuantity(item, e.target.value),
|
|
824
|
+
type: "text"
|
|
825
|
+
}), (0, _preact.h)("div", {
|
|
826
|
+
style: "width: 80px !important; text-align: right !important; "
|
|
827
|
+
}, (0, _preact.h)("b", null, _index.default.formatCurrency(item.quantity * product.price))));
|
|
828
|
+
});
|
|
829
|
+
} else {
|
|
830
|
+
$products = _index.default.map(order.items, item => {
|
|
831
|
+
if (!item || !item.product) return null;
|
|
832
|
+
let product = item.product;
|
|
833
|
+
return (0, _preact.h)("div", {
|
|
834
|
+
class: "order_attachment__product"
|
|
835
|
+
}, (0, _preact.h)("img", {
|
|
836
|
+
class: "order_attachment__product_img",
|
|
837
|
+
alt: '' + product.id,
|
|
838
|
+
src: _index.default.get(product, 'images.0') || require('../../assets/img/default.jpg')
|
|
839
|
+
}), (0, _preact.h)("div", {
|
|
840
|
+
style: "overflow: hidden !important; flex: 1 !important"
|
|
841
|
+
}, (0, _preact.h)("div", {
|
|
842
|
+
class: "order_attachment__product_name"
|
|
843
|
+
}, product.name), (0, _preact.h)("div", {
|
|
844
|
+
class: "order_attachment__product_desc"
|
|
845
|
+
}, product.description || product.long_description), (0, _preact.h)("div", {
|
|
846
|
+
class: "order_attachment__product_desc"
|
|
847
|
+
}, _index.default.formatCurrency(product.price))), (0, _preact.h)("div", {
|
|
848
|
+
style: "text-align: center !important; font-weight: 400 !important; width: 50px !important"
|
|
849
|
+
}, item.quantity), (0, _preact.h)("div", {
|
|
850
|
+
style: "width: 80px !important; text-align: right !important; "
|
|
851
|
+
}, (0, _preact.h)("b", null, _index.default.formatCurrency(item.total))));
|
|
852
|
+
});
|
|
853
|
+
}
|
|
854
|
+
|
|
855
|
+
return (0, _preact.h)("div", {
|
|
856
|
+
class: "card_section"
|
|
857
|
+
}, (0, _preact.h)("div", {
|
|
858
|
+
class: "desktop_order__heading"
|
|
859
|
+
}, this.renderStatusBadge(order), (0, _preact.h)("b", {
|
|
860
|
+
style: "font-size: 18px !important;"
|
|
861
|
+
}, this.props.t('order'), " #", order.order_number || order.id), (0, _preact.h)("div", {
|
|
862
|
+
class: "muted"
|
|
863
|
+
}, (0, _preact.h)(_time.default, {
|
|
864
|
+
style: "font-size: 13px !important;",
|
|
865
|
+
time: order.issue_date || order.created
|
|
866
|
+
}))), (0, _preact.h)("div", {
|
|
867
|
+
class: "order_label d-flex",
|
|
868
|
+
style: "margin-top: 20px !important;justify-content: space-between !important; align-items: flex-end !important;"
|
|
869
|
+
}, (0, _preact.h)("div", {
|
|
870
|
+
style: "flex: 1 !important;"
|
|
871
|
+
}, this.props.t('product')), (0, _preact.h)("div", {
|
|
872
|
+
style: "font-weight: 400 !important; text-align:center !important; width: 50px !important"
|
|
873
|
+
}, this.props.t('qty')), (0, _preact.h)("div", {
|
|
874
|
+
style: "font-weight: 400 !important; text-align: right !important; width: 80px !important;"
|
|
875
|
+
}, this.props.t('total'))), $products);
|
|
876
|
+
}
|
|
877
|
+
|
|
878
|
+
renderMobile(order) {
|
|
879
|
+
if (this.state.step === 'success') return this.renderMobileSuccess(order);
|
|
880
|
+
let $error = null;
|
|
881
|
+
|
|
882
|
+
if (this.state.g_err) {
|
|
883
|
+
$error = (0, _preact.h)("div", {
|
|
884
|
+
class: "mb-2 text__danger"
|
|
885
|
+
}, (0, _preact.h)("img", {
|
|
886
|
+
style: "margin-top: -4px !important; height: 15px !important;",
|
|
887
|
+
src: ximg
|
|
888
|
+
}), "\xA0", (0, _preact.h)("b", null, this.state.g_err));
|
|
889
|
+
}
|
|
890
|
+
|
|
891
|
+
let $status = (0, _preact.h)("div", null, $error, (0, _preact.h)("div", {
|
|
892
|
+
class: "btn-confirm-order",
|
|
893
|
+
style: "margin-top: 0 !important;",
|
|
894
|
+
onClick: this.confirm
|
|
895
|
+
}, this.props.t('confirm_order')));
|
|
896
|
+
let $close = (0, _preact.h)("div", {
|
|
897
|
+
class: "order_btn order__btn__light mt-3",
|
|
898
|
+
onClick: this.onCancel
|
|
899
|
+
}, this.props.t('cancel_order'));
|
|
900
|
+
|
|
901
|
+
if (order.user_confirmation || order.status != 'new') {
|
|
902
|
+
$status = null;
|
|
903
|
+
if (this.props.cid) $close = (0, _preact.h)("div", {
|
|
904
|
+
class: "order_btn order__btn__light mt-3",
|
|
905
|
+
onClick: this.close
|
|
906
|
+
}, this.props.t('close'));
|
|
907
|
+
}
|
|
908
|
+
|
|
909
|
+
return (0, _preact.h)("div", {
|
|
910
|
+
class: "order",
|
|
911
|
+
style: "height: 100% !important"
|
|
912
|
+
}, (0, _preact.h)("div", {
|
|
913
|
+
class: "order--content"
|
|
914
|
+
}, (0, _preact.h)("div", {
|
|
915
|
+
class: "order--heading"
|
|
916
|
+
}, this.renderStatusBadge(order), (0, _preact.h)("b", {
|
|
917
|
+
style: "font-size: 16px !important;"
|
|
918
|
+
}, this.props.t('order'), " #", order.order_number || order.id), (0, _preact.h)("div", {
|
|
919
|
+
class: "muted"
|
|
920
|
+
}, (0, _preact.h)(_time.default, {
|
|
921
|
+
style: "font-size: 13px !important;",
|
|
922
|
+
time: order.issue_date || order.created
|
|
923
|
+
}))), this.renderProducts(order), this.renderDesktopShipping(order), this.renderShippingInfo(order), this.renderDesktopPaymentMethod(order), this.renderDesktopSummary(order), (0, _preact.h)("div", {
|
|
924
|
+
class: "order_section pb-3",
|
|
925
|
+
style: "padding-top: 0 !important;"
|
|
926
|
+
}, $status, $close)));
|
|
927
|
+
}
|
|
928
|
+
|
|
929
|
+
renderActions(order) {
|
|
930
|
+
let $actions = null;
|
|
931
|
+
let editmode = false;
|
|
932
|
+
|
|
933
|
+
if (!order.status || order.status == 'new') {
|
|
934
|
+
editmode = !order.user_confirmation;
|
|
935
|
+
}
|
|
936
|
+
|
|
937
|
+
if (this.state.step === 'success') return (0, _preact.h)("div", {
|
|
938
|
+
class: "d-flex",
|
|
939
|
+
style: "align-items: center !important; justify-content: flex-end !important"
|
|
940
|
+
}, (0, _preact.h)("div", null, "Ghi nh\u1EADn th\xE0nh c\xF4ng"), "\xA0", (0, _preact.h)("img", {
|
|
941
|
+
style: "width: 16px !important; height: 16px !important;",
|
|
942
|
+
width: "16",
|
|
943
|
+
height: "16",
|
|
944
|
+
src: checkedimg
|
|
945
|
+
}));
|
|
946
|
+
|
|
947
|
+
if (editmode) {
|
|
948
|
+
let $error = null;
|
|
949
|
+
|
|
950
|
+
if (this.state.g_err) {
|
|
951
|
+
$error = (0, _preact.h)("div", {
|
|
952
|
+
class: "mb-2 text__danger"
|
|
953
|
+
}, (0, _preact.h)("img", {
|
|
954
|
+
style: "margin-top: -4px !important; height: 15px !important;",
|
|
955
|
+
src: ximg
|
|
956
|
+
}), "\xA0", (0, _preact.h)("b", null, this.state.g_err));
|
|
957
|
+
}
|
|
958
|
+
|
|
959
|
+
$actions = (0, _preact.h)("div", null, $error, (0, _preact.h)("div", {
|
|
960
|
+
class: "btn-confirm-order",
|
|
961
|
+
onClick: this.confirm
|
|
962
|
+
}, this.props.t('confirm_order')), (0, _preact.h)("div", {
|
|
963
|
+
class: "btn-cancel-order",
|
|
964
|
+
onClick: this.onCancel
|
|
965
|
+
}, this.props.t('cancel_order')));
|
|
966
|
+
}
|
|
967
|
+
|
|
968
|
+
return $actions;
|
|
969
|
+
}
|
|
970
|
+
|
|
971
|
+
renderDesktop(order) {
|
|
972
|
+
let acc = this.props.store.matchAccount();
|
|
973
|
+
|
|
974
|
+
var uri = acc.logo_url || require('../../assets/img/image_default.png');
|
|
975
|
+
|
|
976
|
+
return (0, _preact.h)("div", {
|
|
977
|
+
class: "desktop order"
|
|
978
|
+
}, (0, _preact.h)("div", {
|
|
979
|
+
class: "order_acc_header"
|
|
980
|
+
}, (0, _preact.h)("img", {
|
|
981
|
+
class: "order_acc_logo",
|
|
982
|
+
src: uri
|
|
983
|
+
}), (0, _preact.h)("div", {
|
|
984
|
+
class: "order_acc_name"
|
|
985
|
+
}, acc.name)), (0, _preact.h)("div", {
|
|
986
|
+
class: "desktop_order__content"
|
|
987
|
+
}, (0, _preact.h)("div", {
|
|
988
|
+
style: "flex: 1 !important; padding-right: 20px !important;"
|
|
989
|
+
}, this.renderDesktopProducts(order), this.renderDesktopShipping(order), this.renderDesktopShippingInfo(order), this.renderDesktopPaymentMethod(order), (0, _preact.h)("div", {
|
|
990
|
+
class: "order__footer"
|
|
991
|
+
}, (0, _preact.h)("a", {
|
|
992
|
+
target: "_blank",
|
|
993
|
+
href: "https://subiz.com.vn",
|
|
994
|
+
class: "order__footer_link"
|
|
995
|
+
}, "Cung c\u1EA5p b\u1EDFi ", (0, _preact.h)("b", null, "Subiz")), (0, _preact.h)("div", {
|
|
996
|
+
class: "order__footer_delimiter"
|
|
997
|
+
}), (0, _preact.h)("a", {
|
|
998
|
+
target: "_blank",
|
|
999
|
+
href: "https://subiz.com.vn/vi/terms-of-service.html",
|
|
1000
|
+
class: "order__footer_link"
|
|
1001
|
+
}, "\u0110i\u1EC1u kho\u1EA3n"), (0, _preact.h)("a", {
|
|
1002
|
+
target: "_blank",
|
|
1003
|
+
href: "https://subiz.com.vn/vi/privacy-policy.html",
|
|
1004
|
+
class: "order__footer_link"
|
|
1005
|
+
}, "Quy\u1EC1n ri\xEAng t\u01B0"))), (0, _preact.h)("div", null, (0, _preact.h)("div", {
|
|
1006
|
+
class: "order_recap"
|
|
1007
|
+
}, this.renderDesktopSummary(order), this.renderActions(order)))));
|
|
1008
|
+
}
|
|
1009
|
+
|
|
1010
|
+
render() {
|
|
1011
|
+
if (this.state.loading) return (0, _preact.h)("div", {
|
|
1012
|
+
class: "order_error"
|
|
1013
|
+
}, (0, _preact.h)(_spinner.default, {
|
|
1014
|
+
class: "mt-4",
|
|
1015
|
+
size: "60",
|
|
1016
|
+
static: true
|
|
1017
|
+
}));
|
|
1018
|
+
if (this.state.error) return (0, _preact.h)("div", {
|
|
1019
|
+
class: "order_error"
|
|
1020
|
+
}, (0, _preact.h)("img", {
|
|
1021
|
+
class: "mt-3",
|
|
1022
|
+
src: require('../../assets/img/empty_1.svg')
|
|
1023
|
+
}), (0, _preact.h)("div", {
|
|
1024
|
+
class: "mt-3"
|
|
1025
|
+
}, this.props.t('order_load_error')));
|
|
1026
|
+
let order = this.state.order;
|
|
1027
|
+
if (this.isMobile()) return this.renderMobile(order);
|
|
1028
|
+
return this.renderDesktop(order);
|
|
1029
|
+
}
|
|
1030
|
+
|
|
1031
|
+
confirm = async () => {
|
|
1032
|
+
this.setState({
|
|
1033
|
+
g_err: ''
|
|
1034
|
+
});
|
|
1035
|
+
let err = {};
|
|
1036
|
+
|
|
1037
|
+
if (!this.state.shipping) {
|
|
1038
|
+
this.setState({
|
|
1039
|
+
g_err: 'Mời bạn chọn địa chỉ giao hàng trước khi xác nhận'
|
|
1040
|
+
});
|
|
1041
|
+
}
|
|
1042
|
+
|
|
1043
|
+
if (this.state.shipping === 'shop') {
|
|
1044
|
+
if (!_index.default.isPhone(this.state.phone)) {
|
|
1045
|
+
err.phone = true;
|
|
1046
|
+
}
|
|
1047
|
+
|
|
1048
|
+
if (!_index.default.trim(this.state.fullname)) {
|
|
1049
|
+
err.name = true;
|
|
1050
|
+
}
|
|
1051
|
+
|
|
1052
|
+
if (!_index.default.trim(this.state.email)) {
|
|
1053
|
+
err.email = true;
|
|
1054
|
+
}
|
|
1055
|
+
} else if (this.state.shipping_address == 'new') {
|
|
1056
|
+
if (!_index.default.isPhone(this.state.phone)) {
|
|
1057
|
+
err.phone = true;
|
|
1058
|
+
}
|
|
1059
|
+
|
|
1060
|
+
if (!_index.default.trim(this.state.fullname)) {
|
|
1061
|
+
err.name = true;
|
|
1062
|
+
}
|
|
1063
|
+
|
|
1064
|
+
if (!_index.default.trim(this.state.address)) {
|
|
1065
|
+
err.address = true;
|
|
1066
|
+
}
|
|
1067
|
+
|
|
1068
|
+
if (_index.default.size(this.state.selectedWard) == 0) {
|
|
1069
|
+
err.ward = true;
|
|
1070
|
+
}
|
|
1071
|
+
|
|
1072
|
+
if (_index.default.size(this.state.selectedDistrict) == 0) {
|
|
1073
|
+
err.district = true;
|
|
1074
|
+
}
|
|
1075
|
+
|
|
1076
|
+
if (_index.default.size(this.state.selectedProvince) == 0) {
|
|
1077
|
+
err.province = true;
|
|
1078
|
+
}
|
|
1079
|
+
}
|
|
1080
|
+
|
|
1081
|
+
if (_index.default.size(err) > 0) {
|
|
1082
|
+
this.setState({
|
|
1083
|
+
err,
|
|
1084
|
+
g_err: this.props.t('input_shipping_info_err')
|
|
1085
|
+
});
|
|
1086
|
+
return;
|
|
1087
|
+
}
|
|
1088
|
+
|
|
1089
|
+
let user = this.props.store.matchUser();
|
|
1090
|
+
|
|
1091
|
+
let ufullname = _index.default.getUserAttr(user, 'fullname', 'text');
|
|
1092
|
+
|
|
1093
|
+
let uemail = _index.default.getUserAttr(user, 'emails', 'text');
|
|
1094
|
+
|
|
1095
|
+
let uphone = _index.default.getUserAttr(user, 'phones', 'text');
|
|
1096
|
+
|
|
1097
|
+
let order = _index.default.cloneDeep(this.state.order);
|
|
1098
|
+
|
|
1099
|
+
if (this.state.shipping === 'shop') {
|
|
1100
|
+
_index.default.set(order, 'shipping.pickup_at_shop', true);
|
|
1101
|
+
|
|
1102
|
+
_index.default.set(order, 'shipping.address.phone', this.state.phone);
|
|
1103
|
+
|
|
1104
|
+
_index.default.set(order, 'shipping.address.fullname', this.state.fullname);
|
|
1105
|
+
|
|
1106
|
+
_index.default.set(order, 'shipping.address.email', this.state.email);
|
|
1107
|
+
} else {
|
|
1108
|
+
if (this.state.shipping_address == 'new') {
|
|
1109
|
+
let out = await this.props.store.createShippingAddress({
|
|
1110
|
+
address: this.state.address,
|
|
1111
|
+
country: 'Việt Nam',
|
|
1112
|
+
fullname: this.state.fullname,
|
|
1113
|
+
email: this.state.email,
|
|
1114
|
+
phone: this.state.phone,
|
|
1115
|
+
district: this.state.selectedDistrict.name,
|
|
1116
|
+
district_id: this.state.selectedDistrict.id,
|
|
1117
|
+
province: this.state.selectedProvince.name,
|
|
1118
|
+
province_id: this.state.selectedProvince.id,
|
|
1119
|
+
ward: this.state.selectedWard.name,
|
|
1120
|
+
street: this.state.street,
|
|
1121
|
+
ward_id: this.state.selectedWard.id
|
|
1122
|
+
});
|
|
1123
|
+
if (out.error) return this.setState({
|
|
1124
|
+
g_err: this.props.t('update_failed')
|
|
1125
|
+
});
|
|
1126
|
+
|
|
1127
|
+
_index.default.set(order, 'shipping.address', out.body);
|
|
1128
|
+
} else {
|
|
1129
|
+
let addresses = this.props.store.matchShippingAddresses();
|
|
1130
|
+
|
|
1131
|
+
let sa = _index.default.find(addresses, addr => addr.id === this.state.shipping_address);
|
|
1132
|
+
|
|
1133
|
+
if (!sa) {
|
|
1134
|
+
return this.setState({
|
|
1135
|
+
err,
|
|
1136
|
+
g_err: this.props.t('input_shipping_info_err')
|
|
1137
|
+
});
|
|
1138
|
+
}
|
|
1139
|
+
|
|
1140
|
+
_index.default.set(order, 'shipping.address', sa);
|
|
1141
|
+
}
|
|
1142
|
+
}
|
|
1143
|
+
|
|
1144
|
+
let changeduser = false;
|
|
1145
|
+
|
|
1146
|
+
if (!ufullname && this.state.fullname) {
|
|
1147
|
+
changeduser = true;
|
|
1148
|
+
|
|
1149
|
+
_index.default.setUserAttr(user, {
|
|
1150
|
+
key: 'fullname',
|
|
1151
|
+
text: this.state.fullname
|
|
1152
|
+
});
|
|
1153
|
+
}
|
|
1154
|
+
|
|
1155
|
+
if (!uemail && this.state.email) {
|
|
1156
|
+
changeduser = true;
|
|
1157
|
+
|
|
1158
|
+
_index.default.setUserAttr(user, {
|
|
1159
|
+
key: 'emails',
|
|
1160
|
+
text: this.state.email
|
|
1161
|
+
});
|
|
1162
|
+
}
|
|
1163
|
+
|
|
1164
|
+
if (!uphone && this.state.phone) {
|
|
1165
|
+
changeduser = true;
|
|
1166
|
+
|
|
1167
|
+
_index.default.setUserAttr(user, {
|
|
1168
|
+
key: 'phones',
|
|
1169
|
+
text: this.state.phone
|
|
1170
|
+
});
|
|
1171
|
+
}
|
|
1172
|
+
|
|
1173
|
+
if (changeduser) this.props.store.setUser(user);
|
|
1174
|
+
this.setState({
|
|
1175
|
+
sending: true
|
|
1176
|
+
});
|
|
1177
|
+
order.user_confirmation = 'confirmed';
|
|
1178
|
+
let out = await this.props.store.updateOrder(order);
|
|
1179
|
+
this.setState({
|
|
1180
|
+
sending: false
|
|
1181
|
+
});
|
|
1182
|
+
|
|
1183
|
+
if (out.error) {
|
|
1184
|
+
return this.setState({
|
|
1185
|
+
g_err: this.props.t('update_failed')
|
|
1186
|
+
});
|
|
1187
|
+
}
|
|
1188
|
+
|
|
1189
|
+
this.setState({
|
|
1190
|
+
step: 'success'
|
|
1191
|
+
});
|
|
1192
|
+
if (this.props.onResponse) this.props.onResponse('confirmed');
|
|
1193
|
+
};
|
|
1194
|
+
onCancel = () => {
|
|
1195
|
+
if (this.props.onResponse) this.props.onResponse('rejected');
|
|
1196
|
+
this.close();
|
|
1197
|
+
};
|
|
1198
|
+
close = () => {
|
|
1199
|
+
if (this.props.cid && !this.state.order.user_confirmation) {
|
|
1200
|
+
let order = _index.default.cloneDeep(this.state.order);
|
|
1201
|
+
|
|
1202
|
+
order.user_confirmation = 'rejected';
|
|
1203
|
+
this.props.store.updateOrder(order);
|
|
1204
|
+
}
|
|
1205
|
+
|
|
1206
|
+
if (this.props.onClose) this.props.onClose();
|
|
1207
|
+
};
|
|
1208
|
+
}
|
|
1209
|
+
|
|
1210
|
+
exports.default = Order;
|
|
1211
|
+
let ShippingProvider = {
|
|
1212
|
+
ghtk: {
|
|
1213
|
+
name: 'Giao hàng tiết kiệm',
|
|
1214
|
+
logo: require('../../assets/img/ghtk.svg')
|
|
1215
|
+
},
|
|
1216
|
+
ghn: {
|
|
1217
|
+
name: 'Giao hàng nhanh',
|
|
1218
|
+
logo: require('../../assets/img/ghn.svg')
|
|
1219
|
+
}
|
|
1220
|
+
};
|