tf-checkout-react 1.4.9 → 1.4.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/tf-checkout-react.cjs.development.js +1 -1
- package/dist/tf-checkout-react.cjs.development.js.map +1 -1
- package/dist/tf-checkout-react.cjs.production.min.js +1 -1
- package/dist/tf-checkout-react.cjs.production.min.js.map +1 -1
- package/dist/tf-checkout-react.esm.js +1 -1
- package/dist/tf-checkout-react.esm.js.map +1 -1
- package/package.json +2 -2
- package/src/components/common/dist/PhoneNumberField.js +96 -0
- package/src/components/paymentContainer/index.tsx +61 -62
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "1.4.
|
|
2
|
+
"version": "1.4.10",
|
|
3
3
|
"license": "MIT",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"typings": "dist/index.d.ts",
|
|
@@ -103,7 +103,7 @@
|
|
|
103
103
|
"react-countdown": "^2.3.2",
|
|
104
104
|
"react-inlinesvg": "^2.3.0",
|
|
105
105
|
"react-share": "^4.4.0",
|
|
106
|
-
"tf-seat-map-view": "9.4.7-beta.
|
|
106
|
+
"tf-seat-map-view": "9.4.7-beta.28",
|
|
107
107
|
"yup": "^0.32.11",
|
|
108
108
|
"react-app-polyfill": "^1.0.0",
|
|
109
109
|
"react-router-dom": "^6.0.2",
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
14
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
15
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
16
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
17
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
18
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
19
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
20
|
+
});
|
|
21
|
+
};
|
|
22
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
23
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
24
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
25
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
26
|
+
function step(op) {
|
|
27
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
28
|
+
while (_) try {
|
|
29
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
30
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
31
|
+
switch (op[0]) {
|
|
32
|
+
case 0: case 1: t = op; break;
|
|
33
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
34
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
35
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
36
|
+
default:
|
|
37
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
38
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
39
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
40
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
41
|
+
if (t[2]) _.ops.pop();
|
|
42
|
+
_.trys.pop(); continue;
|
|
43
|
+
}
|
|
44
|
+
op = body.call(thisArg, _);
|
|
45
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
46
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
exports.__esModule = true;
|
|
50
|
+
exports.PhoneNumberField = void 0;
|
|
51
|
+
var TextField_1 = require("@mui/material/TextField");
|
|
52
|
+
var debounce_1 = require("lodash/debounce");
|
|
53
|
+
var get_1 = require("lodash/get");
|
|
54
|
+
var react_1 = require("react");
|
|
55
|
+
var api_1 = require("../../api");
|
|
56
|
+
exports.PhoneNumberField = function (_a) {
|
|
57
|
+
var label = _a.label, _b = _a.type, type = _b === void 0 ? 'text' : _b, field = _a.field, _c = _a.form, errors = _c.errors, setFieldError = _c.setFieldError, setStatus = _c.setStatus;
|
|
58
|
+
var error = get_1["default"](errors, field.name);
|
|
59
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
60
|
+
var debounceCb = react_1.useCallback(debounce_1["default"](function (cb) { return void cb(); }, 1000), []);
|
|
61
|
+
react_1.useEffect(function () {
|
|
62
|
+
var _a;
|
|
63
|
+
if (field.value) {
|
|
64
|
+
setStatus((_a = {}, _a[field.name] = true, _a));
|
|
65
|
+
}
|
|
66
|
+
debounceCb(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
67
|
+
var error_1, message;
|
|
68
|
+
var _a;
|
|
69
|
+
return __generator(this, function (_b) {
|
|
70
|
+
switch (_b.label) {
|
|
71
|
+
case 0:
|
|
72
|
+
_b.trys.push([0, 3, 4, 5]);
|
|
73
|
+
if (!field.value) return [3 /*break*/, 2];
|
|
74
|
+
return [4 /*yield*/, api_1.validatePhoneNumber(field.value)];
|
|
75
|
+
case 1:
|
|
76
|
+
_b.sent();
|
|
77
|
+
_b.label = 2;
|
|
78
|
+
case 2:
|
|
79
|
+
setFieldError(field.name, '');
|
|
80
|
+
return [3 /*break*/, 5];
|
|
81
|
+
case 3:
|
|
82
|
+
error_1 = _b.sent();
|
|
83
|
+
message = get_1["default"](error_1, 'response.data.message', 'Invalid phone number');
|
|
84
|
+
setFieldError(field.name, message);
|
|
85
|
+
return [3 /*break*/, 5];
|
|
86
|
+
case 4:
|
|
87
|
+
setStatus((_a = {}, _a[field.name] = false, _a));
|
|
88
|
+
return [7 /*endfinally*/];
|
|
89
|
+
case 5: return [2 /*return*/];
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
}); });
|
|
93
|
+
// eslint-disable-next-line
|
|
94
|
+
}, [field.value]);
|
|
95
|
+
return (react_1["default"].createElement(TextField_1["default"], __assign({}, field, { id: field.name, label: label, type: type, fullWidth: true, error: !!error, helperText: error, value: field.value || '', inputProps: { pattern: '[+0-9]/d+' } })));
|
|
96
|
+
};
|
|
@@ -204,10 +204,10 @@ export const PaymentContainer = ({
|
|
|
204
204
|
setConditions(
|
|
205
205
|
conditionsInfo
|
|
206
206
|
? conditionsInfo.map((item: string) => ({
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
207
|
+
id: nanoid(),
|
|
208
|
+
text: item,
|
|
209
|
+
checked: false,
|
|
210
|
+
}))
|
|
211
211
|
: []
|
|
212
212
|
)
|
|
213
213
|
}
|
|
@@ -260,42 +260,42 @@ export const PaymentContainer = ({
|
|
|
260
260
|
const hasTableTypes = Boolean(Number(orderData.guest_count))
|
|
261
261
|
const paymentFieldsData = hasTableTypes
|
|
262
262
|
? [
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
263
|
+
{
|
|
264
|
+
label: 'Event',
|
|
265
|
+
id: 'product_name',
|
|
266
|
+
},
|
|
267
|
+
{
|
|
268
|
+
label: '',
|
|
269
|
+
id: 'tableTypes',
|
|
270
|
+
},
|
|
271
|
+
{
|
|
272
|
+
label: 'Total (incl. fees, card processing and taxes)',
|
|
273
|
+
id: 'total',
|
|
274
|
+
normalizer: (value: string, currency: any) =>
|
|
275
|
+
currencyNormalizerCreator(
|
|
276
|
+
createFixedFloatNormalizer(2)(parseFloat(value)),
|
|
277
|
+
currency
|
|
278
|
+
),
|
|
279
|
+
},
|
|
280
|
+
{
|
|
281
|
+
label: 'Pay Now (incl. 10% fee)',
|
|
282
|
+
id: 'pay_now',
|
|
283
|
+
normalizer: (value: string, currency: any) =>
|
|
284
|
+
currencyNormalizerCreator(
|
|
285
|
+
createFixedFloatNormalizer(2)(parseFloat(value)),
|
|
286
|
+
currency
|
|
287
|
+
),
|
|
288
|
+
},
|
|
289
|
+
{
|
|
290
|
+
label: 'Pay On Check-in',
|
|
291
|
+
id: 'debt',
|
|
292
|
+
normalizer: (value: string, currency: any) =>
|
|
293
|
+
currencyNormalizerCreator(
|
|
294
|
+
createFixedFloatNormalizer(2)(parseFloat(value)),
|
|
295
|
+
currency
|
|
296
|
+
),
|
|
297
|
+
},
|
|
298
|
+
]
|
|
299
299
|
: paymentFields
|
|
300
300
|
const isTable = orderData?.guest_count
|
|
301
301
|
return (
|
|
@@ -394,25 +394,25 @@ export const PaymentContainer = ({
|
|
|
394
394
|
{typeof value === 'string'
|
|
395
395
|
? normalizer(value, currency)
|
|
396
396
|
: _map(value, item => (
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
397
|
+
<div key={item.id} className="add-on-container">
|
|
398
|
+
<span>{item.quantity}</span>
|
|
399
|
+
<span className="add-on-x">{' x '}</span>
|
|
400
|
+
<span>
|
|
401
|
+
{item.groupName ? item.groupName + ' - ' : ''}
|
|
402
|
+
</span>
|
|
403
|
+
<span>{item.name}</span>
|
|
404
|
+
<span>{' - '}</span>
|
|
405
|
+
<span>
|
|
406
|
+
{currencyNormalizerCreator(
|
|
407
|
+
createFixedFloatNormalizer(2)(
|
|
408
|
+
parseFloat(item.price)
|
|
409
|
+
),
|
|
410
|
+
currency
|
|
411
|
+
)}
|
|
412
|
+
</span>
|
|
413
|
+
<span className="add-on-each">{' each'}</span>
|
|
414
|
+
</div>
|
|
415
|
+
))}
|
|
416
416
|
</div>
|
|
417
417
|
</div>
|
|
418
418
|
)
|
|
@@ -505,9 +505,8 @@ export const PaymentContainer = ({
|
|
|
505
505
|
</div>
|
|
506
506
|
) : (
|
|
507
507
|
<div
|
|
508
|
-
className={`payment_button ${
|
|
509
|
-
|
|
510
|
-
}`}
|
|
508
|
+
className={`payment_button ${paymentIsLoading ? 'disabled-payment-button' : ''
|
|
509
|
+
}`}
|
|
511
510
|
>
|
|
512
511
|
<button
|
|
513
512
|
disabled={paymentIsLoading}
|