@websolutespa/bom-mixer-checkout 1.8.0

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.
Files changed (169) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/README.md +11 -0
  3. package/dist/cjs/index.js +3298 -0
  4. package/dist/cjs/index.js.map +1 -0
  5. package/dist/esm/checkout/checkout-basket-item.js +129 -0
  6. package/dist/esm/checkout/checkout-basket-item.js.map +1 -0
  7. package/dist/esm/checkout/checkout-basket.js +193 -0
  8. package/dist/esm/checkout/checkout-basket.js.map +1 -0
  9. package/dist/esm/checkout/checkout-delivery.js +152 -0
  10. package/dist/esm/checkout/checkout-delivery.js.map +1 -0
  11. package/dist/esm/checkout/checkout-discount.js +70 -0
  12. package/dist/esm/checkout/checkout-discount.js.map +1 -0
  13. package/dist/esm/checkout/checkout-empty.js +40 -0
  14. package/dist/esm/checkout/checkout-empty.js.map +1 -0
  15. package/dist/esm/checkout/checkout-error.js +49 -0
  16. package/dist/esm/checkout/checkout-error.js.map +1 -0
  17. package/dist/esm/checkout/checkout-forgot-success.js +50 -0
  18. package/dist/esm/checkout/checkout-forgot-success.js.map +1 -0
  19. package/dist/esm/checkout/checkout-forgot.js +64 -0
  20. package/dist/esm/checkout/checkout-forgot.js.map +1 -0
  21. package/dist/esm/checkout/checkout-info.js +209 -0
  22. package/dist/esm/checkout/checkout-info.js.map +1 -0
  23. package/dist/esm/checkout/checkout-login.js +64 -0
  24. package/dist/esm/checkout/checkout-login.js.map +1 -0
  25. package/dist/esm/checkout/checkout-payment.js +147 -0
  26. package/dist/esm/checkout/checkout-payment.js.map +1 -0
  27. package/dist/esm/checkout/checkout-register-success.js +50 -0
  28. package/dist/esm/checkout/checkout-register-success.js.map +1 -0
  29. package/dist/esm/checkout/checkout-register.js +57 -0
  30. package/dist/esm/checkout/checkout-register.js.map +1 -0
  31. package/dist/esm/checkout/checkout-review.js +381 -0
  32. package/dist/esm/checkout/checkout-review.js.map +1 -0
  33. package/dist/esm/checkout/checkout-success.js +86 -0
  34. package/dist/esm/checkout/checkout-success.js.map +1 -0
  35. package/dist/esm/checkout/checkout-user-info.js +340 -0
  36. package/dist/esm/checkout/checkout-user-info.js.map +1 -0
  37. package/dist/esm/checkout/checkout-wizard.js +194 -0
  38. package/dist/esm/checkout/checkout-wizard.js.map +1 -0
  39. package/dist/esm/hooks/useCart/useCart.js +120 -0
  40. package/dist/esm/hooks/useCart/useCart.js.map +1 -0
  41. package/dist/esm/hooks/useCheckout/useCheckout.js +71 -0
  42. package/dist/esm/hooks/useCheckout/useCheckout.js.map +1 -0
  43. package/dist/esm/index.js +28 -0
  44. package/dist/esm/index.js.map +1 -0
  45. package/dist/esm/models/checkout/checkout.service.js +365 -0
  46. package/dist/esm/models/checkout/checkout.service.js.map +1 -0
  47. package/dist/esm/models/order/order.js +32 -0
  48. package/dist/esm/models/order/order.js.map +1 -0
  49. package/dist/esm/models/order/order.service.js +53 -0
  50. package/dist/esm/models/order/order.service.js.map +1 -0
  51. package/dist/esm/node_modules/tslib/tslib.es6.js +58 -0
  52. package/dist/esm/node_modules/tslib/tslib.es6.js.map +1 -0
  53. package/dist/esm/order/order-address.js +34 -0
  54. package/dist/esm/order/order-address.js.map +1 -0
  55. package/dist/esm/order/order-item.js +93 -0
  56. package/dist/esm/order/order-item.js.map +1 -0
  57. package/dist/esm/order/order-register.js +159 -0
  58. package/dist/esm/order/order-register.js.map +1 -0
  59. package/dist/esm/order/order-summary-item.js +67 -0
  60. package/dist/esm/order/order-summary-item.js.map +1 -0
  61. package/dist/esm/order/order-summary.js +147 -0
  62. package/dist/esm/order/order-summary.js.map +1 -0
  63. package/dist/types/checkout/checkout-basket-item.d.ts +6 -0
  64. package/dist/types/checkout/checkout-basket-item.d.ts.map +1 -0
  65. package/dist/types/checkout/checkout-basket.d.ts +7 -0
  66. package/dist/types/checkout/checkout-basket.d.ts.map +1 -0
  67. package/dist/types/checkout/checkout-delivery.d.ts +8 -0
  68. package/dist/types/checkout/checkout-delivery.d.ts.map +1 -0
  69. package/dist/types/checkout/checkout-discount.d.ts +7 -0
  70. package/dist/types/checkout/checkout-discount.d.ts.map +1 -0
  71. package/dist/types/checkout/checkout-empty.d.ts +4 -0
  72. package/dist/types/checkout/checkout-empty.d.ts.map +1 -0
  73. package/dist/types/checkout/checkout-error.d.ts +7 -0
  74. package/dist/types/checkout/checkout-error.d.ts.map +1 -0
  75. package/dist/types/checkout/checkout-forgot-success.d.ts +8 -0
  76. package/dist/types/checkout/checkout-forgot-success.d.ts.map +1 -0
  77. package/dist/types/checkout/checkout-forgot.d.ts +10 -0
  78. package/dist/types/checkout/checkout-forgot.d.ts.map +1 -0
  79. package/dist/types/checkout/checkout-info.d.ts +8 -0
  80. package/dist/types/checkout/checkout-info.d.ts.map +1 -0
  81. package/dist/types/checkout/checkout-login.d.ts +11 -0
  82. package/dist/types/checkout/checkout-login.d.ts.map +1 -0
  83. package/dist/types/checkout/checkout-payment.d.ts +8 -0
  84. package/dist/types/checkout/checkout-payment.d.ts.map +1 -0
  85. package/dist/types/checkout/checkout-register-success.d.ts +8 -0
  86. package/dist/types/checkout/checkout-register-success.d.ts.map +1 -0
  87. package/dist/types/checkout/checkout-register.d.ts +9 -0
  88. package/dist/types/checkout/checkout-register.d.ts.map +1 -0
  89. package/dist/types/checkout/checkout-review.d.ts +8 -0
  90. package/dist/types/checkout/checkout-review.d.ts.map +1 -0
  91. package/dist/types/checkout/checkout-success.d.ts +7 -0
  92. package/dist/types/checkout/checkout-success.d.ts.map +1 -0
  93. package/dist/types/checkout/checkout-user-info.d.ts +10 -0
  94. package/dist/types/checkout/checkout-user-info.d.ts.map +1 -0
  95. package/dist/types/checkout/checkout-wizard.d.ts +20 -0
  96. package/dist/types/checkout/checkout-wizard.d.ts.map +1 -0
  97. package/dist/types/checkout/index.d.ts +18 -0
  98. package/dist/types/checkout/index.d.ts.map +1 -0
  99. package/dist/types/hooks/index.d.ts +3 -0
  100. package/dist/types/hooks/index.d.ts.map +1 -0
  101. package/dist/types/hooks/useCart/useCart.d.ts +39 -0
  102. package/dist/types/hooks/useCart/useCart.d.ts.map +1 -0
  103. package/dist/types/hooks/useCheckout/useCheckout.d.ts +35 -0
  104. package/dist/types/hooks/useCheckout/useCheckout.d.ts.map +1 -0
  105. package/dist/types/index.d.ts +5 -0
  106. package/dist/types/index.d.ts.map +1 -0
  107. package/dist/types/models/cart/cart.d.ts +10 -0
  108. package/dist/types/models/cart/cart.d.ts.map +1 -0
  109. package/dist/types/models/checkout/checkout.d.ts +60 -0
  110. package/dist/types/models/checkout/checkout.d.ts.map +1 -0
  111. package/dist/types/models/checkout/checkout.service.d.ts +13 -0
  112. package/dist/types/models/checkout/checkout.service.d.ts.map +1 -0
  113. package/dist/types/models/index.d.ts +6 -0
  114. package/dist/types/models/index.d.ts.map +1 -0
  115. package/dist/types/models/order/order.d.ts +28 -0
  116. package/dist/types/models/order/order.d.ts.map +1 -0
  117. package/dist/types/models/order/order.service.d.ts +5 -0
  118. package/dist/types/models/order/order.service.d.ts.map +1 -0
  119. package/dist/types/order/index.d.ts +6 -0
  120. package/dist/types/order/index.d.ts.map +1 -0
  121. package/dist/types/order/order-address.d.ts +8 -0
  122. package/dist/types/order/order-address.d.ts.map +1 -0
  123. package/dist/types/order/order-item.d.ts +7 -0
  124. package/dist/types/order/order-item.d.ts.map +1 -0
  125. package/dist/types/order/order-register.d.ts +9 -0
  126. package/dist/types/order/order-register.d.ts.map +1 -0
  127. package/dist/types/order/order-summary-item.d.ts +6 -0
  128. package/dist/types/order/order-summary-item.d.ts.map +1 -0
  129. package/dist/types/order/order-summary.d.ts +7 -0
  130. package/dist/types/order/order-summary.d.ts.map +1 -0
  131. package/package.json +77 -0
  132. package/src/__tests/example.test.ts +8 -0
  133. package/src/checkout/checkout-basket-item.tsx +63 -0
  134. package/src/checkout/checkout-basket.tsx +116 -0
  135. package/src/checkout/checkout-delivery.tsx +120 -0
  136. package/src/checkout/checkout-discount.tsx +61 -0
  137. package/src/checkout/checkout-empty.tsx +25 -0
  138. package/src/checkout/checkout-error.tsx +31 -0
  139. package/src/checkout/checkout-forgot-success.tsx +41 -0
  140. package/src/checkout/checkout-forgot.tsx +55 -0
  141. package/src/checkout/checkout-info.tsx +144 -0
  142. package/src/checkout/checkout-login.tsx +55 -0
  143. package/src/checkout/checkout-payment.tsx +119 -0
  144. package/src/checkout/checkout-register-success.tsx +41 -0
  145. package/src/checkout/checkout-register.tsx +48 -0
  146. package/src/checkout/checkout-review.tsx +240 -0
  147. package/src/checkout/checkout-success.tsx +57 -0
  148. package/src/checkout/checkout-user-info.tsx +205 -0
  149. package/src/checkout/checkout-wizard.tsx +157 -0
  150. package/src/checkout/index.ts +18 -0
  151. package/src/hooks/index.ts +3 -0
  152. package/src/hooks/useCart/useCart.test.tsx +89 -0
  153. package/src/hooks/useCart/useCart.tsx +129 -0
  154. package/src/hooks/useCheckout/useCheckout.test.tsx +53 -0
  155. package/src/hooks/useCheckout/useCheckout.tsx +93 -0
  156. package/src/index.ts +5 -0
  157. package/src/models/cart/cart.ts +27 -0
  158. package/src/models/checkout/checkout.service.ts +347 -0
  159. package/src/models/checkout/checkout.ts +69 -0
  160. package/src/models/index.ts +6 -0
  161. package/src/models/order/order.service.ts +35 -0
  162. package/src/models/order/order.ts +31 -0
  163. package/src/order/index.ts +6 -0
  164. package/src/order/order-address.tsx +22 -0
  165. package/src/order/order-item.tsx +55 -0
  166. package/src/order/order-register.tsx +103 -0
  167. package/src/order/order-summary-item.tsx +37 -0
  168. package/src/order/order-summary.tsx +72 -0
  169. package/src/styled.d.ts +14 -0
@@ -0,0 +1,3298 @@
1
+ 'use strict';
2
+
3
+ var jsxRuntime = require('react/jsx-runtime');
4
+ var bomMixerHooks = require('@websolutespa/bom-mixer-hooks');
5
+ var bomMixerIcons = require('@websolutespa/bom-mixer-icons');
6
+ var bomMixerUi = require('@websolutespa/bom-mixer-ui');
7
+ var react = require('react');
8
+ var zustand = require('zustand');
9
+ var middleware = require('zustand/middleware');
10
+ var bomMixerForms = require('@websolutespa/bom-mixer-forms');
11
+ var bomMixerAuth = require('@websolutespa/bom-mixer-auth');
12
+ var bomCore = require('@websolutespa/bom-core');
13
+ var styled = require('styled-components');
14
+ var bomMixerModels = require('@websolutespa/bom-mixer-models');
15
+ var bomMixerStore = require('@websolutespa/bom-mixer-store');
16
+
17
+ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
18
+
19
+ var styled__default = /*#__PURE__*/_interopDefault(styled);
20
+
21
+ /******************************************************************************
22
+ Copyright (c) Microsoft Corporation.
23
+
24
+ Permission to use, copy, modify, and/or distribute this software for any
25
+ purpose with or without fee is hereby granted.
26
+
27
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
28
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
29
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
30
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
31
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
32
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
33
+ PERFORMANCE OF THIS SOFTWARE.
34
+ ***************************************************************************** */
35
+ /* global Reflect, Promise, SuppressedError, Symbol */
36
+
37
+ function __rest(s, e) {
38
+ var t = {};
39
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
40
+ if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
41
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
42
+ }
43
+ return t;
44
+ }
45
+ function __awaiter(thisArg, _arguments, P, generator) {
46
+ function adopt(value) {
47
+ return value instanceof P ? value : new P(function (resolve) {
48
+ resolve(value);
49
+ });
50
+ }
51
+ return new (P || (P = Promise))(function (resolve, reject) {
52
+ function fulfilled(value) {
53
+ try {
54
+ step(generator.next(value));
55
+ } catch (e) {
56
+ reject(e);
57
+ }
58
+ }
59
+ function rejected(value) {
60
+ try {
61
+ step(generator["throw"](value));
62
+ } catch (e) {
63
+ reject(e);
64
+ }
65
+ }
66
+ function step(result) {
67
+ result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
68
+ }
69
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
70
+ });
71
+ }
72
+ typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
73
+ var e = new Error(message);
74
+ return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
75
+ };
76
+
77
+ const createCartStore = _a => {
78
+ var {
79
+ storage
80
+ } = _a,
81
+ initialProps = __rest(_a, ["storage"]);
82
+ const DEFAULT_PROPS = {
83
+ hydrated: false,
84
+ items: []
85
+ };
86
+ const useStore = zustand.createStore()(middleware.persist((set, get) => Object.assign(Object.assign(Object.assign({}, DEFAULT_PROPS), initialProps), {
87
+ actions: {
88
+ count: () => {
89
+ return get().items.length;
90
+ },
91
+ has: item => {
92
+ return get().items.find(x => x.schema === item.schema && x.id === item.id) != null;
93
+ },
94
+ find: item => {
95
+ return get().items.find(x => x.schema === item.schema && x.id === item.id);
96
+ },
97
+ add: function (item, qty) {
98
+ if (qty === void 0) {
99
+ qty = 1;
100
+ }
101
+ return set(state => {
102
+ const items = state.items.slice();
103
+ const index = items.reduce((p, c, i) => c.schema === item.schema && c.id === item.id ? i : p, -1);
104
+ if (index === -1) {
105
+ items.push(Object.assign(Object.assign({}, item), {
106
+ qty
107
+ }));
108
+ }
109
+ return {
110
+ items
111
+ };
112
+ });
113
+ },
114
+ remove: item => {
115
+ let count = 0;
116
+ set(state => {
117
+ const items = state.items.slice();
118
+ const index = items.reduce((p, c, i) => c.schema === item.schema && c.id === item.id ? i : p, -1);
119
+ if (index !== -1) {
120
+ items.splice(index, 1);
121
+ }
122
+ count = items.length;
123
+ return {
124
+ items
125
+ };
126
+ });
127
+ return count;
128
+ },
129
+ update: item => set(state => {
130
+ const items = state.items.slice();
131
+ const index = items.reduce((p, c, i) => c.schema === item.schema && c.id === item.id ? i : p, -1);
132
+ if (index !== -1) {
133
+ items[index] = item;
134
+ }
135
+ return {
136
+ items
137
+ };
138
+ }),
139
+ clear: () => set(state => ({
140
+ items: []
141
+ }))
142
+ }
143
+ }), {
144
+ name: 'cart',
145
+ storage: middleware.createJSONStorage(() => storage || localStorage),
146
+ /*
147
+ getStorage: () => {
148
+ // console.log('useCart.getStorage');
149
+ return storage || localStorage;
150
+ },
151
+ */
152
+ onRehydrateStorage: () => () => {
153
+ useStore.setState({
154
+ hydrated: true
155
+ });
156
+ // console.log('onRehydrateStorage', useStore, useStore.getState());
157
+ },
158
+ merge: (persistedState, currentState) => {
159
+ if (persistedState.items && Array.isArray(persistedState.items)) {
160
+ currentState.items = [...persistedState.items];
161
+ }
162
+ currentState.hydrated = true;
163
+ return currentState;
164
+ }
165
+ }));
166
+ return useStore;
167
+ };
168
+ const CartContext = /*#__PURE__*/react.createContext(null);
169
+ function CartProvider(_a) {
170
+ var {
171
+ children
172
+ } = _a,
173
+ props = __rest(_a, ["children"]);
174
+ const storeRef = react.useRef();
175
+ if (!storeRef.current) {
176
+ storeRef.current = createCartStore(props);
177
+ }
178
+ return jsxRuntime.jsx(CartContext.Provider, {
179
+ value: storeRef.current,
180
+ children: children
181
+ });
182
+ }
183
+ function useCart(selector) {
184
+ const store = react.useContext(CartContext);
185
+ if (!store) throw new Error('Missing CartContext.Provider in the tree');
186
+ return zustand.useStore(store, selector);
187
+ }
188
+
189
+ const createCheckoutStore = _a => {
190
+ var {
191
+ storage
192
+ } = _a,
193
+ initialProps = __rest(_a, ["storage"]);
194
+ const DEFAULT_PROPS = {
195
+ hydrated: false,
196
+ checkout: {}
197
+ };
198
+ const useStore = zustand.createStore()(middleware.persist((set, get) => Object.assign(Object.assign(Object.assign({}, DEFAULT_PROPS), initialProps), {
199
+ actions: {
200
+ setCheckout: checkout => set(state => {
201
+ return {
202
+ checkout
203
+ };
204
+ })
205
+ }
206
+ }), {
207
+ name: 'checkout',
208
+ storage: middleware.createJSONStorage(() => storage || localStorage),
209
+ /*
210
+ getStorage: () => {
211
+ // console.log('useCheckout.getStorage');
212
+ return storage || localStorage;
213
+ },
214
+ */
215
+ onRehydrateStorage: () => () => {
216
+ useStore.setState({
217
+ hydrated: true
218
+ });
219
+ // console.log('onRehydrateStorage', useStore, useStore.getState());
220
+ },
221
+ merge: (persistedState, currentState) => {
222
+ if (persistedState.checkout && typeof persistedState.checkout === 'object') {
223
+ currentState.checkout = Object.assign({}, persistedState.checkout);
224
+ }
225
+ currentState.hydrated = true;
226
+ return currentState;
227
+ }
228
+ }));
229
+ return useStore;
230
+ };
231
+ const CheckoutContext = /*#__PURE__*/react.createContext(null);
232
+ function CheckoutProvider(_a) {
233
+ var {
234
+ children
235
+ } = _a,
236
+ props = __rest(_a, ["children"]);
237
+ const storeRef = react.useRef();
238
+ if (!storeRef.current) {
239
+ storeRef.current = createCheckoutStore(props);
240
+ }
241
+ return jsxRuntime.jsx(CheckoutContext.Provider, {
242
+ value: storeRef.current,
243
+ children: children
244
+ });
245
+ }
246
+ function useCheckout(selector) {
247
+ const store = react.useContext(CheckoutContext);
248
+ if (!store) throw new Error('Missing CheckoutContext.Provider in the tree');
249
+ return zustand.useStore(store, selector);
250
+ }
251
+
252
+ const CheckoutBasketItem = _ref => {
253
+ let {
254
+ item
255
+ } = _ref;
256
+ const currency = bomMixerHooks.useCurrency();
257
+ const {
258
+ update,
259
+ remove
260
+ } = useCart(state => state.actions);
261
+ function onSetQty(qty) {
262
+ if (qty > 0) {
263
+ update(Object.assign(Object.assign({}, item), {
264
+ qty
265
+ }));
266
+ } else {
267
+ onRemove();
268
+ }
269
+ }
270
+ function onRemove() {
271
+ const count = remove(item);
272
+ console.log('onRemove', count);
273
+ }
274
+ return jsxRuntime.jsxs(bomMixerUi.Flex.Row, {
275
+ gap: "2rem",
276
+ paddingBottom: "1rem",
277
+ borderBottom: "1px solid var(--color-neutral-300)",
278
+ children: [jsxRuntime.jsx(bomMixerUi.Flex, {
279
+ flex: "0 1 calc(100% - 420px)",
280
+ children: jsxRuntime.jsxs(bomMixerUi.Flex.Row, {
281
+ gap: "2rem",
282
+ children: [item.media && jsxRuntime.jsx(bomMixerUi.Media, {
283
+ item: item.media,
284
+ aspectRatio: 1,
285
+ width: "120px",
286
+ height: "120px",
287
+ flex: "0 0 120px",
288
+ rounded: true
289
+ }), jsxRuntime.jsxs(bomMixerUi.Flex.Col, {
290
+ alignItems: "flex-start",
291
+ children: [jsxRuntime.jsx(bomMixerUi.Link, {
292
+ href: item.href || '',
293
+ children: jsxRuntime.jsx(bomMixerUi.Button, {
294
+ as: "a",
295
+ variant: "nav",
296
+ children: jsxRuntime.jsx(bomMixerUi.Text, {
297
+ variant: "paragraph20",
298
+ fontWeight: "700",
299
+ children: item.title
300
+ })
301
+ })
302
+ }), jsxRuntime.jsx(bomMixerUi.Text, {
303
+ variant: "paragraph30",
304
+ children: item.abstract
305
+ })]
306
+ })]
307
+ })
308
+ }), jsxRuntime.jsxs(bomMixerUi.Flex.Col, {
309
+ flexBasis: "110px",
310
+ alignItems: "flex-end",
311
+ children: [jsxRuntime.jsx(bomMixerUi.Text, {
312
+ children: currency(item.price)
313
+ }), item.fullPrice > item.price && jsxRuntime.jsx(bomMixerUi.Text, {
314
+ variant: "paragraph40",
315
+ textDecoration: "line-through",
316
+ color: "var(--color-neutral-400)",
317
+ children: currency(item.fullPrice)
318
+ })]
319
+ }), jsxRuntime.jsx(bomMixerUi.Flex, {
320
+ flexBasis: "120px",
321
+ justifyContent: "center",
322
+ children: jsxRuntime.jsxs(bomMixerUi.Flex.Row, {
323
+ children: [jsxRuntime.jsx(bomMixerUi.Button, {
324
+ onClick: () => onSetQty(item.qty - 1),
325
+ children: jsxRuntime.jsx(bomMixerIcons.IconMinus, {
326
+ width: "20px",
327
+ height: "20px"
328
+ })
329
+ }), jsxRuntime.jsx(bomMixerUi.Input, {
330
+ width: "60px",
331
+ padding: "0.2rem",
332
+ placeholder: "qty",
333
+ value: item.qty.toString(),
334
+ onChange: e => onSetQty(Number(e.target.value))
335
+ }), jsxRuntime.jsx(bomMixerUi.Button, {
336
+ size: "xs",
337
+ onClick: () => onSetQty(item.qty + 1),
338
+ children: jsxRuntime.jsx(bomMixerIcons.IconPlus, {
339
+ width: "20px",
340
+ height: "20px"
341
+ })
342
+ })]
343
+ })
344
+ }), jsxRuntime.jsx(bomMixerUi.Flex, {
345
+ flexBasis: "80px",
346
+ justifyContent: "center",
347
+ children: jsxRuntime.jsx(bomMixerUi.Button, {
348
+ onClick: onRemove,
349
+ children: jsxRuntime.jsx(bomMixerIcons.IconTrash, {
350
+ width: "20px",
351
+ height: "20px"
352
+ })
353
+ })
354
+ }), jsxRuntime.jsxs(bomMixerUi.Flex.Col, {
355
+ flexBasis: "110px",
356
+ alignItems: "flex-end",
357
+ children: [jsxRuntime.jsx(bomMixerUi.Text, {
358
+ children: currency(item.price * item.qty)
359
+ }), item.fullPrice > item.price && jsxRuntime.jsx(bomMixerUi.Text, {
360
+ variant: "paragraph40",
361
+ textDecoration: "line-through",
362
+ color: "var(--color-neutral-400)",
363
+ children: currency(item.fullPrice * item.qty)
364
+ })]
365
+ })]
366
+ });
367
+ };
368
+
369
+ const CheckoutBasket = _ref => {
370
+ let {
371
+ onBasket
372
+ } = _ref;
373
+ bomMixerHooks.useLabel();
374
+ const layout = bomMixerHooks.useLayout();
375
+ const api = bomMixerHooks.useApi();
376
+ const currency = bomMixerHooks.useCurrency();
377
+ const cartItems = useCart(state => state.items);
378
+ const checkout = useCheckout(state => state.checkout);
379
+ const {
380
+ setCheckout
381
+ } = useCheckout(state => state.actions);
382
+ const [items = []] = bomMixerHooks.useApiPost('/checkout/items', Object.assign(Object.assign({}, checkout), {
383
+ items: cartItems
384
+ }));
385
+ const subTotal = items.reduce((p, c) => {
386
+ return p + c.price * c.qty;
387
+ }, 0);
388
+ const subTotalFull = items.reduce((p, c) => {
389
+ return p + c.fullPrice * c.qty;
390
+ }, 0);
391
+ const onBasket_ = () => __awaiter(void 0, void 0, void 0, function* () {
392
+ try {
393
+ const response = yield api.post('/checkout/update', {
394
+ action: 'basket',
395
+ checkout: Object.assign(Object.assign({}, checkout), {
396
+ items
397
+ })
398
+ });
399
+ setCheckout(response);
400
+ if (typeof onBasket === 'function') {
401
+ onBasket(items);
402
+ }
403
+ } catch (error) {
404
+ console.error('CheckoutBasket.onBasket_.error', error);
405
+ }
406
+ });
407
+ return jsxRuntime.jsxs(jsxRuntime.Fragment, {
408
+ children: [jsxRuntime.jsx(bomMixerUi.Section, {
409
+ children: jsxRuntime.jsxs(bomMixerUi.Container, {
410
+ minHeight: "50vh",
411
+ children: [jsxRuntime.jsxs(bomMixerUi.Flex.Row, {
412
+ gap: "2rem",
413
+ padding: "1rem 0",
414
+ fontWeight: "700",
415
+ children: [jsxRuntime.jsx(bomMixerUi.Text, {
416
+ flex: "0 1 calc(100% - 420px)",
417
+ children: "Product"
418
+ }), jsxRuntime.jsx(bomMixerUi.Text, {
419
+ flexBasis: "110px",
420
+ textAlign: "right",
421
+ children: "Unit price"
422
+ }), jsxRuntime.jsx(bomMixerUi.Text, {
423
+ flexBasis: "120px",
424
+ textAlign: "center",
425
+ children: "Quantity"
426
+ }), jsxRuntime.jsx(bomMixerUi.Text, {
427
+ flexBasis: "80px",
428
+ textAlign: "center",
429
+ children: "\u00A0"
430
+ }), jsxRuntime.jsx(bomMixerUi.Text, {
431
+ flexBasis: "110px",
432
+ textAlign: "right",
433
+ children: "Price"
434
+ })]
435
+ }), jsxRuntime.jsxs(bomMixerUi.Flex.Col, {
436
+ flex: "1",
437
+ gap: "1rem",
438
+ children: [items && items.map((item, i) => jsxRuntime.jsx(CheckoutBasketItem, {
439
+ item: item
440
+ }, i)), jsxRuntime.jsxs(bomMixerUi.Flex.Row, {
441
+ gap: "1rem",
442
+ fontWeight: "700",
443
+ marginBottom: "1rem",
444
+ children: [jsxRuntime.jsx(bomMixerUi.Text, {
445
+ flex: "0 1 calc(100% - 420px)",
446
+ children: "Subtotal"
447
+ }), jsxRuntime.jsx(bomMixerUi.Text, {
448
+ flexBasis: "110px",
449
+ textAlign: "right",
450
+ children: "\u00A0"
451
+ }), jsxRuntime.jsx(bomMixerUi.Text, {
452
+ flexBasis: "120px",
453
+ textAlign: "center",
454
+ children: "\u00A0"
455
+ }), jsxRuntime.jsx(bomMixerUi.Text, {
456
+ flexBasis: "80px",
457
+ textAlign: "center",
458
+ children: "\u00A0"
459
+ }), jsxRuntime.jsxs(bomMixerUi.Flex.Col, {
460
+ flexBasis: "110px",
461
+ alignItems: "flex-end",
462
+ textAlign: "right",
463
+ children: [jsxRuntime.jsx(bomMixerUi.Text, {
464
+ children: currency(subTotal)
465
+ }), subTotalFull > subTotal && jsxRuntime.jsx(bomMixerUi.Text, {
466
+ variant: "paragraph40",
467
+ textDecoration: "line-through",
468
+ color: "var(--color-neutral-400)",
469
+ children: currency(subTotalFull)
470
+ })]
471
+ })]
472
+ })]
473
+ }), jsxRuntime.jsxs(bomMixerUi.Flex.Col, {
474
+ gap: "1rem",
475
+ children: [jsxRuntime.jsx(bomMixerUi.Box, {
476
+ borderRadius: "0.5rem",
477
+ border: "1px solid var(--color-neutral-300)",
478
+ children: jsxRuntime.jsxs(bomMixerUi.Flex.Row, {
479
+ padding: "1rem",
480
+ children: [jsxRuntime.jsx(bomMixerIcons.IconTruck, {
481
+ width: "2rem",
482
+ height: "2rem",
483
+ color: "var(--color-primary-500)"
484
+ }), jsxRuntime.jsxs(bomMixerUi.Box, {
485
+ marginLeft: "0.5rem",
486
+ children: [jsxRuntime.jsx(bomMixerUi.Text, {
487
+ variant: "paragraph20",
488
+ fontWeight: "700",
489
+ children: "The shipping is on us"
490
+ }), jsxRuntime.jsx(bomMixerUi.Text, {
491
+ variant: "paragraph30",
492
+ children: "Free, contactless delivery for payments over the minimum fare."
493
+ })]
494
+ })]
495
+ })
496
+ }), jsxRuntime.jsx(bomMixerUi.Box, {
497
+ borderRadius: "0.5rem",
498
+ border: "1px solid var(--color-neutral-300)",
499
+ children: jsxRuntime.jsxs(bomMixerUi.Flex.Row, {
500
+ padding: "1rem",
501
+ children: [jsxRuntime.jsx(bomMixerIcons.IconPercent, {
502
+ width: "2rem",
503
+ height: "2rem",
504
+ color: "var(--color-primary-500)"
505
+ }), jsxRuntime.jsxs(bomMixerUi.Box, {
506
+ marginLeft: "0.5rem",
507
+ children: [jsxRuntime.jsx(bomMixerUi.Text, {
508
+ variant: "paragraph20",
509
+ fontWeight: "700",
510
+ children: "Do you have a discount code?"
511
+ }), jsxRuntime.jsx(bomMixerUi.Text, {
512
+ variant: "paragraph30",
513
+ children: "You can enter it in the following steps, before the final checkout."
514
+ })]
515
+ })]
516
+ })
517
+ })]
518
+ })]
519
+ })
520
+ }), jsxRuntime.jsx(bomMixerUi.Section, {
521
+ position: "sticky",
522
+ bottom: "0",
523
+ padding: "1rem 0",
524
+ zIndex: "800",
525
+ background: "var(--color-primary-100)",
526
+ children: jsxRuntime.jsx(bomMixerUi.Container, {
527
+ children: jsxRuntime.jsxs(bomMixerUi.Flex.Row, {
528
+ justifyContent: "space-between",
529
+ children: [jsxRuntime.jsx(bomMixerUi.Flex, {
530
+ children: jsxRuntime.jsx(bomMixerUi.NavLink, {
531
+ href: layout.topLevelHrefs.shop_index || '',
532
+ children: jsxRuntime.jsx(bomMixerUi.Button, {
533
+ as: "a",
534
+ variant: "link",
535
+ children: "Continue shopping"
536
+ })
537
+ })
538
+ }), jsxRuntime.jsx(bomMixerUi.Flex, {
539
+ children: jsxRuntime.jsx(bomMixerUi.Button, {
540
+ variant: "primary",
541
+ onClick: onBasket_,
542
+ children: "Proceed"
543
+ })
544
+ })]
545
+ })
546
+ })
547
+ })]
548
+ });
549
+ };
550
+
551
+ const CheckoutDelivery = _ref => {
552
+ let {
553
+ onPrevious,
554
+ onDelivery
555
+ } = _ref;
556
+ var _a, _b;
557
+ const label = bomMixerHooks.useLabel();
558
+ const currency = bomMixerHooks.useCurrency();
559
+ const api = bomMixerHooks.useApi();
560
+ const checkout = useCheckout(state => state.checkout);
561
+ const {
562
+ setCheckout
563
+ } = useCheckout(state => state.actions);
564
+ const [options] = bomMixerHooks.useApiPost('/checkout/deliveries', checkout);
565
+ const [error, setError] = react.useState();
566
+ const required = bomMixerForms.RequiredValidator();
567
+ const [form, setValue, setTouched, reset, group] = bomMixerForms.useFormBuilder({
568
+ delivery: {
569
+ schema: 'card',
570
+ label: 'field.delivery',
571
+ options: options === null || options === void 0 ? void 0 : options.deliveries,
572
+ validators: [required]
573
+ }
574
+ }, [options]);
575
+ react.useEffect(() => {
576
+ if (checkout.delivery) {
577
+ setValue({
578
+ delivery: checkout.delivery
579
+ });
580
+ }
581
+ // eslint-disable-next-line react-hooks/exhaustive-deps
582
+ }, [options]);
583
+ const onSubmit = event => __awaiter(void 0, void 0, void 0, function* () {
584
+ event.preventDefault();
585
+ if (form.flags.valid && form.value) {
586
+ console.log('CheckoutDelivery.valid', form.value);
587
+ try {
588
+ setError(undefined);
589
+ const delivery = form.value.delivery;
590
+ const response = yield api.post('/checkout/update', {
591
+ action: 'delivery',
592
+ checkout: Object.assign(Object.assign({}, checkout), {
593
+ delivery
594
+ })
595
+ });
596
+ setCheckout(response);
597
+ if (typeof onDelivery === 'function') {
598
+ onDelivery(delivery);
599
+ }
600
+ } catch (error) {
601
+ console.log('CheckoutDelivery.error', error);
602
+ setError(error);
603
+ }
604
+ } else {
605
+ console.log('CheckoutDelivery.invalid');
606
+ setTouched();
607
+ }
608
+ });
609
+ const onPrevious_ = () => {
610
+ if (typeof onPrevious === 'function') {
611
+ onPrevious();
612
+ }
613
+ };
614
+ const delivery = group.controls.delivery;
615
+ const onDeliveryChange = event => {
616
+ var _a;
617
+ group.controls.delivery.value = (_a = delivery === null || delivery === void 0 ? void 0 : delivery.options) === null || _a === void 0 ? void 0 : _a.find(x => x.id.toString() === event.target.value);
618
+ };
619
+ return jsxRuntime.jsxs(jsxRuntime.Fragment, {
620
+ children: [jsxRuntime.jsx(bomMixerUi.Section, {
621
+ children: jsxRuntime.jsx(bomMixerUi.Container, {
622
+ minHeight: "50vh",
623
+ children: jsxRuntime.jsx(bomMixerUi.Flex.Col, {
624
+ justifyContent: "space-between",
625
+ children: jsxRuntime.jsx(bomMixerUi.Form, {
626
+ state: form,
627
+ onSubmit: onSubmit,
628
+ children: jsxRuntime.jsxs(bomMixerUi.Flex.Col, {
629
+ flex: "1",
630
+ rowGap: "2rem",
631
+ children: [jsxRuntime.jsx(bomMixerUi.Text, {
632
+ variant: "heading10",
633
+ fontWeight: "700",
634
+ children: "Select the delivery method"
635
+ }), jsxRuntime.jsx(bomMixerUi.Text, {
636
+ variant: "paragraph10",
637
+ marginBottom: "1rem",
638
+ maxWidth: "60ch",
639
+ children: "Specify your delivery or reference address to find your closest sales outlet for self-service pickup."
640
+ }), delivery && jsxRuntime.jsx(bomMixerUi.RadioCard.Group, {
641
+ initialValue: (_a = delivery.value) === null || _a === void 0 ? void 0 : _a.id.toString(),
642
+ onChange: onDeliveryChange,
643
+ children: (_b = delivery.options) === null || _b === void 0 ? void 0 : _b.map(option => jsxRuntime.jsxs(bomMixerUi.RadioCard, {
644
+ value: option.id.toString(),
645
+ children: [jsxRuntime.jsx(bomMixerUi.RadioCard.Title, {
646
+ children: option.name
647
+ }), option.abstract && jsxRuntime.jsx(bomMixerUi.RadioCard.Abstract, {
648
+ dangerouslySetInnerHTML: {
649
+ __html: option.abstract
650
+ }
651
+ }), option.price > 0 && jsxRuntime.jsx(bomMixerUi.RadioCard.Extra, {
652
+ children: currency(option.price)
653
+ })]
654
+ }, option.id))
655
+ }), false , error && jsxRuntime.jsx(bomMixerUi.FormError, {
656
+ error: error,
657
+ children: label('form.submit.error')
658
+ })]
659
+ })
660
+ })
661
+ })
662
+ })
663
+ }), jsxRuntime.jsx(bomMixerUi.Section, {
664
+ position: "sticky",
665
+ bottom: "0",
666
+ padding: "1rem 0",
667
+ zIndex: "800",
668
+ background: "var(--color-primary-100)",
669
+ children: jsxRuntime.jsx(bomMixerUi.Container, {
670
+ children: jsxRuntime.jsxs(bomMixerUi.Flex.Row, {
671
+ justifyContent: "space-between",
672
+ children: [jsxRuntime.jsx(bomMixerUi.Flex, {
673
+ children: jsxRuntime.jsx(bomMixerUi.Button, {
674
+ variant: "secondary",
675
+ onClick: onPrevious_,
676
+ children: "Back"
677
+ })
678
+ }), jsxRuntime.jsx(bomMixerUi.Flex, {
679
+ children: jsxRuntime.jsx(bomMixerUi.Button, {
680
+ variant: "primary",
681
+ onClick: onSubmit,
682
+ children: "Proceed"
683
+ })
684
+ })]
685
+ })
686
+ })
687
+ })]
688
+ });
689
+ };
690
+
691
+ const CheckoutDiscount = _ref => {
692
+ let {
693
+ onDiscount
694
+ } = _ref;
695
+ const label = bomMixerHooks.useLabel();
696
+ const api = bomMixerHooks.useApi();
697
+ const checkout = useCheckout(state => state.checkout);
698
+ const {
699
+ setCheckout
700
+ } = useCheckout(state => state.actions);
701
+ // console.log('CheckoutDiscount', checkout);
702
+ const [error, setError] = react.useState();
703
+ bomMixerForms.RequiredValidator();
704
+ const [form, setValue, setTouched, reset, group] = bomMixerForms.useFormBuilder({
705
+ discountCode: {
706
+ schema: 'text',
707
+ label: 'field.discountCode'
708
+ }
709
+ });
710
+ const onSubmit = event => __awaiter(void 0, void 0, void 0, function* () {
711
+ event.preventDefault();
712
+ if (form.flags.valid && form.value) {
713
+ console.log('CheckoutDiscount.valid', form.value);
714
+ try {
715
+ setError(undefined);
716
+ const response = yield api.post('/checkout/discount', {
717
+ checkout,
718
+ discountCode: form.value.discountCode
719
+ });
720
+ setCheckout(response);
721
+ if (typeof onDiscount === 'function') {
722
+ onDiscount(response.discounts);
723
+ }
724
+ reset();
725
+ } catch (error) {
726
+ console.log('CheckoutDiscount.error', error);
727
+ setError(error);
728
+ }
729
+ } else {
730
+ console.log('CheckoutDiscount.invalid');
731
+ setTouched();
732
+ }
733
+ });
734
+ return jsxRuntime.jsx(jsxRuntime.Fragment, {
735
+ children: jsxRuntime.jsx(bomMixerUi.Flex.Row, {
736
+ gap: "1rem",
737
+ children: jsxRuntime.jsx(bomMixerUi.FieldText, {
738
+ control: group.controls.discountCode,
739
+ after: jsxRuntime.jsx(bomMixerUi.Button, {
740
+ variant: "secondary",
741
+ onClick: onSubmit,
742
+ children: label('form.apply')
743
+ })
744
+ })
745
+ })
746
+ });
747
+ };
748
+
749
+ const CheckoutEmpty = () => {
750
+ bomMixerHooks.useLabel();
751
+ const layout = bomMixerHooks.useLayout();
752
+ return jsxRuntime.jsx(jsxRuntime.Fragment, {
753
+ children: jsxRuntime.jsx(bomMixerUi.Section, {
754
+ children: jsxRuntime.jsx(bomMixerUi.Container, {
755
+ minHeight: "50vh",
756
+ children: jsxRuntime.jsxs(bomMixerUi.Flex.Col, {
757
+ gap: "1rem",
758
+ alignItems: "center",
759
+ textAlign: "center",
760
+ children: [jsxRuntime.jsx(bomMixerUi.Text, {
761
+ variant: "heading10",
762
+ fontWeight: "700",
763
+ children: "Your cart is empty."
764
+ }), jsxRuntime.jsx(bomMixerUi.Text, {
765
+ variant: "paragraph10",
766
+ marginBottom: "1rem",
767
+ maxWidth: "80ch",
768
+ children: "All\u2019interno di Mixer Shop \u00E8 possibile acquistare i campioni delle collezioni Tiles, 3D Elements e Paints, complementi d\u2019arredo in materiali inediti, elementi decorativi esclusivi e oggettistica legata all\u2019universo del brand."
769
+ }), jsxRuntime.jsx(bomMixerUi.NavLink, {
770
+ href: layout.topLevelHrefs.shop_index || '',
771
+ children: jsxRuntime.jsx(bomMixerUi.Button, {
772
+ as: "a",
773
+ variant: "primary",
774
+ children: "Continue shopping"
775
+ })
776
+ })]
777
+ })
778
+ })
779
+ })
780
+ });
781
+ };
782
+
783
+ const CheckoutError = _ref => {
784
+ let {
785
+ order
786
+ } = _ref;
787
+ bomMixerHooks.useLabel();
788
+ return jsxRuntime.jsx(jsxRuntime.Fragment, {
789
+ children: jsxRuntime.jsx(bomMixerUi.Section, {
790
+ children: jsxRuntime.jsx(bomMixerUi.Container, {
791
+ minHeight: "50vh",
792
+ children: order ? jsxRuntime.jsxs(bomMixerUi.Flex.Col, {
793
+ gap: "1rem",
794
+ alignItems: "center",
795
+ textAlign: "center",
796
+ children: [jsxRuntime.jsx(bomMixerUi.Text, {
797
+ variant: "heading10",
798
+ fontWeight: "700",
799
+ children: "Payment unsuccesful"
800
+ }), jsxRuntime.jsx(bomMixerUi.Text, {
801
+ variant: "paragraph10",
802
+ marginBottom: "1rem",
803
+ maxWidth: "80ch",
804
+ children: "There was a problem processing this payment. Please contact your payment provider if needed."
805
+ })]
806
+ }) : jsxRuntime.jsxs(bomMixerUi.Flex.Col, {
807
+ gap: "1rem",
808
+ alignItems: "center",
809
+ textAlign: "center",
810
+ children: [jsxRuntime.jsx(bomMixerUi.Text, {
811
+ variant: "heading10",
812
+ fontWeight: "700",
813
+ children: "Order not found"
814
+ }), jsxRuntime.jsx(bomMixerUi.Text, {
815
+ variant: "paragraph10",
816
+ marginBottom: "1rem",
817
+ maxWidth: "80ch",
818
+ children: "There was a problem processing this order."
819
+ })]
820
+ })
821
+ })
822
+ })
823
+ });
824
+ };
825
+
826
+ const CheckoutForgot = _ref => {
827
+ let {
828
+ onPasswordSent,
829
+ onNavToLogin,
830
+ onNavToRegister,
831
+ onNavToPrevious
832
+ } = _ref;
833
+ const onPasswordSent_ = () => {
834
+ if (typeof onPasswordSent === 'function') {
835
+ onPasswordSent();
836
+ }
837
+ };
838
+ const onNavToLogin_ = () => {
839
+ if (typeof onNavToLogin === 'function') {
840
+ onNavToLogin();
841
+ }
842
+ };
843
+ const onNavToRegister_ = () => {
844
+ if (typeof onNavToRegister === 'function') {
845
+ onNavToRegister();
846
+ }
847
+ };
848
+ const onNavToPrevious_ = () => {
849
+ if (typeof onNavToPrevious === 'function') {
850
+ onNavToPrevious();
851
+ }
852
+ };
853
+ return jsxRuntime.jsxs(jsxRuntime.Fragment, {
854
+ children: [jsxRuntime.jsx(bomMixerUi.Section, {
855
+ children: jsxRuntime.jsx(bomMixerUi.Container, {
856
+ children: jsxRuntime.jsx(bomMixerAuth.AuthForgot, {
857
+ onPasswordSent: onPasswordSent_,
858
+ onNavToLogin: onNavToLogin_,
859
+ onNavToRegister: onNavToRegister_
860
+ })
861
+ })
862
+ }), jsxRuntime.jsx(bomMixerUi.Section, {
863
+ position: "sticky",
864
+ bottom: "0",
865
+ padding: "1rem 0",
866
+ zIndex: "800",
867
+ background: "var(--color-primary-100)",
868
+ children: jsxRuntime.jsx(bomMixerUi.Container, {
869
+ children: jsxRuntime.jsx(bomMixerUi.Flex.Row, {
870
+ justifyContent: "space-between",
871
+ children: jsxRuntime.jsx(bomMixerUi.Flex, {
872
+ children: jsxRuntime.jsx(bomMixerUi.Button, {
873
+ variant: "secondary",
874
+ onClick: onNavToPrevious_,
875
+ children: "Back"
876
+ })
877
+ })
878
+ })
879
+ })
880
+ })]
881
+ });
882
+ };
883
+
884
+ const CheckoutForgotSuccess = _ref => {
885
+ let {
886
+ onNavToLogin,
887
+ onNavToPrevious
888
+ } = _ref;
889
+ const onNavToLogin_ = () => {
890
+ if (typeof onNavToLogin === 'function') {
891
+ onNavToLogin();
892
+ }
893
+ };
894
+ const onNavToPrevious_ = () => {
895
+ if (typeof onNavToPrevious === 'function') {
896
+ onNavToPrevious();
897
+ }
898
+ };
899
+ return jsxRuntime.jsxs(jsxRuntime.Fragment, {
900
+ children: [jsxRuntime.jsx(bomMixerUi.Section, {
901
+ children: jsxRuntime.jsx(bomMixerUi.Container, {
902
+ children: jsxRuntime.jsx(bomMixerAuth.AuthForgotSuccess, {
903
+ onNavToLogin: onNavToLogin_
904
+ })
905
+ })
906
+ }), jsxRuntime.jsx(bomMixerUi.Section, {
907
+ position: "sticky",
908
+ bottom: "0",
909
+ padding: "1rem 0",
910
+ zIndex: "800",
911
+ background: "var(--color-primary-100)",
912
+ children: jsxRuntime.jsx(bomMixerUi.Container, {
913
+ children: jsxRuntime.jsx(bomMixerUi.Flex.Row, {
914
+ justifyContent: "space-between",
915
+ children: jsxRuntime.jsx(bomMixerUi.Flex, {
916
+ children: jsxRuntime.jsx(bomMixerUi.Button, {
917
+ variant: "secondary",
918
+ onClick: onNavToPrevious_,
919
+ children: "Back"
920
+ })
921
+ })
922
+ })
923
+ })
924
+ })]
925
+ });
926
+ };
927
+
928
+ const CheckoutLogin = _ref => {
929
+ let {
930
+ onSignedIn,
931
+ onNavToForgot,
932
+ onNavToRegister,
933
+ onNavToPrevious
934
+ } = _ref;
935
+ const onSignedIn_ = user => {
936
+ if (typeof onSignedIn === 'function') {
937
+ onSignedIn(user);
938
+ }
939
+ };
940
+ const onNavToForgot_ = () => {
941
+ if (typeof onNavToForgot === 'function') {
942
+ onNavToForgot();
943
+ }
944
+ };
945
+ const onNavToRegister_ = () => {
946
+ if (typeof onNavToRegister === 'function') {
947
+ onNavToRegister();
948
+ }
949
+ };
950
+ const onNavToPrevious_ = () => {
951
+ if (typeof onNavToPrevious === 'function') {
952
+ onNavToPrevious();
953
+ }
954
+ };
955
+ return jsxRuntime.jsxs(jsxRuntime.Fragment, {
956
+ children: [jsxRuntime.jsx(bomMixerUi.Section, {
957
+ children: jsxRuntime.jsx(bomMixerUi.Container, {
958
+ children: jsxRuntime.jsx(bomMixerAuth.AuthLogin, {
959
+ onSignedIn: onSignedIn_,
960
+ onNavToForgot: onNavToForgot_,
961
+ onNavToRegister: onNavToRegister_
962
+ })
963
+ })
964
+ }), jsxRuntime.jsx(bomMixerUi.Section, {
965
+ position: "sticky",
966
+ bottom: "0",
967
+ padding: "1rem 0",
968
+ zIndex: "800",
969
+ background: "var(--color-primary-100)",
970
+ children: jsxRuntime.jsx(bomMixerUi.Container, {
971
+ children: jsxRuntime.jsx(bomMixerUi.Flex.Row, {
972
+ justifyContent: "space-between",
973
+ children: jsxRuntime.jsx(bomMixerUi.Flex, {
974
+ children: jsxRuntime.jsx(bomMixerUi.Button, {
975
+ variant: "secondary",
976
+ onClick: onNavToPrevious_,
977
+ children: "Back"
978
+ })
979
+ })
980
+ })
981
+ })
982
+ })]
983
+ });
984
+ };
985
+
986
+ const CheckoutRegister = _ref => {
987
+ let {
988
+ onSignedUp,
989
+ onNavToLogin,
990
+ onNavToPrevious
991
+ } = _ref;
992
+ const onSignedUp_ = () => {
993
+ if (typeof onSignedUp === 'function') {
994
+ onSignedUp();
995
+ }
996
+ };
997
+ const onNavToLogin_ = () => {
998
+ if (typeof onNavToLogin === 'function') {
999
+ onNavToLogin();
1000
+ }
1001
+ };
1002
+ const onNavToPrevious_ = () => {
1003
+ if (typeof onNavToPrevious === 'function') {
1004
+ onNavToPrevious();
1005
+ }
1006
+ };
1007
+ return jsxRuntime.jsxs(jsxRuntime.Fragment, {
1008
+ children: [jsxRuntime.jsx(bomMixerUi.Section, {
1009
+ children: jsxRuntime.jsx(bomMixerUi.Container, {
1010
+ children: jsxRuntime.jsx(bomMixerAuth.AuthRegister, {
1011
+ onSignedUp: onSignedUp_,
1012
+ onNavToLogin: onNavToLogin_
1013
+ })
1014
+ })
1015
+ }), jsxRuntime.jsx(bomMixerUi.Section, {
1016
+ position: "sticky",
1017
+ bottom: "0",
1018
+ padding: "1rem 0",
1019
+ zIndex: "800",
1020
+ background: "var(--color-primary-100)",
1021
+ children: jsxRuntime.jsx(bomMixerUi.Container, {
1022
+ children: jsxRuntime.jsx(bomMixerUi.Flex.Row, {
1023
+ justifyContent: "space-between",
1024
+ children: jsxRuntime.jsx(bomMixerUi.Flex, {
1025
+ children: jsxRuntime.jsx(bomMixerUi.Button, {
1026
+ variant: "secondary",
1027
+ onClick: onNavToPrevious_,
1028
+ children: "Back"
1029
+ })
1030
+ })
1031
+ })
1032
+ })
1033
+ })]
1034
+ });
1035
+ };
1036
+
1037
+ const CheckoutRegisterSuccess = _ref => {
1038
+ let {
1039
+ onNavToLogin,
1040
+ onNavToPrevious
1041
+ } = _ref;
1042
+ const onNavToLogin_ = () => {
1043
+ if (typeof onNavToLogin === 'function') {
1044
+ onNavToLogin();
1045
+ }
1046
+ };
1047
+ const onNavToPrevious_ = () => {
1048
+ if (typeof onNavToPrevious === 'function') {
1049
+ onNavToPrevious();
1050
+ }
1051
+ };
1052
+ return jsxRuntime.jsxs(jsxRuntime.Fragment, {
1053
+ children: [jsxRuntime.jsx(bomMixerUi.Section, {
1054
+ children: jsxRuntime.jsx(bomMixerUi.Container, {
1055
+ children: jsxRuntime.jsx(bomMixerAuth.AuthRegisterSuccess, {
1056
+ onNavToLogin: onNavToLogin_
1057
+ })
1058
+ })
1059
+ }), jsxRuntime.jsx(bomMixerUi.Section, {
1060
+ position: "sticky",
1061
+ bottom: "0",
1062
+ padding: "1rem 0",
1063
+ zIndex: "800",
1064
+ background: "var(--color-primary-100)",
1065
+ children: jsxRuntime.jsx(bomMixerUi.Container, {
1066
+ children: jsxRuntime.jsx(bomMixerUi.Flex.Row, {
1067
+ justifyContent: "space-between",
1068
+ children: jsxRuntime.jsx(bomMixerUi.Flex, {
1069
+ children: jsxRuntime.jsx(bomMixerUi.Button, {
1070
+ variant: "secondary",
1071
+ onClick: onNavToPrevious_,
1072
+ children: "Back"
1073
+ })
1074
+ })
1075
+ })
1076
+ })
1077
+ })]
1078
+ });
1079
+ };
1080
+
1081
+ const CheckoutUserInfo = _ref => {
1082
+ let {
1083
+ user,
1084
+ onUserInfo,
1085
+ onNavToPrevious
1086
+ } = _ref;
1087
+ const label = bomMixerHooks.useLabel();
1088
+ const api = bomMixerHooks.useApi();
1089
+ const checkout = useCheckout(state => state.checkout);
1090
+ const {
1091
+ setCheckout
1092
+ } = useCheckout(state => state.actions);
1093
+ const [options] = bomMixerHooks.useApiPost('/checkout/info', checkout);
1094
+ const required = bomMixerForms.RequiredValidator();
1095
+ bomMixerForms.RequiredTrueValidator();
1096
+ const email = bomMixerForms.EmailValidator();
1097
+ const shippingRequiredIfItaly = bomMixerForms.RequiredIfValidator((value, rootValue) => {
1098
+ var _a, _b;
1099
+ return ((_b = (_a = rootValue === null || rootValue === void 0 ? void 0 : rootValue.shippingAddress) === null || _a === void 0 ? void 0 : _a.country) === null || _b === void 0 ? void 0 : _b.id) === 'it';
1100
+ });
1101
+ const shippingHiddenIfNotItaly = (value, rootValue) => {
1102
+ var _a, _b;
1103
+ return !(((_b = (_a = rootValue === null || rootValue === void 0 ? void 0 : rootValue.shippingAddress) === null || _a === void 0 ? void 0 : _a.country) === null || _b === void 0 ? void 0 : _b.id) === 'it');
1104
+ };
1105
+ const billingRequired = bomMixerForms.RequiredIfValidator((value, rootValue) => (rootValue === null || rootValue === void 0 ? void 0 : rootValue.hasBilling) === true);
1106
+ const billingHidden = (value, rootValue) => !((rootValue === null || rootValue === void 0 ? void 0 : rootValue.hasBilling) === true);
1107
+ const billingHiddenIfNotItaly = (value, rootValue) => {
1108
+ var _a, _b;
1109
+ return !(((_b = (_a = rootValue === null || rootValue === void 0 ? void 0 : rootValue.billingAddress) === null || _a === void 0 ? void 0 : _a.country) === null || _b === void 0 ? void 0 : _b.id) === 'it');
1110
+ };
1111
+ // const billingRequiredIfItaly = RequiredIfValidator((value, rootValue) => rootValue?.billingAddress?.country?.id === 'it');
1112
+ const [form, setValue, setTouched, reset, group] = bomMixerForms.useFormBuilder({
1113
+ shippingAddress: {
1114
+ schema: 'group',
1115
+ label: 'field.shippingAddress',
1116
+ children: {
1117
+ firstName: {
1118
+ schema: 'text',
1119
+ label: 'field.firstName',
1120
+ validators: [required]
1121
+ },
1122
+ lastName: {
1123
+ schema: 'text',
1124
+ label: 'field.lastName',
1125
+ validators: [required]
1126
+ },
1127
+ email: {
1128
+ schema: 'text',
1129
+ label: 'field.email',
1130
+ validators: [required, email]
1131
+ },
1132
+ phoneNumber: {
1133
+ schema: 'text',
1134
+ label: 'field.phoneNumber',
1135
+ validators: [required]
1136
+ },
1137
+ country: {
1138
+ schema: 'select',
1139
+ label: 'field.country',
1140
+ options: options === null || options === void 0 ? void 0 : options.countries,
1141
+ validators: [required]
1142
+ },
1143
+ region: {
1144
+ schema: 'select',
1145
+ label: 'field.region',
1146
+ options: options === null || options === void 0 ? void 0 : options.regions,
1147
+ validators: shippingRequiredIfItaly,
1148
+ disabled: shippingHiddenIfNotItaly,
1149
+ hidden: shippingHiddenIfNotItaly
1150
+ },
1151
+ province: {
1152
+ schema: 'autocomplete',
1153
+ label: 'field.province',
1154
+ options: options === null || options === void 0 ? void 0 : options.provinces,
1155
+ validators: shippingRequiredIfItaly,
1156
+ disabled: shippingHiddenIfNotItaly,
1157
+ hidden: shippingHiddenIfNotItaly
1158
+ },
1159
+ address: {
1160
+ schema: 'text',
1161
+ label: 'field.address',
1162
+ validators: [required]
1163
+ },
1164
+ streetNumber: {
1165
+ schema: 'text',
1166
+ label: 'field.streetNumber',
1167
+ validators: [required]
1168
+ },
1169
+ zipCode: {
1170
+ schema: 'text',
1171
+ label: 'field.zipCode',
1172
+ validators: [required]
1173
+ },
1174
+ city: {
1175
+ schema: 'text',
1176
+ label: 'field.city',
1177
+ validators: [required]
1178
+ }
1179
+ }
1180
+ },
1181
+ hasInvoice: {
1182
+ schema: 'checkbox',
1183
+ label: 'field.hasInvoice'
1184
+ },
1185
+ hasBilling: {
1186
+ schema: 'checkbox',
1187
+ label: 'field.hasBilling'
1188
+ },
1189
+ billingAddress: {
1190
+ schema: 'group',
1191
+ label: 'field.billingAddress',
1192
+ children: {
1193
+ firstName: {
1194
+ schema: 'text',
1195
+ label: 'field.firstName',
1196
+ validators: [billingRequired]
1197
+ },
1198
+ lastName: {
1199
+ schema: 'text',
1200
+ label: 'field.lastName',
1201
+ validators: [billingRequired]
1202
+ },
1203
+ email: {
1204
+ schema: 'text',
1205
+ label: 'field.email',
1206
+ validators: [billingRequired, email]
1207
+ },
1208
+ phoneNumber: {
1209
+ schema: 'text',
1210
+ label: 'field.phoneNumber',
1211
+ validators: [billingRequired]
1212
+ },
1213
+ country: {
1214
+ schema: 'select',
1215
+ label: 'field.country',
1216
+ options: options === null || options === void 0 ? void 0 : options.countries,
1217
+ validators: [billingRequired]
1218
+ },
1219
+ region: {
1220
+ schema: 'select',
1221
+ label: 'field.region',
1222
+ options: options === null || options === void 0 ? void 0 : options.regions,
1223
+ validators: [billingRequired],
1224
+ disabled: billingHiddenIfNotItaly,
1225
+ hidden: billingHiddenIfNotItaly
1226
+ },
1227
+ province: {
1228
+ schema: 'autocomplete',
1229
+ label: 'field.province',
1230
+ options: options === null || options === void 0 ? void 0 : options.provinces,
1231
+ validators: [billingRequired],
1232
+ disabled: billingHiddenIfNotItaly,
1233
+ hidden: billingHiddenIfNotItaly
1234
+ },
1235
+ address: {
1236
+ schema: 'text',
1237
+ label: 'field.address',
1238
+ validators: [billingRequired]
1239
+ },
1240
+ streetNumber: {
1241
+ schema: 'text',
1242
+ label: 'field.streetNumber',
1243
+ validators: [billingRequired]
1244
+ },
1245
+ zipCode: {
1246
+ schema: 'text',
1247
+ label: 'field.zipCode',
1248
+ validators: [billingRequired]
1249
+ },
1250
+ city: {
1251
+ schema: 'text',
1252
+ label: 'field.city',
1253
+ validators: [billingRequired]
1254
+ }
1255
+ },
1256
+ disabled: billingHidden,
1257
+ hidden: billingHidden
1258
+ },
1259
+ checkField: {
1260
+ schema: 'text',
1261
+ hidden: true
1262
+ } // check hidden field for antiforgery
1263
+ }, [options]);
1264
+ react.useEffect(() => {
1265
+ if (checkout.shippingAddress) {
1266
+ setValue({
1267
+ shippingAddress: checkout.shippingAddress,
1268
+ hasInvoice: checkout.hasInvoice,
1269
+ hasBilling: checkout.hasBilling,
1270
+ billingAddress: checkout.billingAddress
1271
+ });
1272
+ } else if (user) {
1273
+ setValue({
1274
+ shippingAddress: user
1275
+ });
1276
+ }
1277
+ // eslint-disable-next-line react-hooks/exhaustive-deps
1278
+ }, [options]);
1279
+ const onTest = () => {
1280
+ setValue({
1281
+ shippingAddress: {
1282
+ firstName: 'Jhon',
1283
+ lastName: 'Appleseed',
1284
+ email: 'jhon.appleseed@gmail.com',
1285
+ phoneNumber: '0721411112',
1286
+ country: {
1287
+ id: 'it',
1288
+ name: 'Italy'
1289
+ },
1290
+ region: {
1291
+ id: 10,
1292
+ name: 'Marche'
1293
+ },
1294
+ province: {
1295
+ id: 175,
1296
+ name: 'Pesaro Urbino'
1297
+ },
1298
+ address: 'Strada della Campanara',
1299
+ streetNumber: '15',
1300
+ zipCode: '61122',
1301
+ city: 'Pesaro'
1302
+ },
1303
+ hasInvoice: false,
1304
+ hasBilling: false
1305
+ });
1306
+ };
1307
+ const onReset = () => {
1308
+ reset();
1309
+ };
1310
+ const [error, setError] = react.useState();
1311
+ const onSubmit = event => __awaiter(void 0, void 0, void 0, function* () {
1312
+ event.preventDefault();
1313
+ if (form.flags.valid && form.value) {
1314
+ console.log('CheckoutUserInfo.valid', form.value);
1315
+ try {
1316
+ setError(undefined);
1317
+ const response = yield api.post('/checkout/update', {
1318
+ action: 'info',
1319
+ checkout: Object.assign(Object.assign(Object.assign({}, checkout), form.value), {
1320
+ user
1321
+ })
1322
+ });
1323
+ setCheckout(response);
1324
+ if (typeof onUserInfo === 'function') {
1325
+ onUserInfo(Object.assign(Object.assign({}, form.value), {
1326
+ user
1327
+ }));
1328
+ }
1329
+ } catch (error) {
1330
+ console.log('CheckoutUserInfo.error', error);
1331
+ setError(error);
1332
+ }
1333
+ } else {
1334
+ console.log('CheckoutUserInfo.invalid');
1335
+ setTouched();
1336
+ }
1337
+ });
1338
+ const onNavToPrevious_ = () => {
1339
+ if (typeof onNavToPrevious === 'function') {
1340
+ onNavToPrevious();
1341
+ }
1342
+ };
1343
+ return jsxRuntime.jsxs(jsxRuntime.Fragment, {
1344
+ children: [jsxRuntime.jsx(bomMixerUi.Section, {
1345
+ children: jsxRuntime.jsx(bomMixerUi.Container, {
1346
+ children: jsxRuntime.jsx(bomMixerUi.Flex.Col, {
1347
+ justifyContent: "space-between",
1348
+ children: jsxRuntime.jsx(bomMixerUi.Form, {
1349
+ state: form,
1350
+ onSubmit: onSubmit,
1351
+ children: jsxRuntime.jsxs(bomMixerUi.Flex.Col, {
1352
+ flex: "1",
1353
+ rowGap: "1rem",
1354
+ children: [jsxRuntime.jsx(bomMixerUi.Text, {
1355
+ variant: "heading10",
1356
+ fontWeight: "700",
1357
+ marginBottom: "1rem",
1358
+ children: "Reference address"
1359
+ }), jsxRuntime.jsx(bomMixerUi.Text, {
1360
+ variant: "paragraph10",
1361
+ marginBottom: "1rem",
1362
+ maxWidth: "60ch",
1363
+ children: "Specify your delivery or reference address to find your closest sales outlet for self-service pickup."
1364
+ }), jsxRuntime.jsx(bomMixerUi.Grid.Row, {
1365
+ rowGap: "1rem",
1366
+ children: jsxRuntime.jsx(bomMixerUi.FieldCollection, {
1367
+ collection: group
1368
+ })
1369
+ }), error && jsxRuntime.jsx(bomMixerUi.FormError, {
1370
+ error: error,
1371
+ children: label('form.submit.error')
1372
+ }), jsxRuntime.jsx(bomMixerUi.FormTester, {
1373
+ form: form,
1374
+ onTest: onTest,
1375
+ onReset: onReset
1376
+ })]
1377
+ })
1378
+ })
1379
+ })
1380
+ })
1381
+ }), jsxRuntime.jsx(bomMixerUi.Section, {
1382
+ position: "sticky",
1383
+ bottom: "0",
1384
+ padding: "1rem 0",
1385
+ zIndex: "800",
1386
+ background: "var(--color-primary-100)",
1387
+ children: jsxRuntime.jsx(bomMixerUi.Container, {
1388
+ children: jsxRuntime.jsxs(bomMixerUi.Flex.Row, {
1389
+ justifyContent: "space-between",
1390
+ children: [jsxRuntime.jsx(bomMixerUi.Flex, {
1391
+ children: jsxRuntime.jsx(bomMixerUi.Button, {
1392
+ variant: "secondary",
1393
+ onClick: onNavToPrevious_,
1394
+ children: "Back"
1395
+ })
1396
+ }), jsxRuntime.jsx(bomMixerUi.Flex, {
1397
+ children: jsxRuntime.jsx(bomMixerUi.Button, {
1398
+ variant: "primary",
1399
+ onClick: onSubmit,
1400
+ children: "Proceed"
1401
+ })
1402
+ })]
1403
+ })
1404
+ })
1405
+ })]
1406
+ });
1407
+ };
1408
+
1409
+ const CheckoutInfo = _ref => {
1410
+ let {
1411
+ onPrevious,
1412
+ onInfo
1413
+ } = _ref;
1414
+ bomMixerHooks.useLabel();
1415
+ const checkout = useCheckout(state => state.checkout);
1416
+ const user = bomMixerAuth.useUser(state => state.user);
1417
+ const {
1418
+ setUser
1419
+ } = bomMixerAuth.useUser(state => state.actions);
1420
+ const [view, setView] = react.useState(checkout.shippingAddress || user ? 'address' : 'choose');
1421
+ // const [user, setUser] = useState<IUser>();
1422
+ const onView = view => {
1423
+ setView(view);
1424
+ bomMixerHooks.scrollToY(0);
1425
+ };
1426
+ const onUserInfo = info => {
1427
+ if (typeof onInfo === 'function') {
1428
+ onInfo(info);
1429
+ }
1430
+ };
1431
+ const onSignedIn = user => {
1432
+ console.log('onSignedIn');
1433
+ setUser(user);
1434
+ onView('address');
1435
+ };
1436
+ const onSignedUp = () => {
1437
+ console.log('onSignedUp');
1438
+ onView('register-success');
1439
+ };
1440
+ const onPasswordSent = () => {
1441
+ console.log('onPasswordSent');
1442
+ onView('forgot-success');
1443
+ };
1444
+ const onNavToLogin = () => {
1445
+ onView('login');
1446
+ };
1447
+ const onNavToRegister = () => {
1448
+ onView('register');
1449
+ };
1450
+ const onNavToForgot = () => {
1451
+ onView('forgot');
1452
+ };
1453
+ const onNavToPrevious = () => {
1454
+ onView('choose');
1455
+ };
1456
+ const onPrevious_ = () => {
1457
+ if (typeof onPrevious === 'function') {
1458
+ onPrevious();
1459
+ }
1460
+ bomMixerHooks.scrollToY(0);
1461
+ };
1462
+ const getView = () => {
1463
+ switch (view) {
1464
+ case 'choose':
1465
+ return jsxRuntime.jsxs(jsxRuntime.Fragment, {
1466
+ children: [jsxRuntime.jsx(bomMixerUi.Section, {
1467
+ children: jsxRuntime.jsx(bomMixerUi.Container, {
1468
+ minHeight: "50vh",
1469
+ children: jsxRuntime.jsxs(bomMixerUi.Grid.Row, {
1470
+ rowGap: "3rem",
1471
+ children: [jsxRuntime.jsx(bomMixerUi.Grid, {
1472
+ sm: 6,
1473
+ children: jsxRuntime.jsxs(bomMixerUi.Flex.Col, {
1474
+ gap: "1rem",
1475
+ alignItems: "flex-start",
1476
+ children: [jsxRuntime.jsx(bomMixerUi.Text, {
1477
+ variant: "heading10",
1478
+ fontWeight: "700",
1479
+ children: "Login"
1480
+ }), jsxRuntime.jsx(bomMixerUi.Text, {
1481
+ variant: "paragraph10",
1482
+ marginBottom: "1rem",
1483
+ maxWidth: "60ch",
1484
+ children: "Login to optimise your shopping experience and to see your previous orders."
1485
+ }), jsxRuntime.jsx(bomMixerUi.Button, {
1486
+ variant: "primary",
1487
+ onClick: () => setView('login'),
1488
+ children: "Login"
1489
+ })]
1490
+ })
1491
+ }), jsxRuntime.jsx(bomMixerUi.Grid, {
1492
+ sm: 6,
1493
+ children: jsxRuntime.jsxs(bomMixerUi.Flex.Col, {
1494
+ gap: "2rem",
1495
+ children: [jsxRuntime.jsxs(bomMixerUi.Flex.Col, {
1496
+ gap: "1rem",
1497
+ alignItems: "flex-start",
1498
+ marginBottom: "3rem",
1499
+ children: [jsxRuntime.jsx(bomMixerUi.Text, {
1500
+ variant: "heading10",
1501
+ fontWeight: "700",
1502
+ children: "Register"
1503
+ }), jsxRuntime.jsx(bomMixerUi.Text, {
1504
+ variant: "paragraph10",
1505
+ marginBottom: "1rem",
1506
+ maxWidth: "60ch",
1507
+ children: "Register to optimise your shopping experience and to see your previous orders."
1508
+ }), jsxRuntime.jsx(bomMixerUi.Button, {
1509
+ variant: "primary",
1510
+ onClick: () => setView('register'),
1511
+ children: "Register"
1512
+ })]
1513
+ }), jsxRuntime.jsxs(bomMixerUi.Flex.Col, {
1514
+ gap: "1rem",
1515
+ alignItems: "flex-start",
1516
+ children: [jsxRuntime.jsx(bomMixerUi.Text, {
1517
+ variant: "heading10",
1518
+ fontWeight: "700",
1519
+ children: "Proceed as guest"
1520
+ }), jsxRuntime.jsx(bomMixerUi.Text, {
1521
+ variant: "paragraph10",
1522
+ marginBottom: "1rem",
1523
+ maxWidth: "60ch",
1524
+ children: "If you continue your purchase as a guest, we will request your shipping details and assign the appropriate sales outlet, but you will not need to create a personal account. If you would like to access your user area and your order history, please complete the purchase by registering your account."
1525
+ }), jsxRuntime.jsx(bomMixerUi.Button, {
1526
+ variant: "primary",
1527
+ onClick: () => setView('address'),
1528
+ children: "Proceed"
1529
+ })]
1530
+ })]
1531
+ })
1532
+ })]
1533
+ })
1534
+ })
1535
+ }), jsxRuntime.jsx(bomMixerUi.Section, {
1536
+ position: "sticky",
1537
+ bottom: "0",
1538
+ padding: "1rem 0",
1539
+ zIndex: "800",
1540
+ background: "var(--color-primary-100)",
1541
+ children: jsxRuntime.jsx(bomMixerUi.Container, {
1542
+ children: jsxRuntime.jsx(bomMixerUi.Flex.Row, {
1543
+ justifyContent: "space-between",
1544
+ children: jsxRuntime.jsx(bomMixerUi.Flex, {
1545
+ children: jsxRuntime.jsx(bomMixerUi.Button, {
1546
+ variant: "secondary",
1547
+ onClick: onPrevious_,
1548
+ children: "Back"
1549
+ })
1550
+ })
1551
+ })
1552
+ })
1553
+ })]
1554
+ });
1555
+ case 'address':
1556
+ return jsxRuntime.jsx(CheckoutUserInfo, {
1557
+ user: user,
1558
+ onUserInfo: onUserInfo,
1559
+ onNavToPrevious: onNavToPrevious
1560
+ });
1561
+ case 'login':
1562
+ return jsxRuntime.jsx(CheckoutLogin, {
1563
+ onSignedIn: onSignedIn,
1564
+ onNavToForgot: onNavToForgot,
1565
+ onNavToRegister: onNavToRegister,
1566
+ onNavToPrevious: onNavToPrevious
1567
+ });
1568
+ case 'register':
1569
+ return jsxRuntime.jsx(CheckoutRegister, {
1570
+ onSignedUp: onSignedUp,
1571
+ onNavToLogin: onNavToLogin,
1572
+ onNavToPrevious: onNavToPrevious
1573
+ });
1574
+ case 'register-success':
1575
+ return jsxRuntime.jsx(CheckoutRegisterSuccess, {
1576
+ onNavToLogin: onNavToLogin,
1577
+ onNavToPrevious: onNavToPrevious
1578
+ });
1579
+ case 'forgot':
1580
+ return jsxRuntime.jsx(CheckoutForgot, {
1581
+ onPasswordSent: onPasswordSent,
1582
+ onNavToLogin: onNavToLogin,
1583
+ onNavToRegister: onNavToRegister,
1584
+ onNavToPrevious: onNavToPrevious
1585
+ });
1586
+ case 'forgot-success':
1587
+ return jsxRuntime.jsx(CheckoutForgotSuccess, {
1588
+ onNavToLogin: onNavToLogin,
1589
+ onNavToPrevious: onNavToPrevious
1590
+ });
1591
+ default:
1592
+ return null;
1593
+ }
1594
+ };
1595
+ return jsxRuntime.jsx(jsxRuntime.Fragment, {
1596
+ children: getView()
1597
+ });
1598
+ };
1599
+
1600
+ const CheckoutPayment = _ref => {
1601
+ let {
1602
+ onPrevious,
1603
+ onPayment
1604
+ } = _ref;
1605
+ var _a, _b;
1606
+ const label = bomMixerHooks.useLabel();
1607
+ const api = bomMixerHooks.useApi();
1608
+ const checkout = useCheckout(state => state.checkout);
1609
+ const {
1610
+ setCheckout
1611
+ } = useCheckout(state => state.actions);
1612
+ const [options] = bomMixerHooks.useApiPost('/checkout/payments', checkout);
1613
+ const [error, setError] = react.useState();
1614
+ const required = bomMixerForms.RequiredValidator();
1615
+ const [form, setValue, setTouched, reset, group] = bomMixerForms.useFormBuilder({
1616
+ payment: {
1617
+ schema: 'select',
1618
+ label: 'field.payment',
1619
+ options: options === null || options === void 0 ? void 0 : options.payments,
1620
+ validators: [required]
1621
+ }
1622
+ }, [options]);
1623
+ react.useEffect(() => {
1624
+ if (checkout.payment) {
1625
+ setValue({
1626
+ payment: checkout.payment
1627
+ });
1628
+ } else if (options) {
1629
+ setValue({
1630
+ payment: options.payments[0]
1631
+ });
1632
+ }
1633
+ // eslint-disable-next-line react-hooks/exhaustive-deps
1634
+ }, [options]);
1635
+ const onSubmit = event => __awaiter(void 0, void 0, void 0, function* () {
1636
+ event.preventDefault();
1637
+ if (form.flags.valid && form.value) {
1638
+ console.log('CheckoutPayment.valid', form.value);
1639
+ try {
1640
+ setError(undefined);
1641
+ const payment = form.value.payment;
1642
+ const response = yield api.post('/checkout/update', {
1643
+ action: 'payment',
1644
+ checkout: Object.assign(Object.assign({}, checkout), {
1645
+ payment
1646
+ })
1647
+ });
1648
+ setCheckout(response);
1649
+ if (typeof onPayment === 'function') {
1650
+ onPayment(payment);
1651
+ }
1652
+ } catch (error) {
1653
+ console.log('CheckoutPayment.error', error);
1654
+ setError(error);
1655
+ }
1656
+ } else {
1657
+ console.log('CheckoutPayment.invalid');
1658
+ setTouched();
1659
+ }
1660
+ });
1661
+ const onPrevious_ = () => {
1662
+ if (typeof onPrevious === 'function') {
1663
+ onPrevious();
1664
+ }
1665
+ };
1666
+ const payment = group.controls.payment;
1667
+ const onPaymentChange = event => {
1668
+ var _a;
1669
+ group.controls.payment.value = (_a = payment === null || payment === void 0 ? void 0 : payment.options) === null || _a === void 0 ? void 0 : _a.find(x => x.id.toString() === event.target.value);
1670
+ };
1671
+ return jsxRuntime.jsxs(jsxRuntime.Fragment, {
1672
+ children: [jsxRuntime.jsx(bomMixerUi.Section, {
1673
+ children: jsxRuntime.jsx(bomMixerUi.Container, {
1674
+ children: jsxRuntime.jsx(bomMixerUi.Form, {
1675
+ state: form,
1676
+ onSubmit: onSubmit,
1677
+ children: jsxRuntime.jsxs(bomMixerUi.Flex.Col, {
1678
+ flex: "1",
1679
+ rowGap: "2rem",
1680
+ children: [jsxRuntime.jsx(bomMixerUi.Text, {
1681
+ variant: "heading10",
1682
+ fontWeight: "700",
1683
+ children: "Select a payment method"
1684
+ }), payment && jsxRuntime.jsx(bomMixerUi.RadioCard.Group, {
1685
+ initialValue: (_a = payment.value) === null || _a === void 0 ? void 0 : _a.id.toString(),
1686
+ onChange: onPaymentChange,
1687
+ children: (_b = payment.options) === null || _b === void 0 ? void 0 : _b.map(option => jsxRuntime.jsxs(bomMixerUi.RadioCard, {
1688
+ value: option.id.toString(),
1689
+ flex: "0 0 calc(50% - 1rem)",
1690
+ children: [jsxRuntime.jsx(bomMixerUi.RadioCard.Title, {
1691
+ children: option.name
1692
+ }), option.abstract && jsxRuntime.jsx(bomMixerUi.RadioCard.Abstract, {
1693
+ dangerouslySetInnerHTML: {
1694
+ __html: option.abstract
1695
+ }
1696
+ }), option.media && jsxRuntime.jsx(bomMixerUi.RadioCard.Media, {
1697
+ item: option.media
1698
+ })]
1699
+ }, option.id))
1700
+ }), false , error && jsxRuntime.jsx(bomMixerUi.FormError, {
1701
+ error: error,
1702
+ children: label('form.submit.error')
1703
+ })]
1704
+ })
1705
+ })
1706
+ })
1707
+ }), jsxRuntime.jsx(bomMixerUi.Section, {
1708
+ position: "sticky",
1709
+ bottom: "0",
1710
+ padding: "1rem 0",
1711
+ zIndex: "800",
1712
+ background: "var(--color-primary-100)",
1713
+ children: jsxRuntime.jsx(bomMixerUi.Container, {
1714
+ children: jsxRuntime.jsxs(bomMixerUi.Flex.Row, {
1715
+ justifyContent: "space-between",
1716
+ children: [jsxRuntime.jsx(bomMixerUi.Flex, {
1717
+ children: jsxRuntime.jsx(bomMixerUi.Button, {
1718
+ variant: "secondary",
1719
+ onClick: onPrevious_,
1720
+ children: "Back"
1721
+ })
1722
+ }), jsxRuntime.jsx(bomMixerUi.Flex, {
1723
+ children: jsxRuntime.jsx(bomMixerUi.Button, {
1724
+ variant: "primary",
1725
+ onClick: onSubmit,
1726
+ children: "Proceed"
1727
+ })
1728
+ })]
1729
+ })
1730
+ })
1731
+ })]
1732
+ });
1733
+ };
1734
+
1735
+ const CheckoutReview = _ref => {
1736
+ let {
1737
+ onPrevious,
1738
+ onReview
1739
+ } = _ref;
1740
+ var _a, _b, _c, _d, _e, _f;
1741
+ const label = bomMixerHooks.useLabel();
1742
+ const api = bomMixerHooks.useApi();
1743
+ const currency = bomMixerHooks.useCurrency();
1744
+ const distance = bomMixerHooks.useUnit('kilometer');
1745
+ const checkout = useCheckout(state => state.checkout);
1746
+ const {
1747
+ setCheckout
1748
+ } = useCheckout(state => state.actions);
1749
+ const [options] = bomMixerHooks.useApiPost('/checkout/stores', checkout);
1750
+ // console.log('CheckoutReview', checkout);
1751
+ const [error, setError] = react.useState();
1752
+ const required = bomMixerForms.RequiredValidator();
1753
+ const [form, setValue, setTouched, reset, group] = bomMixerForms.useFormBuilder({
1754
+ store: {
1755
+ schema: 'select',
1756
+ label: 'field.store',
1757
+ options: options === null || options === void 0 ? void 0 : options.stores,
1758
+ validators: [required]
1759
+ }
1760
+ }, [options]);
1761
+ react.useEffect(() => {
1762
+ if (checkout.store || checkout.discounts) {
1763
+ setValue({
1764
+ store: checkout.store
1765
+ });
1766
+ } else if (options) {
1767
+ setValue({
1768
+ store: options.stores[0]
1769
+ });
1770
+ }
1771
+ // eslint-disable-next-line react-hooks/exhaustive-deps
1772
+ }, [options]);
1773
+ const selectedStore = (_a = form.value) === null || _a === void 0 ? void 0 : _a.store;
1774
+ const shippingAddress = checkout.shippingAddress;
1775
+ const billingAddress = checkout.billingAddress;
1776
+ const delivery = checkout.delivery;
1777
+ const subTotal = checkout.subTotal || 0;
1778
+ const subTotalFull = checkout.subTotalFull || 0;
1779
+ const taxes = checkout.taxes || 0;
1780
+ const total = checkout.total || 0;
1781
+ const onSubmit = event => __awaiter(void 0, void 0, void 0, function* () {
1782
+ event.preventDefault();
1783
+ if (form.flags.valid && form.value) {
1784
+ console.log('CheckoutReview.valid', form.value);
1785
+ try {
1786
+ setError(undefined);
1787
+ const store = form.value.store;
1788
+ const response = yield api.post('/checkout/update', {
1789
+ action: 'store',
1790
+ checkout: Object.assign(Object.assign({}, checkout), {
1791
+ store
1792
+ })
1793
+ });
1794
+ setCheckout(response);
1795
+ if (typeof onReview === 'function') {
1796
+ onReview(store);
1797
+ }
1798
+ } catch (error) {
1799
+ console.log('CheckoutReview.error', error);
1800
+ setError(error);
1801
+ }
1802
+ } else {
1803
+ console.log('CheckoutReview.invalid');
1804
+ setTouched();
1805
+ }
1806
+ });
1807
+ const onPrevious_ = () => {
1808
+ if (typeof onPrevious === 'function') {
1809
+ onPrevious();
1810
+ }
1811
+ };
1812
+ const store = group.controls.store;
1813
+ const onStoreChange = event => {
1814
+ var _a;
1815
+ group.controls.store.value = (_a = store === null || store === void 0 ? void 0 : store.options) === null || _a === void 0 ? void 0 : _a.find(x => x.id.toString() === event.target.value);
1816
+ };
1817
+ return jsxRuntime.jsxs(jsxRuntime.Fragment, {
1818
+ children: [jsxRuntime.jsx(bomMixerUi.Section, {
1819
+ children: jsxRuntime.jsx(bomMixerUi.Container, {
1820
+ children: jsxRuntime.jsxs(bomMixerUi.Flex.Col, {
1821
+ gap: "2rem",
1822
+ flexDirectionMd: "row",
1823
+ children: [jsxRuntime.jsx(bomMixerUi.Flex, {
1824
+ flexMd: "1 1 calc(100% - 375px - 2rem)",
1825
+ alignItemsMd: "flex-start",
1826
+ children: jsxRuntime.jsx(bomMixerUi.Form, {
1827
+ state: form,
1828
+ onSubmit: onSubmit,
1829
+ children: jsxRuntime.jsxs(bomMixerUi.Flex.Col, {
1830
+ flex: "1",
1831
+ rowGap: "2rem",
1832
+ children: [jsxRuntime.jsx(bomMixerUi.Text, {
1833
+ variant: "heading10",
1834
+ fontWeight: "700",
1835
+ children: "Reference store"
1836
+ }), jsxRuntime.jsx(bomMixerUi.Text, {
1837
+ variant: "paragraph10",
1838
+ marginBottom: "1rem",
1839
+ children: "Your suggested closest sales outlet for self-service pickup."
1840
+ }), selectedStore && jsxRuntime.jsxs(bomMixerUi.Flex.Col, {
1841
+ marginBottom: "1rem",
1842
+ children: [jsxRuntime.jsx(bomMixerUi.Text, {
1843
+ variant: "heading40",
1844
+ fontWeight: "700",
1845
+ children: selectedStore.name
1846
+ }), jsxRuntime.jsxs(bomMixerUi.Text, {
1847
+ children: [selectedStore.address, ", ", selectedStore.streetNumber]
1848
+ }), jsxRuntime.jsxs(bomMixerUi.Text, {
1849
+ children: [selectedStore.zipCode, " ", selectedStore.city, " ", (_b = selectedStore.country) === null || _b === void 0 ? void 0 : _b.name]
1850
+ }), jsxRuntime.jsx(bomMixerUi.Text, {
1851
+ children: selectedStore.phoneNumber
1852
+ })]
1853
+ }), store && jsxRuntime.jsx(bomMixerUi.RadioCard.Group, {
1854
+ initialValue: (_c = store.value) === null || _c === void 0 ? void 0 : _c.id.toString(),
1855
+ onChange: onStoreChange,
1856
+ maxWidth: "60ch",
1857
+ children: (_d = store.options) === null || _d === void 0 ? void 0 : _d.map(option => jsxRuntime.jsxs(bomMixerUi.RadioCard, {
1858
+ value: option.id.toString(),
1859
+ children: [jsxRuntime.jsx(bomMixerUi.RadioCard.Title, {
1860
+ children: option.name
1861
+ }), option.category && jsxRuntime.jsx(bomMixerUi.RadioCard.Abstract, {
1862
+ children: option.category.name
1863
+ }), jsxRuntime.jsx(bomMixerUi.RadioCard.Extra, {
1864
+ children: distance(option.distance)
1865
+ })]
1866
+ }, option.id))
1867
+ }), false , error && jsxRuntime.jsx(bomMixerUi.FormError, {
1868
+ error: error,
1869
+ children: label('form.submit.error')
1870
+ }), jsxRuntime.jsxs(bomMixerUi.Grid.Row, {
1871
+ padding: "2em 0",
1872
+ children: [jsxRuntime.jsx(bomMixerUi.Grid, {
1873
+ md: 6,
1874
+ children: shippingAddress && jsxRuntime.jsxs(bomMixerUi.Flex.Col, {
1875
+ gap: "1rem",
1876
+ children: [jsxRuntime.jsx(bomMixerUi.Text, {
1877
+ variant: "heading10",
1878
+ fontWeight: "700",
1879
+ children: "Shipping address"
1880
+ }), jsxRuntime.jsxs(bomMixerUi.Flex.Col, {
1881
+ children: [jsxRuntime.jsxs(bomMixerUi.Text, {
1882
+ variant: "heading40",
1883
+ fontWeight: "700",
1884
+ children: [shippingAddress.firstName, " ", shippingAddress.lastName]
1885
+ }), jsxRuntime.jsxs(bomMixerUi.Text, {
1886
+ children: [shippingAddress.address, ", ", shippingAddress.streetNumber]
1887
+ }), jsxRuntime.jsxs(bomMixerUi.Text, {
1888
+ children: [shippingAddress.zipCode, " ", shippingAddress.city, " ", (_e = shippingAddress.country) === null || _e === void 0 ? void 0 : _e.name]
1889
+ }), jsxRuntime.jsx(bomMixerUi.Text, {
1890
+ children: shippingAddress.phoneNumber
1891
+ }), jsxRuntime.jsx(bomMixerUi.Text, {
1892
+ children: shippingAddress.email
1893
+ })]
1894
+ })]
1895
+ })
1896
+ }), jsxRuntime.jsx(bomMixerUi.Grid, {
1897
+ md: 6,
1898
+ children: billingAddress && jsxRuntime.jsxs(bomMixerUi.Flex.Col, {
1899
+ gap: "1rem",
1900
+ children: [jsxRuntime.jsx(bomMixerUi.Text, {
1901
+ variant: "heading10",
1902
+ fontWeight: "700",
1903
+ children: "Billing address"
1904
+ }), jsxRuntime.jsxs(bomMixerUi.Flex.Col, {
1905
+ children: [jsxRuntime.jsxs(bomMixerUi.Text, {
1906
+ variant: "heading40",
1907
+ fontWeight: "700",
1908
+ children: [billingAddress.firstName, " ", billingAddress.lastName]
1909
+ }), jsxRuntime.jsxs(bomMixerUi.Text, {
1910
+ children: [billingAddress.address, ", ", billingAddress.streetNumber]
1911
+ }), jsxRuntime.jsxs(bomMixerUi.Text, {
1912
+ children: [billingAddress.zipCode, " ", billingAddress.city, " ", (_f = billingAddress.country) === null || _f === void 0 ? void 0 : _f.name]
1913
+ }), jsxRuntime.jsx(bomMixerUi.Text, {
1914
+ children: billingAddress.phoneNumber
1915
+ }), jsxRuntime.jsx(bomMixerUi.Text, {
1916
+ children: billingAddress.email
1917
+ })]
1918
+ })]
1919
+ })
1920
+ })]
1921
+ })]
1922
+ })
1923
+ })
1924
+ }), jsxRuntime.jsx(bomMixerUi.Flex, {
1925
+ flexMd: "0 0 375px",
1926
+ alignItemsMd: "flex-start",
1927
+ children: jsxRuntime.jsxs(bomMixerUi.Flex.Col, {
1928
+ gap: "1rem",
1929
+ positionMd: "sticky",
1930
+ topMd: "200px",
1931
+ children: [jsxRuntime.jsxs(bomMixerUi.Flex.Col, {
1932
+ gap: "1rem",
1933
+ padding: "1rem",
1934
+ borderRadius: "0.5em",
1935
+ border: "1px solid var(--color-neutral-300)",
1936
+ fontSize: "0.9em",
1937
+ lineHeight: "1",
1938
+ children: [jsxRuntime.jsxs(bomMixerUi.Flex.Row, {
1939
+ gap: "1rem",
1940
+ fontWeight: "700",
1941
+ children: [jsxRuntime.jsx(bomMixerUi.Text, {
1942
+ flexGrow: "1",
1943
+ children: "Product"
1944
+ }), jsxRuntime.jsx(bomMixerUi.Text, {
1945
+ flexBasis: "40px",
1946
+ textAlign: "right",
1947
+ children: "Qty"
1948
+ }), jsxRuntime.jsx(bomMixerUi.Text, {
1949
+ flexBasis: "90px",
1950
+ textAlign: "right",
1951
+ children: "Price"
1952
+ })]
1953
+ }), jsxRuntime.jsx(bomMixerUi.Flex.Col, {
1954
+ flex: "1",
1955
+ gap: "1rem",
1956
+ padding: "1rem 0",
1957
+ borderTop: "1px solid var(--color-neutral-300)",
1958
+ borderBottom: "1px solid var(--color-neutral-300)",
1959
+ children: checkout.items && checkout.items.map((item, i) => jsxRuntime.jsxs(bomMixerUi.Flex.Row, {
1960
+ gap: "1rem",
1961
+ children: [jsxRuntime.jsx(bomMixerUi.Text, {
1962
+ flexGrow: "1",
1963
+ children: item.title
1964
+ }), jsxRuntime.jsx(bomMixerUi.Text, {
1965
+ flexBasis: "40px",
1966
+ textAlign: "right",
1967
+ children: item.qty
1968
+ }), jsxRuntime.jsxs(bomMixerUi.Flex.Col, {
1969
+ flexBasis: "90px",
1970
+ alignItems: "flex-end",
1971
+ textAlign: "right",
1972
+ children: [jsxRuntime.jsx(bomMixerUi.Text, {
1973
+ children: currency(item.qty * item.price)
1974
+ }), item.fullPrice > item.price && jsxRuntime.jsx(bomMixerUi.Text, {
1975
+ variant: "paragraph40",
1976
+ textDecoration: "line-through",
1977
+ color: "var(--color-neutral-400)",
1978
+ children: currency(item.fullPrice * item.qty)
1979
+ })]
1980
+ })]
1981
+ }, i))
1982
+ }), jsxRuntime.jsxs(bomMixerUi.Flex.Row, {
1983
+ gap: "1rem",
1984
+ children: [jsxRuntime.jsx(bomMixerUi.Text, {
1985
+ flexGrow: "1",
1986
+ children: "Subtotal"
1987
+ }), jsxRuntime.jsx(bomMixerUi.Text, {
1988
+ flexBasis: "40px",
1989
+ textAlign: "right",
1990
+ children: "\u00A0"
1991
+ }), jsxRuntime.jsxs(bomMixerUi.Flex.Col, {
1992
+ flexBasis: "90px",
1993
+ alignItems: "flex-end",
1994
+ textAlign: "right",
1995
+ children: [jsxRuntime.jsx(bomMixerUi.Text, {
1996
+ children: currency(subTotal)
1997
+ }), subTotalFull > subTotal && jsxRuntime.jsx(bomMixerUi.Text, {
1998
+ variant: "paragraph40",
1999
+ textDecoration: "line-through",
2000
+ color: "var(--color-neutral-400)",
2001
+ children: currency(subTotalFull)
2002
+ })]
2003
+ })]
2004
+ }), checkout.discounts && checkout.discounts.map((item, i) => jsxRuntime.jsxs(bomMixerUi.Flex.Row, {
2005
+ gap: "1rem",
2006
+ children: [jsxRuntime.jsxs(bomMixerUi.Text, {
2007
+ flexGrow: "1",
2008
+ children: ["Discount ", jsxRuntime.jsx(bomMixerUi.Badge, {
2009
+ children: item.name
2010
+ })]
2011
+ }), jsxRuntime.jsx(bomMixerUi.Text, {
2012
+ flexBasis: "40px",
2013
+ textAlign: "right",
2014
+ children: item.abstract
2015
+ }), jsxRuntime.jsx(bomMixerUi.Text, {
2016
+ flexBasis: "90px",
2017
+ textAlign: "right",
2018
+ children: currency(item.price)
2019
+ })]
2020
+ }, i)), taxes > 0 && jsxRuntime.jsxs(bomMixerUi.Flex.Row, {
2021
+ gap: "1rem",
2022
+ children: [jsxRuntime.jsx(bomMixerUi.Text, {
2023
+ flexGrow: "1",
2024
+ children: "Taxes"
2025
+ }), jsxRuntime.jsx(bomMixerUi.Text, {
2026
+ flexBasis: "40px",
2027
+ textAlign: "right",
2028
+ children: "\u00A0"
2029
+ }), jsxRuntime.jsx(bomMixerUi.Text, {
2030
+ flexBasis: "90px",
2031
+ textAlign: "right",
2032
+ children: currency(taxes)
2033
+ })]
2034
+ }), delivery && jsxRuntime.jsxs(bomMixerUi.Flex.Row, {
2035
+ gap: "1rem",
2036
+ children: [jsxRuntime.jsx(bomMixerUi.Text, {
2037
+ flexGrow: "1",
2038
+ children: delivery.name
2039
+ }), jsxRuntime.jsx(bomMixerUi.Text, {
2040
+ flexBasis: "40px",
2041
+ textAlign: "right",
2042
+ children: "\u00A0"
2043
+ }), jsxRuntime.jsx(bomMixerUi.Text, {
2044
+ flexBasis: "90px",
2045
+ textAlign: "right",
2046
+ children: currency(delivery.price)
2047
+ })]
2048
+ }), jsxRuntime.jsxs(bomMixerUi.Flex.Row, {
2049
+ gap: "1rem",
2050
+ fontWeight: "700",
2051
+ marginBottom: "1rem",
2052
+ children: [jsxRuntime.jsx(bomMixerUi.Text, {
2053
+ flexGrow: "1",
2054
+ children: "Total"
2055
+ }), jsxRuntime.jsx(bomMixerUi.Text, {
2056
+ flexBasis: "40px",
2057
+ textAlign: "right",
2058
+ children: "\u00A0"
2059
+ }), jsxRuntime.jsx(bomMixerUi.Text, {
2060
+ flexBasis: "90px",
2061
+ textAlign: "right",
2062
+ children: currency(total)
2063
+ })]
2064
+ })]
2065
+ }), jsxRuntime.jsx(bomMixerUi.Box, {
2066
+ padding: "1rem",
2067
+ borderRadius: "0.5em",
2068
+ border: "1px solid var(--color-neutral-300)",
2069
+ children: jsxRuntime.jsx(CheckoutDiscount, {})
2070
+ })]
2071
+ })
2072
+ })]
2073
+ })
2074
+ })
2075
+ }), jsxRuntime.jsx(bomMixerUi.Section, {
2076
+ position: "sticky",
2077
+ bottom: "0",
2078
+ padding: "1rem 0",
2079
+ zIndex: "800",
2080
+ background: "var(--color-primary-100)",
2081
+ children: jsxRuntime.jsx(bomMixerUi.Container, {
2082
+ children: jsxRuntime.jsxs(bomMixerUi.Flex.Row, {
2083
+ justifyContent: "space-between",
2084
+ children: [jsxRuntime.jsx(bomMixerUi.Flex, {
2085
+ children: jsxRuntime.jsx(bomMixerUi.Button, {
2086
+ variant: "secondary",
2087
+ onClick: onPrevious_,
2088
+ children: "Back"
2089
+ })
2090
+ }), jsxRuntime.jsx(bomMixerUi.Flex, {
2091
+ children: jsxRuntime.jsx(bomMixerUi.Button, {
2092
+ variant: "primary",
2093
+ onClick: onSubmit,
2094
+ children: "Proceed"
2095
+ })
2096
+ })]
2097
+ })
2098
+ })
2099
+ })]
2100
+ });
2101
+ };
2102
+
2103
+ const OrderAddress = _ref => {
2104
+ let {
2105
+ item,
2106
+ title
2107
+ } = _ref;
2108
+ var _a;
2109
+ return jsxRuntime.jsxs(bomMixerUi.Flex.Col, {
2110
+ gap: "1rem",
2111
+ children: [title && jsxRuntime.jsx(bomMixerUi.Text, {
2112
+ variant: "heading30",
2113
+ fontWeight: "700",
2114
+ children: title
2115
+ }), jsxRuntime.jsxs(bomMixerUi.Flex.Col, {
2116
+ children: [jsxRuntime.jsxs(bomMixerUi.Text, {
2117
+ fontWeight: "700",
2118
+ children: [item.firstName, " ", item.lastName]
2119
+ }), jsxRuntime.jsxs(bomMixerUi.Text, {
2120
+ children: [item.address, ", ", item.streetNumber]
2121
+ }), jsxRuntime.jsxs(bomMixerUi.Text, {
2122
+ children: [item.zipCode, " ", item.city, " ", (_a = item.country) === null || _a === void 0 ? void 0 : _a.name]
2123
+ }), jsxRuntime.jsx(bomMixerUi.Text, {
2124
+ children: item.phoneNumber
2125
+ }), jsxRuntime.jsx(bomMixerUi.Text, {
2126
+ children: item.email
2127
+ })]
2128
+ })]
2129
+ });
2130
+ };
2131
+
2132
+ const OrderRegister = _ref => {
2133
+ let {
2134
+ className,
2135
+ data,
2136
+ onSignedUp
2137
+ } = _ref;
2138
+ var _a;
2139
+ const label = bomMixerHooks.useLabel();
2140
+ const [registered, setRegistered] = react.useState(false);
2141
+ const required = bomMixerForms.RequiredValidator();
2142
+ const requiredTrue = bomMixerForms.RequiredTrueValidator();
2143
+ const email = bomMixerForms.EmailValidator();
2144
+ const match = bomMixerForms.MatchValidator((value, rootValue, control, root) => {
2145
+ return rootValue === null || rootValue === void 0 ? void 0 : rootValue.password;
2146
+ });
2147
+ const [form, setValue, setTouched, reset, group] = bomMixerForms.useFormBuilder({
2148
+ password: {
2149
+ schema: 'password',
2150
+ label: 'field.password',
2151
+ validators: required
2152
+ },
2153
+ confirmPassword: {
2154
+ schema: 'password',
2155
+ label: 'field.confirmPassword',
2156
+ validators: [required, match]
2157
+ },
2158
+ firstName: {
2159
+ value: data.firstName,
2160
+ schema: 'text',
2161
+ label: 'field.firstName',
2162
+ validators: [required]
2163
+ },
2164
+ lastName: {
2165
+ value: data.lastName,
2166
+ schema: 'text',
2167
+ label: 'field.lastName',
2168
+ validators: [required]
2169
+ },
2170
+ email: {
2171
+ value: data.email,
2172
+ schema: 'text',
2173
+ label: 'field.email',
2174
+ validators: [required, email]
2175
+ },
2176
+ privacy: {
2177
+ schema: 'checkbox',
2178
+ label: 'field.privacy',
2179
+ validators: [requiredTrue]
2180
+ },
2181
+ checkField: {
2182
+ schema: 'text',
2183
+ hidden: true
2184
+ } // check hidden field for antiforgery
2185
+ });
2186
+ const onTest = () => {
2187
+ setValue({
2188
+ firstName: 'Jhon',
2189
+ lastName: 'Appleseed',
2190
+ email: 'jhon.appleseed@gmail.com',
2191
+ password: '123456',
2192
+ confirmPassword: '123456',
2193
+ privacy: true
2194
+ });
2195
+ };
2196
+ const onReset = () => {
2197
+ reset();
2198
+ };
2199
+ const [error, setError] = react.useState();
2200
+ const onSubmit = event => __awaiter(void 0, void 0, void 0, function* () {
2201
+ event.preventDefault();
2202
+ if (form.flags.valid) {
2203
+ console.log('AuthRegister.valid', form.value);
2204
+ try {
2205
+ setError(undefined);
2206
+ yield bomCore.httpPost('/api/auth/register', form.value);
2207
+ setRegistered(true);
2208
+ if (typeof onSignedUp === 'function') {
2209
+ onSignedUp();
2210
+ }
2211
+ } catch (error) {
2212
+ console.log('AuthRegister.error', error);
2213
+ setError(error);
2214
+ }
2215
+ } else {
2216
+ console.log('AuthRegister.invalid');
2217
+ setTouched();
2218
+ }
2219
+ });
2220
+ return jsxRuntime.jsx(bomMixerUi.Section, {
2221
+ className: className,
2222
+ children: jsxRuntime.jsx(bomMixerUi.Container, {
2223
+ children: jsxRuntime.jsx(bomMixerUi.Flex.Col, {
2224
+ gap: "1rem",
2225
+ padding: "1.5rem 1rem",
2226
+ borderRadius: "0.5em",
2227
+ border: "1px solid var(--color-warning-500)",
2228
+ children: registered ? jsxRuntime.jsxs(jsxRuntime.Fragment, {
2229
+ children: [jsxRuntime.jsx(bomMixerUi.Text, {
2230
+ variant: "heading30",
2231
+ fontWeight: "700",
2232
+ children: "Account created"
2233
+ }), jsxRuntime.jsxs(bomMixerUi.Text, {
2234
+ variant: "paragraph10",
2235
+ marginBottom: "1rem",
2236
+ maxWidth: "80ch",
2237
+ children: ["A confimation email has been sent to you at ", (_a = form.value) === null || _a === void 0 ? void 0 : _a.email, ". Please check your inbox."]
2238
+ })]
2239
+ }) : jsxRuntime.jsxs(jsxRuntime.Fragment, {
2240
+ children: [jsxRuntime.jsx(bomMixerUi.Text, {
2241
+ variant: "heading30",
2242
+ fontWeight: "700",
2243
+ children: "Checkout faster next time"
2244
+ }), jsxRuntime.jsx(bomMixerUi.Text, {
2245
+ variant: "paragraph10",
2246
+ marginBottom: "1rem",
2247
+ maxWidth: "80ch",
2248
+ children: "Want easy order tracking and faster checkout? Just choose a password to create your account."
2249
+ }), jsxRuntime.jsxs(bomMixerUi.Form, {
2250
+ state: form,
2251
+ onSubmit: onSubmit,
2252
+ children: [jsxRuntime.jsx(bomMixerUi.Grid.Row, {
2253
+ rowGap: "1rem",
2254
+ children: jsxRuntime.jsx(bomMixerUi.FieldCollection, {
2255
+ collection: group
2256
+ })
2257
+ }), error && jsxRuntime.jsx(bomMixerUi.FormError, {
2258
+ error: error,
2259
+ children: label('form.submit.error')
2260
+ }), jsxRuntime.jsx(bomMixerUi.Button, {
2261
+ type: "submit",
2262
+ variant: "primary",
2263
+ size: "lg",
2264
+ justifyContent: "center",
2265
+ margin: "1rem 0",
2266
+ children: jsxRuntime.jsx("span", {
2267
+ children: "Create account"
2268
+ })
2269
+ }), jsxRuntime.jsx(bomMixerUi.FormTester, {
2270
+ form: form,
2271
+ onTest: onTest,
2272
+ onReset: onReset
2273
+ })]
2274
+ })]
2275
+ })
2276
+ })
2277
+ })
2278
+ });
2279
+ };
2280
+
2281
+ const OrderSummaryItem = _ref => {
2282
+ let {
2283
+ item
2284
+ } = _ref;
2285
+ const currency = bomMixerHooks.useCurrency();
2286
+ const price = currency(item.price);
2287
+ const totalPrice = currency(item.price * item.qty);
2288
+ return jsxRuntime.jsxs(bomMixerUi.Flex.Row, {
2289
+ gap: "2rem",
2290
+ paddingBottom: "1rem",
2291
+ borderBottom: "1px solid var(--color-neutral-300)",
2292
+ children: [jsxRuntime.jsx(bomMixerUi.Flex, {
2293
+ flexGrow: "1",
2294
+ children: jsxRuntime.jsxs(bomMixerUi.Flex.Row, {
2295
+ gap: "2rem",
2296
+ children: [item.media && jsxRuntime.jsx(bomMixerUi.Media, {
2297
+ item: item.media,
2298
+ aspectRatio: 1,
2299
+ width: "120px",
2300
+ height: "120px",
2301
+ flex: "0 0 120px",
2302
+ rounded: true
2303
+ }), jsxRuntime.jsxs(bomMixerUi.Flex.Col, {
2304
+ alignItems: "flex-start",
2305
+ children: [jsxRuntime.jsx(bomMixerUi.Link, {
2306
+ href: item.href || '',
2307
+ children: jsxRuntime.jsx(bomMixerUi.Button, {
2308
+ as: "a",
2309
+ variant: "nav",
2310
+ children: jsxRuntime.jsx(bomMixerUi.Text, {
2311
+ variant: "paragraph20",
2312
+ fontWeight: "700",
2313
+ children: item.title
2314
+ })
2315
+ })
2316
+ }), jsxRuntime.jsx(bomMixerUi.Text, {
2317
+ variant: "paragraph30",
2318
+ children: item.abstract
2319
+ })]
2320
+ })]
2321
+ })
2322
+ }), jsxRuntime.jsx(bomMixerUi.Flex, {
2323
+ flexBasis: "110px",
2324
+ justifyContent: "flex-end",
2325
+ children: jsxRuntime.jsx(bomMixerUi.Text, {
2326
+ children: price
2327
+ })
2328
+ }), jsxRuntime.jsx(bomMixerUi.Flex, {
2329
+ flexBasis: "120px",
2330
+ justifyContent: "center",
2331
+ children: item.qty.toString()
2332
+ }), jsxRuntime.jsx(bomMixerUi.Flex, {
2333
+ flexBasis: "110px",
2334
+ justifyContent: "flex-end",
2335
+ children: jsxRuntime.jsx(bomMixerUi.Text, {
2336
+ children: totalPrice
2337
+ })
2338
+ })]
2339
+ });
2340
+ };
2341
+
2342
+ const OrderSummary = _ref => {
2343
+ let {
2344
+ order
2345
+ } = _ref;
2346
+ bomMixerHooks.useLabel();
2347
+ bomMixerHooks.useLayout();
2348
+ const currency = bomMixerHooks.useCurrency();
2349
+ return jsxRuntime.jsx(jsxRuntime.Fragment, {
2350
+ children: jsxRuntime.jsx(bomMixerUi.Section, {
2351
+ children: jsxRuntime.jsxs(bomMixerUi.Container, {
2352
+ children: [jsxRuntime.jsx(bomMixerUi.Text, {
2353
+ variant: "heading30",
2354
+ fontWeight: "700",
2355
+ children: "Order Summary"
2356
+ }), jsxRuntime.jsxs(bomMixerUi.Flex.Row, {
2357
+ gap: "2rem",
2358
+ padding: "1rem 0",
2359
+ fontWeight: "700",
2360
+ children: [jsxRuntime.jsx(bomMixerUi.Text, {
2361
+ flexGrow: "1",
2362
+ children: "Product"
2363
+ }), jsxRuntime.jsx(bomMixerUi.Text, {
2364
+ flexBasis: "110px",
2365
+ textAlign: "right",
2366
+ children: "Unit price"
2367
+ }), jsxRuntime.jsx(bomMixerUi.Text, {
2368
+ flexBasis: "120px",
2369
+ textAlign: "center",
2370
+ children: "Quantity"
2371
+ }), jsxRuntime.jsx(bomMixerUi.Text, {
2372
+ flexBasis: "110px",
2373
+ textAlign: "right",
2374
+ children: "Price"
2375
+ })]
2376
+ }), jsxRuntime.jsxs(bomMixerUi.Flex.Col, {
2377
+ flex: "1",
2378
+ gap: "1rem",
2379
+ children: [order.items && order.items.map((item, i) => jsxRuntime.jsx(OrderSummaryItem, {
2380
+ item: item
2381
+ }, i)), jsxRuntime.jsxs(bomMixerUi.Flex.Row, {
2382
+ gap: "1rem",
2383
+ children: [jsxRuntime.jsx(bomMixerUi.Text, {
2384
+ flexGrow: "1",
2385
+ children: "Subtotal"
2386
+ }), jsxRuntime.jsx(bomMixerUi.Text, {
2387
+ flexBasis: "110px",
2388
+ textAlign: "right",
2389
+ children: "\u00A0"
2390
+ }), jsxRuntime.jsx(bomMixerUi.Text, {
2391
+ flexBasis: "120px",
2392
+ textAlign: "center",
2393
+ children: "\u00A0"
2394
+ }), jsxRuntime.jsx(bomMixerUi.Text, {
2395
+ flexBasis: "90px",
2396
+ textAlign: "right",
2397
+ children: currency(order.subTotal)
2398
+ })]
2399
+ }), order.discounts.map((item, i) => jsxRuntime.jsxs(bomMixerUi.Flex.Row, {
2400
+ gap: "1rem",
2401
+ children: [jsxRuntime.jsxs(bomMixerUi.Text, {
2402
+ flexGrow: "1",
2403
+ children: ["Discount ", jsxRuntime.jsx(bomMixerUi.Badge, {
2404
+ children: item.name
2405
+ })]
2406
+ }), jsxRuntime.jsx(bomMixerUi.Text, {
2407
+ flexBasis: "110px",
2408
+ textAlign: "right",
2409
+ children: "\u00A0"
2410
+ }), jsxRuntime.jsx(bomMixerUi.Text, {
2411
+ flexBasis: "120px",
2412
+ textAlign: "center",
2413
+ children: item.abstract
2414
+ }), jsxRuntime.jsx(bomMixerUi.Text, {
2415
+ flexBasis: "90px",
2416
+ textAlign: "right",
2417
+ children: currency(item.price)
2418
+ })]
2419
+ }, i)), order.taxes > 0 && jsxRuntime.jsxs(bomMixerUi.Flex.Row, {
2420
+ gap: "1rem",
2421
+ children: [jsxRuntime.jsx(bomMixerUi.Text, {
2422
+ flexGrow: "1",
2423
+ children: "Taxes"
2424
+ }), jsxRuntime.jsx(bomMixerUi.Text, {
2425
+ flexBasis: "110px",
2426
+ textAlign: "right",
2427
+ children: "\u00A0"
2428
+ }), jsxRuntime.jsx(bomMixerUi.Text, {
2429
+ flexBasis: "120px",
2430
+ textAlign: "center",
2431
+ children: "\u00A0"
2432
+ }), jsxRuntime.jsx(bomMixerUi.Text, {
2433
+ flexBasis: "90px",
2434
+ textAlign: "right",
2435
+ children: currency(order.taxes)
2436
+ })]
2437
+ }), jsxRuntime.jsxs(bomMixerUi.Flex.Row, {
2438
+ gap: "1rem",
2439
+ children: [jsxRuntime.jsx(bomMixerUi.Text, {
2440
+ flexGrow: "1",
2441
+ children: order.delivery.name
2442
+ }), jsxRuntime.jsx(bomMixerUi.Text, {
2443
+ flexBasis: "110px",
2444
+ textAlign: "right",
2445
+ children: "\u00A0"
2446
+ }), jsxRuntime.jsx(bomMixerUi.Text, {
2447
+ flexBasis: "120px",
2448
+ textAlign: "center",
2449
+ children: "\u00A0"
2450
+ }), jsxRuntime.jsx(bomMixerUi.Text, {
2451
+ flexBasis: "110px",
2452
+ textAlign: "right",
2453
+ children: currency(order.delivery.price)
2454
+ })]
2455
+ }), jsxRuntime.jsxs(bomMixerUi.Flex.Row, {
2456
+ gap: "1rem",
2457
+ fontWeight: "700",
2458
+ marginBottom: "1rem",
2459
+ children: [jsxRuntime.jsx(bomMixerUi.Text, {
2460
+ flexGrow: "1",
2461
+ children: "Total"
2462
+ }), jsxRuntime.jsx(bomMixerUi.Text, {
2463
+ flexBasis: "110px",
2464
+ textAlign: "right",
2465
+ children: "\u00A0"
2466
+ }), jsxRuntime.jsx(bomMixerUi.Text, {
2467
+ flexBasis: "120px",
2468
+ textAlign: "center",
2469
+ children: "\u00A0"
2470
+ }), jsxRuntime.jsx(bomMixerUi.Text, {
2471
+ flexBasis: "110px",
2472
+ textAlign: "right",
2473
+ children: currency(order.total)
2474
+ })]
2475
+ })]
2476
+ })]
2477
+ })
2478
+ })
2479
+ });
2480
+ };
2481
+
2482
+ const CheckoutSuccess = _ref => {
2483
+ let {
2484
+ order
2485
+ } = _ref;
2486
+ const label = bomMixerHooks.useLabel();
2487
+ // console.log('CheckoutSuccess', order);
2488
+ return jsxRuntime.jsxs(jsxRuntime.Fragment, {
2489
+ children: [jsxRuntime.jsx(bomMixerUi.Section, {
2490
+ position: "sticky",
2491
+ top: "80px",
2492
+ padding: "1rem 0",
2493
+ zIndex: "800",
2494
+ background: "var(--color-primary-100)",
2495
+ children: jsxRuntime.jsx(bomMixerUi.Container.Fluid, {
2496
+ children: jsxRuntime.jsxs(bomMixerUi.Flex.Row, {
2497
+ justifyContent: "space-between",
2498
+ children: [jsxRuntime.jsxs(bomMixerUi.Text, {
2499
+ variant: "paragraph10",
2500
+ fontWeight: "700",
2501
+ children: ["Order #", order.id, " ", jsxRuntime.jsx(bomMixerUi.Badge, {
2502
+ children: label(`order.status.${order.status}`)
2503
+ })]
2504
+ }), jsxRuntime.jsx(bomMixerUi.Button, {
2505
+ className: "print-none",
2506
+ variant: "primary",
2507
+ onClick: () => window.print(),
2508
+ children: "Print"
2509
+ })]
2510
+ })
2511
+ })
2512
+ }), jsxRuntime.jsx(bomMixerUi.Section, {
2513
+ className: "print-none",
2514
+ children: jsxRuntime.jsx(bomMixerUi.Container, {
2515
+ children: jsxRuntime.jsxs(bomMixerUi.Flex.Col, {
2516
+ gap: "1rem",
2517
+ alignItems: "center",
2518
+ textAlign: "center",
2519
+ children: [jsxRuntime.jsxs(bomMixerUi.Text, {
2520
+ variant: "heading10",
2521
+ fontWeight: "700",
2522
+ children: ["Thank you for your order, ", order.user ? order.user.firstName : order.shippingAddress.firstName]
2523
+ }), jsxRuntime.jsxs(bomMixerUi.Text, {
2524
+ variant: "paragraph10",
2525
+ marginBottom: "1rem",
2526
+ maxWidth: "80ch",
2527
+ children: ["A confirmation email will be sent to you at ", order.user ? order.user.email : order.shippingAddress.email, " with your complete order details."]
2528
+ })]
2529
+ })
2530
+ })
2531
+ }), !order.user && jsxRuntime.jsx(OrderRegister, {
2532
+ className: "print-none",
2533
+ data: order.shippingAddress
2534
+ }), jsxRuntime.jsx(OrderSummary, {
2535
+ order: order
2536
+ }), jsxRuntime.jsx(bomMixerUi.Section, {
2537
+ children: jsxRuntime.jsx(bomMixerUi.Container, {
2538
+ children: jsxRuntime.jsxs(bomMixerUi.Grid.Row, {
2539
+ padding: "2em 0",
2540
+ children: [jsxRuntime.jsx(bomMixerUi.Grid, {
2541
+ md: 6,
2542
+ children: order.shippingAddress && jsxRuntime.jsx(OrderAddress, {
2543
+ item: order.shippingAddress,
2544
+ title: 'Shipping address'
2545
+ })
2546
+ }), jsxRuntime.jsx(bomMixerUi.Grid, {
2547
+ md: 6,
2548
+ children: order.billingAddress && jsxRuntime.jsx(OrderAddress, {
2549
+ item: order.billingAddress,
2550
+ title: 'Billing address'
2551
+ })
2552
+ })]
2553
+ })
2554
+ })
2555
+ })]
2556
+ });
2557
+ };
2558
+
2559
+ exports.CheckoutStatus = void 0;
2560
+ (function (CheckoutStatus) {
2561
+ CheckoutStatus[CheckoutStatus["None"] = -1] = "None";
2562
+ CheckoutStatus[CheckoutStatus["Basket"] = 0] = "Basket";
2563
+ CheckoutStatus[CheckoutStatus["Info"] = 1] = "Info";
2564
+ CheckoutStatus[CheckoutStatus["Delivery"] = 2] = "Delivery";
2565
+ CheckoutStatus[CheckoutStatus["Review"] = 3] = "Review";
2566
+ CheckoutStatus[CheckoutStatus["Payment"] = 4] = "Payment";
2567
+ CheckoutStatus[CheckoutStatus["Complete"] = 5] = "Complete";
2568
+ CheckoutStatus[CheckoutStatus["Error"] = 6] = "Error";
2569
+ })(exports.CheckoutStatus || (exports.CheckoutStatus = {}));
2570
+ const StyledWizard = styled__default.default(bomMixerUi.Flex.Row)`
2571
+ counter-reset: steps;
2572
+
2573
+ & > div {
2574
+ counter-increment: steps;
2575
+ text-transform: uppercase;
2576
+ opacity: 0.25;
2577
+
2578
+ &:before {
2579
+ content: counter(steps) ". ";
2580
+ display: block;
2581
+ font-size: 48px;
2582
+ font-weight: 100;
2583
+ line-height: 1;
2584
+ }
2585
+
2586
+ &.active {
2587
+ opacity: 1;
2588
+ }
2589
+
2590
+ @media(max-width: 800px) {
2591
+
2592
+ &:not(.active) {
2593
+ font-size: 0;
2594
+ }
2595
+
2596
+ &:before {
2597
+ font-size: 1rem;
2598
+ font-weight: 700;
2599
+ margin-right: 0.5rem;
2600
+ }
2601
+ }
2602
+ }
2603
+ `;
2604
+ const CheckoutWizard = _a => {
2605
+ var {
2606
+ onCheckout
2607
+ } = _a;
2608
+ __rest(_a, ["onCheckout"]);
2609
+ const api = bomMixerHooks.useApi();
2610
+ const checkout = useCheckout(state => state.checkout);
2611
+ // const { setCheckout } = useCheckout((state) => state.actions);
2612
+ const [status, setStatus] = react.useState(exports.CheckoutStatus.Basket);
2613
+ const onCheckout_ = checkout => {
2614
+ // setCheckout(checkout);
2615
+ if (typeof onCheckout === 'function') {
2616
+ onCheckout(checkout);
2617
+ }
2618
+ bomMixerHooks.scrollToY(0);
2619
+ };
2620
+ // 1.
2621
+ const onBasket = items => {
2622
+ console.log('CheckoutWizard.onBasket', items);
2623
+ onCheckout_(Object.assign(Object.assign({}, checkout), {
2624
+ items
2625
+ }));
2626
+ setStatus(exports.CheckoutStatus.Info);
2627
+ };
2628
+ // 2.
2629
+ const onInfo = info => {
2630
+ console.log('CheckoutWizard.onInfo', info);
2631
+ onCheckout_(Object.assign(Object.assign({}, checkout), info));
2632
+ setStatus(exports.CheckoutStatus.Delivery);
2633
+ };
2634
+ // 3.
2635
+ const onDelivery = delivery => {
2636
+ console.log('CheckoutWizard.onDelivery', delivery);
2637
+ onCheckout_(Object.assign(Object.assign({}, checkout), {
2638
+ delivery
2639
+ }));
2640
+ setStatus(exports.CheckoutStatus.Review);
2641
+ };
2642
+ // 4.
2643
+ const onReview = store => {
2644
+ console.log('CheckoutWizard.onReview', store);
2645
+ onCheckout_(Object.assign(Object.assign({}, checkout), {
2646
+ store
2647
+ }));
2648
+ setStatus(exports.CheckoutStatus.Payment);
2649
+ };
2650
+ // 5.
2651
+ const onPayment = payment => __awaiter(void 0, void 0, void 0, function* () {
2652
+ console.log('CheckoutWizard.onPayment', payment);
2653
+ try {
2654
+ const response = yield api.post('/checkout/payment', Object.assign(Object.assign({}, checkout), {
2655
+ payment
2656
+ }));
2657
+ // console.log('onPayment.response', response);
2658
+ window.location.href = response.redirectUrl;
2659
+ } catch (error) {
2660
+ console.error('onPayment.error', error);
2661
+ }
2662
+ /*
2663
+ onCheckout_({ ...checkout, payment });
2664
+ setStatus(CheckoutStatus.Complete);
2665
+ */
2666
+ });
2667
+ const onPrevious = () => {
2668
+ console.log('CheckoutWizard.onPrevious');
2669
+ if (status > exports.CheckoutStatus.Basket) {
2670
+ setStatus(status - 1);
2671
+ }
2672
+ bomMixerHooks.scrollToY(0);
2673
+ };
2674
+ return jsxRuntime.jsxs(jsxRuntime.Fragment, {
2675
+ children: [jsxRuntime.jsx(bomMixerUi.Section, {
2676
+ position: "sticky",
2677
+ top: "80px",
2678
+ padding: "1rem 0",
2679
+ zIndex: "800",
2680
+ background: "var(--color-primary-100)",
2681
+ children: jsxRuntime.jsx(bomMixerUi.Container, {
2682
+ children: jsxRuntime.jsxs(StyledWizard, {
2683
+ justifyContent: "space-between",
2684
+ children: [jsxRuntime.jsx(bomMixerUi.Flex, {
2685
+ className: bomCore.getClassNames({
2686
+ active: status === exports.CheckoutStatus.Basket
2687
+ }),
2688
+ children: "Basket"
2689
+ }), jsxRuntime.jsx(bomMixerUi.Flex, {
2690
+ className: bomCore.getClassNames({
2691
+ active: status === exports.CheckoutStatus.Info
2692
+ }),
2693
+ children: "User data"
2694
+ }), jsxRuntime.jsx(bomMixerUi.Flex, {
2695
+ className: bomCore.getClassNames({
2696
+ active: status === exports.CheckoutStatus.Delivery
2697
+ }),
2698
+ children: "Delivery"
2699
+ }), jsxRuntime.jsx(bomMixerUi.Flex, {
2700
+ className: bomCore.getClassNames({
2701
+ active: status === exports.CheckoutStatus.Review
2702
+ }),
2703
+ children: "Review"
2704
+ }), jsxRuntime.jsx(bomMixerUi.Flex, {
2705
+ className: bomCore.getClassNames({
2706
+ active: status === exports.CheckoutStatus.Payment
2707
+ }),
2708
+ children: "Payment"
2709
+ }), jsxRuntime.jsx(bomMixerUi.Flex, {
2710
+ className: bomCore.getClassNames({
2711
+ active: status === exports.CheckoutStatus.Complete
2712
+ }),
2713
+ children: "Complete"
2714
+ })]
2715
+ })
2716
+ })
2717
+ }), status === exports.CheckoutStatus.Basket && jsxRuntime.jsx(CheckoutBasket, {
2718
+ onBasket: onBasket
2719
+ }), status === exports.CheckoutStatus.Info && jsxRuntime.jsx(CheckoutInfo, {
2720
+ onInfo: onInfo,
2721
+ onPrevious: onPrevious
2722
+ }), status === exports.CheckoutStatus.Delivery && jsxRuntime.jsx(CheckoutDelivery, {
2723
+ onDelivery: onDelivery,
2724
+ onPrevious: onPrevious
2725
+ }), status === exports.CheckoutStatus.Review && jsxRuntime.jsx(CheckoutReview, {
2726
+ onReview: onReview,
2727
+ onPrevious: onPrevious
2728
+ }), status === exports.CheckoutStatus.Payment && jsxRuntime.jsx(CheckoutPayment, {
2729
+ onPayment: onPayment,
2730
+ onPrevious: onPrevious
2731
+ })]
2732
+ });
2733
+ };
2734
+
2735
+ // step 1.
2736
+ function getItems(items, market, locale, user) {
2737
+ return __awaiter(this, void 0, void 0, function* () {
2738
+ // !!! todo calculate user discount price
2739
+ return items.map(x => Object.assign(Object.assign({}, x), {
2740
+ fullPrice: x.price * 1.1,
2741
+ price: x.price
2742
+ }));
2743
+ });
2744
+ }
2745
+ // step 2.
2746
+ function getInfo(checkout, market, locale) {
2747
+ return __awaiter(this, void 0, void 0, function* () {
2748
+ const countries = yield bomMixerModels.getCountries(locale);
2749
+ const provinces = yield bomMixerModels.getProvinces(locale);
2750
+ const regions = yield bomMixerModels.getRegions(locale);
2751
+ const data = {
2752
+ countries,
2753
+ regions,
2754
+ provinces
2755
+ };
2756
+ return data;
2757
+ });
2758
+ }
2759
+ // step 3.
2760
+ function getDeliveries(checkout, market, locale) {
2761
+ return __awaiter(this, void 0, void 0, function* () {
2762
+ return [{
2763
+ 'id': 1,
2764
+ 'name': 'In-store pick up',
2765
+ 'abstract': 'Conveniently collect from your nearest shop at no extra charge',
2766
+ 'price': 0,
2767
+ 'fullPrice': 0
2768
+ }, {
2769
+ 'id': 2,
2770
+ 'name': 'Courier delivery',
2771
+ 'abstract': 'Packaged goods are delivered by our trusted forwarder.',
2772
+ 'price': 81,
2773
+ 'fullPrice': 81
2774
+ }, {
2775
+ 'id': 3,
2776
+ 'name': 'In-home courier delivery',
2777
+ 'abstract': 'Packaged goods are delivered inside at front door. <br>White glove delivery, unpacking, assembly, or removal of debris is optional on request.',
2778
+ 'price': 156,
2779
+ 'fullPrice': 156
2780
+ }];
2781
+ });
2782
+ }
2783
+ // step 4.
2784
+ function getStores(checkout, market, locale) {
2785
+ return __awaiter(this, void 0, void 0, function* () {
2786
+ return [{
2787
+ 'id': 10366,
2788
+ 'category': {
2789
+ 'id': 'store_category_distributor',
2790
+ 'name': 'Mixer Distributor'
2791
+ },
2792
+ 'name': 'Di Paolo Arredamenti',
2793
+ 'address': 'Viale Cesare Battisti',
2794
+ 'streetNumber': '80',
2795
+ 'zipCode': '64020',
2796
+ 'city': 'Bellante',
2797
+ 'country': {
2798
+ 'id': 'it',
2799
+ 'name': 'Italy'
2800
+ },
2801
+ 'phoneNumber': '+39 0861 616436',
2802
+ 'timetable': [],
2803
+ 'position': {
2804
+ 'latitude': 0.0,
2805
+ 'longitude': 0.0
2806
+ },
2807
+ 'distance': 151.84174300013095,
2808
+ 'rank': 1
2809
+ }, {
2810
+ 'id': 7430,
2811
+ 'category': {
2812
+ 'id': 'store_category_distributor',
2813
+ 'name': 'Mixer Distributor'
2814
+ },
2815
+ 'name': 'Mancini Italian Design & Art S.r.l.',
2816
+ 'address': 'Via Ascari',
2817
+ 'streetNumber': '2',
2818
+ 'zipCode': '41053',
2819
+ 'city': 'Maranello',
2820
+ 'country': {
2821
+ 'id': 'it',
2822
+ 'name': 'Italy'
2823
+ },
2824
+ 'email': 'info@mancinimida.com',
2825
+ 'timetable': [],
2826
+ 'position': {
2827
+ 'latitude': 0.0,
2828
+ 'longitude': 0.0
2829
+ },
2830
+ 'distance': 170.6551472799284,
2831
+ 'rank': 2
2832
+ }, {
2833
+ 'id': 325,
2834
+ 'category': {
2835
+ 'id': 'store_category_distributor',
2836
+ 'name': 'Mixer Distributor'
2837
+ },
2838
+ 'name': 'AD dal Pozzo',
2839
+ 'address': 'Via Mazzini',
2840
+ 'streetNumber': '24',
2841
+ 'zipCode': '36040',
2842
+ 'city': 'Grisignano Di Zocco',
2843
+ 'country': {
2844
+ 'id': 'it',
2845
+ 'name': 'Italy'
2846
+ },
2847
+ 'phoneNumber': '+39 0444 614521',
2848
+ 'email': 'mfort@websolute.it',
2849
+ 'timetable': [],
2850
+ 'position': {
2851
+ 'latitude': 0.0,
2852
+ 'longitude': 0.0
2853
+ },
2854
+ 'distance': 196.0600048738732,
2855
+ 'rank': 3
2856
+ }];
2857
+ });
2858
+ }
2859
+ // step 5.
2860
+ function getPayments(checkout, market, locale) {
2861
+ return __awaiter(this, void 0, void 0, function* () {
2862
+ return [{
2863
+ 'id': 'alipay',
2864
+ 'name': 'Alipay',
2865
+ 'media': {
2866
+ 'type': 'image',
2867
+ 'src': '/assets/payment/alipay.svg'
2868
+ }
2869
+ }, {
2870
+ 'id': 'amex',
2871
+ 'name': 'American Express',
2872
+ 'media': {
2873
+ 'type': 'image',
2874
+ 'src': '/assets/payment/american-express.svg'
2875
+ }
2876
+ }, {
2877
+ 'id': 'apple-pay',
2878
+ 'name': 'Apple Pay',
2879
+ 'media': {
2880
+ 'type': 'image',
2881
+ 'src': '/assets/payment/apple-pay.svg'
2882
+ }
2883
+ }, {
2884
+ 'id': 'bank-transfer',
2885
+ 'name': 'Bank Transfer',
2886
+ 'media': {
2887
+ 'type': 'image',
2888
+ 'src': '/assets/payment/bank-transfer.svg'
2889
+ }
2890
+ }, {
2891
+ 'id': 'cbc',
2892
+ 'name': 'CBC',
2893
+ 'media': {
2894
+ 'type': 'image',
2895
+ 'src': '/assets/payment/cbc.svg'
2896
+ }
2897
+ }, {
2898
+ 'id': 'direct-debit',
2899
+ 'name': 'Direct Debit',
2900
+ 'media': {
2901
+ 'type': 'image',
2902
+ 'src': '/assets/payment/direct-debit.svg'
2903
+ }
2904
+ }, {
2905
+ 'id': 'googlepay',
2906
+ 'name': 'Google Pay',
2907
+ 'media': {
2908
+ 'type': 'image',
2909
+ 'src': '/assets/payment/googlepay.svg'
2910
+ }
2911
+ }, {
2912
+ 'id': 'ideal',
2913
+ 'name': 'iDEAL',
2914
+ 'media': {
2915
+ 'type': 'image',
2916
+ 'src': '/assets/payment/ideal.svg'
2917
+ }
2918
+ }, {
2919
+ 'id': 'maestro',
2920
+ 'name': 'Maestro',
2921
+ 'media': {
2922
+ 'type': 'image',
2923
+ 'src': '/assets/payment/maestro.svg'
2924
+ }
2925
+ }, {
2926
+ 'id': 'mastercard',
2927
+ 'name': 'MasterCard',
2928
+ 'abstract': '<p>You can use your Mastercard credit card. The 3DS authentication procedure will be used when the order is concluded, and you will be redirected to the bank\'s web page. To complete the order, follow the required steps.</p>',
2929
+ 'media': {
2930
+ 'type': 'image',
2931
+ 'src': '/assets/payment/mastercard.svg'
2932
+ }
2933
+ }, {
2934
+ 'id': 'mybank',
2935
+ 'name': 'MyBank',
2936
+ 'media': {
2937
+ 'type': 'image',
2938
+ 'src': '/assets/payment/mybank.svg'
2939
+ }
2940
+ }, {
2941
+ 'id': 'paypal',
2942
+ 'name': 'PayPal',
2943
+ 'media': {
2944
+ 'type': 'image',
2945
+ 'src': '/assets/payment/paypal.svg'
2946
+ }
2947
+ }, {
2948
+ 'id': 'trustly',
2949
+ 'name': 'Trustly',
2950
+ 'media': {
2951
+ 'type': 'image',
2952
+ 'src': '/assets/payment/trustly.svg'
2953
+ }
2954
+ }, {
2955
+ 'id': 'visa',
2956
+ 'name': 'Visa',
2957
+ 'abstract': '<p>You can use your Visa credit card. The 3DS authentication procedure will be used when the order is concluded, and you will be redirected to the bank\'s web page. To complete the order, follow the required steps.</p>',
2958
+ 'media': {
2959
+ 'type': 'image',
2960
+ 'src': '/assets/payment/visa.svg'
2961
+ }
2962
+ }, {
2963
+ 'id': 'wechatpay',
2964
+ 'name': 'WeChat Pay',
2965
+ 'media': {
2966
+ 'type': 'image',
2967
+ 'src': '/assets/payment/wechatpay.svg'
2968
+ }
2969
+ }, {
2970
+ 'id': 'wire-transfer',
2971
+ 'name': 'Wire Transfer',
2972
+ 'abstract': '<p>The order confirmation will contain a summary of the total amount to be paid and the details of the bank to which the payment is to be made..</p><p> Once the payment has been made, the order will be activated and the delivery terms indicated for the various items ordered will apply. The successful completion of the payment will be communicated by email to the email address indicated during registration.</p>',
2973
+ 'media': {
2974
+ 'type': 'image',
2975
+ 'src': '/assets/payment/wire-transfer.svg'
2976
+ }
2977
+ }];
2978
+ });
2979
+ }
2980
+ // update
2981
+ function updateCheckout(checkout, action, market, locale) {
2982
+ return __awaiter(this, void 0, void 0, function* () {
2983
+ var _a;
2984
+ // generic checkout update
2985
+ /*
2986
+ switch (action) {
2987
+ case 'basket':
2988
+ break;
2989
+ case 'info':
2990
+ break;
2991
+ case 'delivery':
2992
+ break;
2993
+ case 'store':
2994
+ break;
2995
+ case 'discount':
2996
+ break;
2997
+ case 'payment':
2998
+ break;
2999
+ }
3000
+ */
3001
+ // recalculate price
3002
+ const subTotal = checkout.items ? checkout.items.reduce((p, c) => {
3003
+ return p + c.price * c.qty;
3004
+ }, 0) : 0;
3005
+ const subTotalFull = checkout.items ? checkout.items.reduce((p, c) => {
3006
+ return p + c.fullPrice * c.qty;
3007
+ }, 0) : 0;
3008
+ const subTotalDiscountPrice = checkout.discounts ? checkout.discounts.reduce((p, c) => {
3009
+ let value = 0;
3010
+ switch (c.id) {
3011
+ case 'coupon10':
3012
+ value = subTotal * 0.1 * -1;
3013
+ c.price = value;
3014
+ break;
3015
+ case 'coupon50':
3016
+ value = subTotal * 0.5 * -1;
3017
+ c.price = value;
3018
+ break;
3019
+ }
3020
+ return p + value;
3021
+ }, 0) : 0;
3022
+ const deliveryPrice = ((_a = checkout.delivery) === null || _a === void 0 ? void 0 : _a.price) || 0;
3023
+ const afterTaxesDiscountPrice = checkout.discounts ? checkout.discounts.reduce((p, c) => {
3024
+ let value = 0;
3025
+ switch (c.id) {
3026
+ case 'shipping':
3027
+ value = deliveryPrice * -1;
3028
+ c.price = value;
3029
+ break;
3030
+ }
3031
+ return p + value;
3032
+ }, 0) : 0;
3033
+ // const totalDiscountPrice = subTotalDiscountPrice + afterTaxesDiscountPrice;
3034
+ const taxes = (subTotal + subTotalDiscountPrice) * 0.2;
3035
+ const total = subTotal + subTotalDiscountPrice + taxes + deliveryPrice + afterTaxesDiscountPrice;
3036
+ checkout.subTotal = subTotal;
3037
+ checkout.subTotalFull = subTotalFull;
3038
+ checkout.taxes = taxes;
3039
+ checkout.total = total;
3040
+ return checkout;
3041
+ });
3042
+ }
3043
+ // discounts
3044
+ function setDiscountCode(discountCode, checkout, market, locale) {
3045
+ return __awaiter(this, void 0, void 0, function* () {
3046
+ var _a, _b, _c;
3047
+ const discounts = []; // checkout.discounts || [];
3048
+ if (discountCode === 'shipping') {
3049
+ discounts.push({
3050
+ 'id': 'shipping',
3051
+ 'name': 'shipping',
3052
+ 'abstract': 'Free shipping',
3053
+ 'price': (((_a = checkout.delivery) === null || _a === void 0 ? void 0 : _a.price) || 0) * -1,
3054
+ 'validFrom': new Date(),
3055
+ 'validTo': new Date()
3056
+ });
3057
+ }
3058
+ if (discountCode === 'coupon10') {
3059
+ discounts.push({
3060
+ 'id': 'coupon10',
3061
+ 'name': 'coupon10',
3062
+ 'abstract': '10%',
3063
+ 'price': (((_b = checkout.items) === null || _b === void 0 ? void 0 : _b.reduce((p, c) => p + c.price * c.qty * 0.1, 0)) || 0) * -1,
3064
+ 'validFrom': new Date(),
3065
+ 'validTo': new Date()
3066
+ });
3067
+ }
3068
+ if (discountCode === 'coupon50') {
3069
+ discounts.push({
3070
+ 'id': 'coupon50',
3071
+ 'name': 'coupon50',
3072
+ 'abstract': '50%',
3073
+ 'price': (((_c = checkout.items) === null || _c === void 0 ? void 0 : _c.reduce((p, c) => p + c.price * c.qty * 0.5, 0)) || 0) * -1,
3074
+ 'validFrom': new Date(),
3075
+ 'validTo': new Date()
3076
+ });
3077
+ }
3078
+ return yield updateCheckout(Object.assign(Object.assign({}, checkout), {
3079
+ discounts
3080
+ }));
3081
+ });
3082
+ }
3083
+ // payment
3084
+ function getPayment(checkout, market, locale) {
3085
+ return __awaiter(this, void 0, void 0, function* () {
3086
+ const knownRoutes = yield bomMixerModels.getRoutesForSchemas(['checkout_result'], market, locale);
3087
+ // !!! todo return payment redirectUrl
3088
+ const redirectUrl = `${knownRoutes.checkout_result}?orderId=1&status=OK`;
3089
+ return {
3090
+ redirectUrl
3091
+ };
3092
+ });
3093
+ }
3094
+
3095
+ const IOrderStatus = {
3096
+ Pending: 'pending',
3097
+ // Customer started the checkout process but did not complete it. Incomplete orders are assigned a "Pending" status and can be found under the More tab in the View Orders screen.
3098
+ AwaitingPayment: 'awaitingPayment',
3099
+ // Customer has completed the checkout process, but payment has yet to be confirmed. Authorize only transactions that are not yet captured have this status.
3100
+ AwaitingFulfillment: 'awaitingFulfillment',
3101
+ // Customer has completed the checkout process and payment has been confirmed.
3102
+ AwaitingShipment: 'awaitingShipment',
3103
+ // Order has been pulled and packaged and is awaiting collection from a shipping provider.
3104
+ AwaitingPickup: 'awaitingPickup',
3105
+ // Order has been packaged and is awaiting customer pickup from a seller-specified location.
3106
+ PartiallyShipped: 'partiallyShipped',
3107
+ // Only some items in the order have been shipped.
3108
+ Completed: 'completed',
3109
+ // Order has been shipped/picked up, and receipt is confirmed; client has paid for their digital product, and their file(s) are available for download.
3110
+ Shipped: 'shipped',
3111
+ // Order has been shipped, but receipt has not been confirmed; seller has used the Ship Items action. A listing of all orders with a "Shipped" status can be found under the More tab of the View Orders screen.
3112
+ Cancelled: 'cancelled',
3113
+ // Seller has cancelled an order, due to a stock inconsistency or other reasons. Stock levels will automatically update depending on your Inventory Settings. Cancelling an order will not refund the order. This status is triggered automatically when an order using an authorize-only payment gateway is voided in the control panel before capturing payment.
3114
+ Declined: 'declined',
3115
+ // Seller has marked the order as declined.
3116
+ Refunded: 'refunded',
3117
+ // Seller has used the Refund action to refund the whole order. A listing of all orders with a "Refunded" status can be found under the More tab of the View Orders screen.
3118
+ Disputed: 'disputed',
3119
+ // Customer has initiated a dispute resolution process for the PayPal transaction that paid for the order or the seller has marked the order as a fraudulent order.
3120
+ ManualVerificationRequired: 'manualVerificationRequired',
3121
+ // Order on hold while some aspect, such as tax-exempt documentation, is manually confirmed. Orders with this status must be updated manually. Capturing funds or other order actions will not automatically update the status of an order marked Manual Verification Required.
3122
+ PartiallyRefunded: 'partiallyRefunded' // Seller has partially refunded the order.
3123
+ };
3124
+
3125
+ function getOrders() {
3126
+ return __awaiter(this, arguments, void 0, function (params) {
3127
+ if (params === void 0) {
3128
+ params = {};
3129
+ }
3130
+ return function* () {
3131
+ const store = yield bomMixerStore.getStore();
3132
+ const items = yield store.order.findMany(params);
3133
+ const {
3134
+ market,
3135
+ locale
3136
+ } = params;
3137
+ if (typeof market === 'string' && typeof locale === 'string') {
3138
+ const knownRoutes = yield bomMixerModels.getRoutesForTemplates(['reserved_area_order_detail'], params.market, params.locale);
3139
+ return items.map(x => Object.assign(Object.assign({}, x), {
3140
+ href: `${knownRoutes.reserved_area_order_detail}?orderId=${x.id}`
3141
+ }));
3142
+ }
3143
+ return items;
3144
+ }();
3145
+ });
3146
+ }
3147
+ function getOrder(id_1) {
3148
+ return __awaiter(this, arguments, void 0, function (id, params) {
3149
+ if (params === void 0) {
3150
+ params = {};
3151
+ }
3152
+ return function* () {
3153
+ const store = yield bomMixerStore.getStore();
3154
+ const item = yield store.order.findOne(id, params);
3155
+ if (item) {
3156
+ const {
3157
+ market,
3158
+ locale
3159
+ } = params;
3160
+ if (typeof market === 'string' && typeof locale === 'string') {
3161
+ const knownRoutes = yield bomMixerModels.getRoutesForTemplates(['reserved_area_order_detail'], params.market, params.locale);
3162
+ return Object.assign(Object.assign({}, item), {
3163
+ href: `${knownRoutes.reserved_area_order_detail}?orderId=${item.id}`
3164
+ });
3165
+ }
3166
+ }
3167
+ return item;
3168
+ }();
3169
+ });
3170
+ }
3171
+
3172
+ const OrderItem = _ref => {
3173
+ let {
3174
+ item
3175
+ } = _ref;
3176
+ bomMixerHooks.useLayout();
3177
+ const label = bomMixerHooks.useLabel();
3178
+ const dateTimeFormat = bomMixerHooks.useDateTimeFormat({
3179
+ year: 'numeric',
3180
+ month: 'short',
3181
+ day: 'numeric'
3182
+ });
3183
+ const currency = bomMixerHooks.useCurrency();
3184
+ const qty = item.items.reduce((p, c) => p + c.qty, 0);
3185
+ return jsxRuntime.jsxs(bomMixerUi.Flex.Row, {
3186
+ gap: "2rem",
3187
+ padding: "1rem",
3188
+ border: "1px solid var(--color-neutral-300)",
3189
+ children: [jsxRuntime.jsxs(bomMixerUi.Box, {
3190
+ flexBasis: "80px",
3191
+ children: [jsxRuntime.jsx(bomMixerUi.Text, {
3192
+ variant: "paragraph40",
3193
+ fontWeight: "700",
3194
+ children: "ID"
3195
+ }), jsxRuntime.jsx(bomMixerUi.NavLink, {
3196
+ href: item.href,
3197
+ children: jsxRuntime.jsxs(bomMixerUi.Button, {
3198
+ as: "a",
3199
+ variant: "underline",
3200
+ children: ["#", item.id]
3201
+ })
3202
+ })]
3203
+ }), jsxRuntime.jsxs(bomMixerUi.Box, {
3204
+ flexBasis: "120px",
3205
+ children: [jsxRuntime.jsx(bomMixerUi.Text, {
3206
+ variant: "paragraph40",
3207
+ fontWeight: "700",
3208
+ children: "Order placed"
3209
+ }), jsxRuntime.jsx(bomMixerUi.Text, {
3210
+ variant: "paragraph30",
3211
+ children: dateTimeFormat(item.date)
3212
+ })]
3213
+ }), jsxRuntime.jsxs(bomMixerUi.Box, {
3214
+ flexBasis: "160px",
3215
+ children: [jsxRuntime.jsx(bomMixerUi.Text, {
3216
+ variant: "paragraph40",
3217
+ fontWeight: "700",
3218
+ children: "Current status"
3219
+ }), jsxRuntime.jsx(bomMixerUi.Badge, {
3220
+ children: label(`order.status.${item.status}`)
3221
+ })]
3222
+ }), jsxRuntime.jsxs(bomMixerUi.Box, {
3223
+ flexBasis: "120px",
3224
+ children: [jsxRuntime.jsx(bomMixerUi.Text, {
3225
+ variant: "paragraph40",
3226
+ fontWeight: "700",
3227
+ children: "Articles"
3228
+ }), jsxRuntime.jsx(bomMixerUi.Text, {
3229
+ variant: "paragraph30",
3230
+ children: qty.toString()
3231
+ })]
3232
+ }), jsxRuntime.jsxs(bomMixerUi.Box, {
3233
+ flexBasis: "120px",
3234
+ textAlign: "right",
3235
+ children: [jsxRuntime.jsx(bomMixerUi.Text, {
3236
+ variant: "paragraph40",
3237
+ fontWeight: "700",
3238
+ children: "Total"
3239
+ }), jsxRuntime.jsx(bomMixerUi.Text, {
3240
+ variant: "paragraph30",
3241
+ children: currency(item.total)
3242
+ })]
3243
+ }), jsxRuntime.jsx(bomMixerUi.Box, {
3244
+ flexGrow: "1",
3245
+ textAlign: "right",
3246
+ children: jsxRuntime.jsx(bomMixerUi.NavLink, {
3247
+ href: item.href,
3248
+ children: jsxRuntime.jsx(bomMixerUi.Button, {
3249
+ as: "a",
3250
+ variant: "primary",
3251
+ size: "sm",
3252
+ children: "Order detail"
3253
+ })
3254
+ })
3255
+ })]
3256
+ });
3257
+ };
3258
+
3259
+ exports.CartContext = CartContext;
3260
+ exports.CartProvider = CartProvider;
3261
+ exports.CheckoutBasket = CheckoutBasket;
3262
+ exports.CheckoutBasketItem = CheckoutBasketItem;
3263
+ exports.CheckoutContext = CheckoutContext;
3264
+ exports.CheckoutDelivery = CheckoutDelivery;
3265
+ exports.CheckoutDiscount = CheckoutDiscount;
3266
+ exports.CheckoutEmpty = CheckoutEmpty;
3267
+ exports.CheckoutError = CheckoutError;
3268
+ exports.CheckoutForgot = CheckoutForgot;
3269
+ exports.CheckoutForgotSuccess = CheckoutForgotSuccess;
3270
+ exports.CheckoutInfo = CheckoutInfo;
3271
+ exports.CheckoutLogin = CheckoutLogin;
3272
+ exports.CheckoutPayment = CheckoutPayment;
3273
+ exports.CheckoutProvider = CheckoutProvider;
3274
+ exports.CheckoutRegister = CheckoutRegister;
3275
+ exports.CheckoutRegisterSuccess = CheckoutRegisterSuccess;
3276
+ exports.CheckoutReview = CheckoutReview;
3277
+ exports.CheckoutSuccess = CheckoutSuccess;
3278
+ exports.CheckoutUserInfo = CheckoutUserInfo;
3279
+ exports.CheckoutWizard = CheckoutWizard;
3280
+ exports.IOrderStatus = IOrderStatus;
3281
+ exports.OrderAddress = OrderAddress;
3282
+ exports.OrderItem = OrderItem;
3283
+ exports.OrderRegister = OrderRegister;
3284
+ exports.OrderSummary = OrderSummary;
3285
+ exports.OrderSummaryItem = OrderSummaryItem;
3286
+ exports.getDeliveries = getDeliveries;
3287
+ exports.getInfo = getInfo;
3288
+ exports.getItems = getItems;
3289
+ exports.getOrder = getOrder;
3290
+ exports.getOrders = getOrders;
3291
+ exports.getPayment = getPayment;
3292
+ exports.getPayments = getPayments;
3293
+ exports.getStores = getStores;
3294
+ exports.setDiscountCode = setDiscountCode;
3295
+ exports.updateCheckout = updateCheckout;
3296
+ exports.useCart = useCart;
3297
+ exports.useCheckout = useCheckout;
3298
+ //# sourceMappingURL=index.js.map