ordering-ui-admin-external 1.28.0 → 1.29.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.
- package/_bundles/main.css +294 -26
- package/_bundles/{ordering-ui-admin.88341b2ec95c8949082e.js → ordering-ui-admin.452c5996b9b7ebdf8016.js} +2 -2
- package/_bundles/{ordering-ui-admin.88341b2ec95c8949082e.js.LICENSE.txt → ordering-ui-admin.452c5996b9b7ebdf8016.js.LICENSE.txt} +8 -0
- package/_modules/components/Delivery/AddressForm/styles.js +2 -2
- package/_modules/components/Delivery/AddressList/index.js +9 -56
- package/_modules/components/Delivery/AddressList/styles.js +1 -1
- package/_modules/components/Delivery/DriversGroupLogs/index.js +5 -2
- package/_modules/components/Delivery/UserAddForm/index.js +16 -4
- package/_modules/components/Delivery/UserFormDetails/index.js +17 -5
- package/_modules/components/Home/HomePage/index.js +5 -1
- package/_modules/components/MyProducts/OrderingWebsite/index.js +5 -1
- package/_modules/components/OrderingProducts/SiteTheme/index.js +1 -1
- package/_modules/components/Orders/CreateCustomOrder/CardForm/index.js +96 -0
- package/_modules/components/Orders/CreateCustomOrder/CardForm/styles.js +35 -0
- package/_modules/components/Orders/CreateCustomOrder/CardFormCustom/cardUtils.js +102 -0
- package/_modules/components/Orders/CreateCustomOrder/CardFormCustom/index.js +148 -0
- package/_modules/components/Orders/CreateCustomOrder/CardFormCustom/styles.js +16 -0
- package/_modules/components/Orders/CreateCustomOrder/CartBill/index.js +275 -0
- package/_modules/components/Orders/CreateCustomOrder/CartBill/styles.js +23 -0
- package/_modules/components/Orders/CreateCustomOrder/Checkout/index.js +498 -0
- package/_modules/components/Orders/CreateCustomOrder/Checkout/styles.js +31 -0
- package/_modules/components/Orders/CreateCustomOrder/CouponControl/index.js +100 -0
- package/_modules/components/Orders/CreateCustomOrder/CouponControl/styles.js +17 -0
- package/_modules/components/Orders/CreateCustomOrder/CustomOrderDetails/index.js +139 -0
- package/_modules/components/Orders/CreateCustomOrder/CustomOrderDetails/styles.js +17 -0
- package/_modules/components/Orders/CreateCustomOrder/DriverTips/index.js +101 -0
- package/_modules/components/Orders/CreateCustomOrder/DriverTips/styles.js +37 -0
- package/_modules/components/Orders/CreateCustomOrder/Map/index.js +131 -0
- package/_modules/components/Orders/CreateCustomOrder/Map/styles.js +12 -0
- package/_modules/components/Orders/CreateCustomOrder/PaymentOptionCard/index.js +83 -0
- package/_modules/components/Orders/CreateCustomOrder/PaymentOptionCash/index.js +81 -0
- package/_modules/components/Orders/CreateCustomOrder/PaymentOptionCash/styles.js +23 -0
- package/_modules/components/Orders/CreateCustomOrder/PaymentOptionPaypal/index.js +45 -0
- package/_modules/components/Orders/CreateCustomOrder/PaymentOptionPaypal/styles.js +12 -0
- package/_modules/components/Orders/CreateCustomOrder/PaymentOptionSquare/index.js +112 -0
- package/_modules/components/Orders/CreateCustomOrder/PaymentOptionSquare/styles.js +21 -0
- package/_modules/components/Orders/CreateCustomOrder/PaymentOptionStripe/index.js +259 -0
- package/_modules/components/Orders/CreateCustomOrder/PaymentOptionStripe/styles.js +66 -0
- package/_modules/components/Orders/CreateCustomOrder/PaymentOptionWallet/index.js +173 -0
- package/_modules/components/Orders/CreateCustomOrder/PaymentOptionWallet/styles.js +26 -0
- package/_modules/components/Orders/CreateCustomOrder/PaymentOptions/index.js +400 -0
- package/_modules/components/Orders/CreateCustomOrder/PaymentOptions/styles.js +40 -0
- package/_modules/components/Orders/CreateCustomOrder/ProductForm/index.js +613 -0
- package/_modules/components/Orders/CreateCustomOrder/ProductForm/styles.js +109 -0
- package/_modules/components/Orders/CreateCustomOrder/ProductIngredient/index.js +39 -0
- package/_modules/components/Orders/CreateCustomOrder/ProductIngredient/styles.js +23 -0
- package/_modules/components/Orders/CreateCustomOrder/ProductOption/index.js +51 -0
- package/_modules/components/Orders/CreateCustomOrder/ProductOption/styles.js +29 -0
- package/_modules/components/Orders/CreateCustomOrder/ProductOptionSubOption/index.js +148 -0
- package/_modules/components/Orders/CreateCustomOrder/ProductOptionSubOption/styles.js +79 -0
- package/_modules/components/Orders/CreateCustomOrder/SelectBusinesses/index.js +82 -0
- package/_modules/components/Orders/CreateCustomOrder/SelectBusinesses/styles.js +21 -0
- package/_modules/components/Orders/CreateCustomOrder/SelectCustomer/index.js +191 -0
- package/_modules/components/Orders/CreateCustomOrder/SelectCustomer/styles.js +68 -0
- package/_modules/components/Orders/CreateCustomOrder/SelectProducts/index.js +234 -0
- package/_modules/components/Orders/CreateCustomOrder/SelectProducts/styles.js +54 -0
- package/_modules/components/Orders/CreateCustomOrder/SingleProductCard/index.js +99 -0
- package/_modules/components/Orders/CreateCustomOrder/SingleProductCard/styles.js +131 -0
- package/_modules/components/Orders/CreateCustomOrder/StripeElementsForm/index.js +73 -0
- package/_modules/components/Orders/CreateCustomOrder/StripeElementsForm/styles.js +17 -0
- package/_modules/components/Orders/CreateCustomOrder/StripeMethodForm/index.js +124 -0
- package/_modules/components/Orders/CreateCustomOrder/StripeMethodForm/styles.js +12 -0
- package/_modules/components/Orders/CreateCustomOrder/StripeRedirectForm/index.js +83 -0
- package/_modules/components/Orders/CreateCustomOrder/StripeRedirectForm/styles.js +21 -0
- package/_modules/components/Orders/CreateCustomOrder/TaxInformation/index.js +48 -0
- package/_modules/components/Orders/CreateCustomOrder/TaxInformation/styles.js +14 -0
- package/_modules/components/Orders/CreateCustomOrder/index.js +59 -0
- package/_modules/components/Orders/OrderToPrintTicket/index.js +2 -2
- package/_modules/components/Orders/OrdersDashboardControls/index.js +6 -2
- package/_modules/components/Orders/OrdersDashboardControls/styles.js +3 -3
- package/_modules/components/Orders/OrdersExportCSV/styles.js +14 -8
- package/_modules/components/Orders/OrdersManager/index.js +6 -4
- package/_modules/components/Orders/OrdersManager/styles.js +1 -1
- package/_modules/components/Shared/AutoScroll/index.js +1 -0
- package/_modules/components/Shared/LinkableText/index.js +22 -0
- package/_modules/components/Shared/Tabs/index.js +32 -0
- package/_modules/components/Shared/index.js +20 -0
- package/_modules/components/SidebarMenu/index.js +2 -1
- package/_modules/components/Stores/BusinessProductsListing/index.js +7 -3
- package/_modules/components/Stores/BusinessQRCodeOption/index.js +6 -2
- package/_modules/components/Stores/BusinessSummary/index.js +7 -3
- package/_modules/components/Users/UserAddForm/index.js +13 -5
- package/_modules/components/Users/UserAddForm/styles.js +1 -1
- package/_modules/styles/Selects/index.js +1 -1
- package/_modules/utils/index.js +9 -2
- package/index-template.js +1 -1
- package/package.json +6 -4
- package/src/components/Delivery/AddressForm/styles.js +3 -3
- package/src/components/Delivery/AddressList/index.js +6 -61
- package/src/components/Delivery/AddressList/styles.js +1 -1
- package/src/components/Delivery/DriversGroupLogs/index.js +8 -2
- package/src/components/Delivery/UserAddForm/index.js +32 -13
- package/src/components/Delivery/UserFormDetails/index.js +30 -13
- package/src/components/Home/HomePage/index.js +3 -2
- package/src/components/MyProducts/OrderingWebsite/index.js +9 -8
- package/src/components/OrderingProducts/SiteTheme/index.js +1 -1
- package/src/components/Orders/CreateCustomOrder/CardForm/index.js +135 -0
- package/src/components/Orders/CreateCustomOrder/CardForm/styles.js +135 -0
- package/src/components/Orders/CreateCustomOrder/CardFormCustom/cardUtils.js +111 -0
- package/src/components/Orders/CreateCustomOrder/CardFormCustom/index.js +161 -0
- package/src/components/Orders/CreateCustomOrder/CardFormCustom/styles.js +20 -0
- package/src/components/Orders/CreateCustomOrder/CartBill/index.js +267 -0
- package/src/components/Orders/CreateCustomOrder/CartBill/styles.js +67 -0
- package/src/components/Orders/CreateCustomOrder/Checkout/index.js +519 -0
- package/src/components/Orders/CreateCustomOrder/Checkout/styles.js +85 -0
- package/src/components/Orders/CreateCustomOrder/CouponControl/index.js +90 -0
- package/src/components/Orders/CreateCustomOrder/CouponControl/styles.js +22 -0
- package/src/components/Orders/CreateCustomOrder/CustomOrderDetails/index.js +132 -0
- package/src/components/Orders/CreateCustomOrder/CustomOrderDetails/styles.js +28 -0
- package/src/components/Orders/CreateCustomOrder/DriverTips/index.js +113 -0
- package/src/components/Orders/CreateCustomOrder/DriverTips/styles.js +91 -0
- package/src/components/Orders/CreateCustomOrder/Map/index.js +115 -0
- package/src/components/Orders/CreateCustomOrder/Map/styles.js +10 -0
- package/src/components/Orders/CreateCustomOrder/PaymentOptionCard/index.js +70 -0
- package/src/components/Orders/CreateCustomOrder/PaymentOptionCash/index.js +83 -0
- package/src/components/Orders/CreateCustomOrder/PaymentOptionCash/styles.js +50 -0
- package/src/components/Orders/CreateCustomOrder/PaymentOptionPaypal/index.js +43 -0
- package/src/components/Orders/CreateCustomOrder/PaymentOptionPaypal/styles.js +5 -0
- package/src/components/Orders/CreateCustomOrder/PaymentOptionSquare/index.js +105 -0
- package/src/components/Orders/CreateCustomOrder/PaymentOptionSquare/styles.js +27 -0
- package/src/components/Orders/CreateCustomOrder/PaymentOptionStripe/index.js +261 -0
- package/src/components/Orders/CreateCustomOrder/PaymentOptionStripe/styles.js +159 -0
- package/src/components/Orders/CreateCustomOrder/PaymentOptionWallet/index.js +172 -0
- package/src/components/Orders/CreateCustomOrder/PaymentOptionWallet/styles.js +33 -0
- package/src/components/Orders/CreateCustomOrder/PaymentOptions/index.js +440 -0
- package/src/components/Orders/CreateCustomOrder/PaymentOptions/styles.js +132 -0
- package/src/components/Orders/CreateCustomOrder/ProductForm/index.js +701 -0
- package/src/components/Orders/CreateCustomOrder/ProductForm/styles.js +540 -0
- package/src/components/Orders/CreateCustomOrder/ProductIngredient/index.js +43 -0
- package/src/components/Orders/CreateCustomOrder/ProductIngredient/styles.js +29 -0
- package/src/components/Orders/CreateCustomOrder/ProductOption/index.js +58 -0
- package/src/components/Orders/CreateCustomOrder/ProductOption/styles.js +76 -0
- package/src/components/Orders/CreateCustomOrder/ProductOptionSubOption/index.js +182 -0
- package/src/components/Orders/CreateCustomOrder/ProductOptionSubOption/styles.js +195 -0
- package/src/components/Orders/CreateCustomOrder/SelectBusinesses/index.js +67 -0
- package/src/components/Orders/CreateCustomOrder/SelectBusinesses/styles.js +63 -0
- package/src/components/Orders/CreateCustomOrder/SelectCustomer/index.js +241 -0
- package/src/components/Orders/CreateCustomOrder/SelectCustomer/styles.js +235 -0
- package/src/components/Orders/CreateCustomOrder/SelectProducts/index.js +237 -0
- package/src/components/Orders/CreateCustomOrder/SelectProducts/styles.js +161 -0
- package/src/components/Orders/CreateCustomOrder/SingleProductCard/index.js +105 -0
- package/src/components/Orders/CreateCustomOrder/SingleProductCard/styles.js +314 -0
- package/src/components/Orders/CreateCustomOrder/StripeElementsForm/index.js +71 -0
- package/src/components/Orders/CreateCustomOrder/StripeElementsForm/styles.js +13 -0
- package/src/components/Orders/CreateCustomOrder/StripeMethodForm/index.js +90 -0
- package/src/components/Orders/CreateCustomOrder/StripeMethodForm/styles.js +9 -0
- package/src/components/Orders/CreateCustomOrder/StripeRedirectForm/index.js +96 -0
- package/src/components/Orders/CreateCustomOrder/StripeRedirectForm/styles.js +73 -0
- package/src/components/Orders/CreateCustomOrder/TaxInformation/index.js +69 -0
- package/src/components/Orders/CreateCustomOrder/TaxInformation/styles.js +25 -0
- package/src/components/Orders/CreateCustomOrder/index.js +45 -0
- package/src/components/Orders/OrderToPrintTicket/index.js +1 -1
- package/src/components/Orders/OrdersDashboardControls/index.js +4 -1
- package/src/components/Orders/OrdersDashboardControls/styles.js +13 -11
- package/src/components/Orders/OrdersExportCSV/styles.js +16 -0
- package/src/components/Orders/OrdersManager/index.js +5 -1
- package/src/components/Orders/OrdersManager/styles.js +2 -0
- package/src/components/Shared/AutoScroll/index.js +1 -0
- package/src/components/Shared/LinkableText/index.js +17 -0
- package/src/components/Shared/Tabs/index.js +28 -0
- package/src/components/Shared/index.js +5 -0
- package/src/components/SidebarMenu/index.js +1 -1
- package/src/components/Stores/BusinessProductsListing/index.js +6 -3
- package/src/components/Stores/BusinessQRCodeOption/index.js +5 -3
- package/src/components/Stores/BusinessSummary/index.js +6 -4
- package/src/components/Users/UserAddForm/index.js +12 -3
- package/src/components/Users/UserAddForm/styles.js +2 -2
- package/src/styles/Selects/index.js +1 -1
- package/src/utils/index.js +5 -0
|
@@ -0,0 +1,498 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.Checkout = void 0;
|
|
8
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
9
|
+
var _orderingComponentsAdminExternal = require("ordering-components-admin-external");
|
|
10
|
+
var _libphonenumberJs = _interopRequireDefault(require("libphonenumber-js"));
|
|
11
|
+
var _VscWarning = _interopRequireDefault(require("@meronex/icons/vsc/VscWarning"));
|
|
12
|
+
var _PaymentOptions = require("../PaymentOptions");
|
|
13
|
+
var _PaymentOptionWallet = require("../PaymentOptionWallet");
|
|
14
|
+
var _DriverTips = require("../DriverTips");
|
|
15
|
+
var _CartBill = require("../CartBill");
|
|
16
|
+
var _Shared = require("../../../Shared");
|
|
17
|
+
var _styles = require("../../../../styles");
|
|
18
|
+
var _styles2 = require("./styles");
|
|
19
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
20
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
21
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
22
|
+
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, defineProperty = Object.defineProperty || function (obj, key, desc) { obj[key] = desc.value; }, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return defineProperty(generator, "_invoke", { value: makeInvokeMethod(innerFn, self, context) }), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; defineProperty(this, "_invoke", { value: function value(method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; } function maybeInvokeDelegate(delegate, context) { var methodName = context.method, method = delegate.iterator[methodName]; if (undefined === method) return context.delegate = null, "throw" === methodName && delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method) || "return" !== methodName && (context.method = "throw", context.arg = new TypeError("The iterator does not provide a '" + methodName + "' method")), ContinueSentinel; var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, defineProperty(Gp, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), defineProperty(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (val) { var object = Object(val), keys = []; for (var key in object) keys.push(key); return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, catch: function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }
|
|
23
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
24
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
25
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
26
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
27
|
+
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
28
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
29
|
+
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
30
|
+
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
31
|
+
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
32
|
+
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
33
|
+
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
34
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
35
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
36
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
37
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
38
|
+
function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
|
|
39
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
40
|
+
var CheckoutUI = function CheckoutUI(props) {
|
|
41
|
+
var _businessDetails$busi, _businessDetails$busi2, _configs$table_numer_, _businessConfigs$find, _businessConfigs$find2, _configs$cash_wallet, _configs$wallet_enabl, _validationFields$fie, _validationFields$fie2, _validationFields$fie3, _validationFields$fie4, _validationFields$fie5, _validationFields$fie6, _cart$comment, _validationFields$fie7, _validationFields$fie8, _validationFields$fie9, _validationFields$fie10, _validationFields$fie11, _validationFields$fie12, _paymethodSelected$da, _paymethodSelected$da2, _paymethodSelected$da3, _cardList$cards, _cartState$cart, _validationFields$fie13, _validationFields$fie14, _validationFields$fie15, _validationFields$fie16, _validationFields$fie17, _validationFields$fie18, _configs$driver_tip_o, _configs$driver_tip_o2, _configs$driver_tip_o3, _validationFields$fie19, _validationFields$fie20, _validationFields$fie21, _businessDetails$busi3, _businessDetails$busi4, _businessDetails$busi5, _configs$driver_tip_t, _configs$driver_tip_u, _configs$driver_tip_t2, _validationFields$fie30, _validationFields$fie31, _validationFields$fie32, _validationFields$fie33, _validationFields$fie34, _validationFields$fie35;
|
|
42
|
+
var cart = props.cart,
|
|
43
|
+
errors = props.errors,
|
|
44
|
+
placing = props.placing,
|
|
45
|
+
cartState = props.cartState,
|
|
46
|
+
loyaltyPlansState = props.loyaltyPlansState,
|
|
47
|
+
businessDetails = props.businessDetails,
|
|
48
|
+
paymethodSelected = props.paymethodSelected,
|
|
49
|
+
handlePaymethodChange = props.handlePaymethodChange,
|
|
50
|
+
handlerClickPlaceOrder = props.handlerClickPlaceOrder,
|
|
51
|
+
handleOrderRedirect = props.handleOrderRedirect,
|
|
52
|
+
isCustomerMode = props.isCustomerMode,
|
|
53
|
+
isResetPaymethod = props.isResetPaymethod,
|
|
54
|
+
setIsResetPaymethod = props.setIsResetPaymethod,
|
|
55
|
+
onPlaceOrderClick = props.onPlaceOrderClick,
|
|
56
|
+
placeSpotNumber = props.placeSpotNumber;
|
|
57
|
+
var _useValidationFields = (0, _orderingComponentsAdminExternal.useValidationFields)(),
|
|
58
|
+
_useValidationFields2 = _slicedToArray(_useValidationFields, 1),
|
|
59
|
+
validationFields = _useValidationFields2[0];
|
|
60
|
+
var _useOrder = (0, _orderingComponentsAdminExternal.useOrder)(),
|
|
61
|
+
_useOrder2 = _slicedToArray(_useOrder, 1),
|
|
62
|
+
_useOrder2$ = _useOrder2[0],
|
|
63
|
+
options = _useOrder2$.options,
|
|
64
|
+
loading = _useOrder2$.loading;
|
|
65
|
+
var _useLanguage = (0, _orderingComponentsAdminExternal.useLanguage)(),
|
|
66
|
+
_useLanguage2 = _slicedToArray(_useLanguage, 2),
|
|
67
|
+
t = _useLanguage2[1];
|
|
68
|
+
var _useUtils = (0, _orderingComponentsAdminExternal.useUtils)(),
|
|
69
|
+
_useUtils2 = _slicedToArray(_useUtils, 1),
|
|
70
|
+
parsePrice = _useUtils2[0].parsePrice;
|
|
71
|
+
var _useSession = (0, _orderingComponentsAdminExternal.useSession)(),
|
|
72
|
+
_useSession2 = _slicedToArray(_useSession, 1),
|
|
73
|
+
user = _useSession2[0].user;
|
|
74
|
+
var _useConfig = (0, _orderingComponentsAdminExternal.useConfig)(),
|
|
75
|
+
_useConfig2 = _slicedToArray(_useConfig, 1),
|
|
76
|
+
configs = _useConfig2[0].configs;
|
|
77
|
+
var _useCustomer = (0, _orderingComponentsAdminExternal.useCustomer)(),
|
|
78
|
+
_useCustomer2 = _slicedToArray(_useCustomer, 1),
|
|
79
|
+
customerState = _useCustomer2[0];
|
|
80
|
+
var _useState = (0, _react.useState)(false),
|
|
81
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
82
|
+
errorCash = _useState2[0],
|
|
83
|
+
setErrorCash = _useState2[1];
|
|
84
|
+
var _useState3 = (0, _react.useState)([]),
|
|
85
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
86
|
+
userErrors = _useState4[0],
|
|
87
|
+
setUserErrors = _useState4[1];
|
|
88
|
+
var _useState5 = (0, _react.useState)({
|
|
89
|
+
open: false,
|
|
90
|
+
content: []
|
|
91
|
+
}),
|
|
92
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
93
|
+
alertState = _useState6[0],
|
|
94
|
+
setAlertState = _useState6[1];
|
|
95
|
+
var _useState7 = (0, _react.useState)([]),
|
|
96
|
+
_useState8 = _slicedToArray(_useState7, 2),
|
|
97
|
+
requiredFields = _useState8[0],
|
|
98
|
+
setRequiredFields = _useState8[1];
|
|
99
|
+
var _useState9 = (0, _react.useState)([]),
|
|
100
|
+
_useState10 = _slicedToArray(_useState9, 2),
|
|
101
|
+
cardList = _useState10[0],
|
|
102
|
+
setCardList = _useState10[1];
|
|
103
|
+
var _useState11 = (0, _react.useState)(null),
|
|
104
|
+
_useState12 = _slicedToArray(_useState11, 2),
|
|
105
|
+
paymethodClicked = _useState12[0],
|
|
106
|
+
setPaymethodClicked = _useState12[1];
|
|
107
|
+
var cardsMethods = ['stripe', 'credomatic'];
|
|
108
|
+
var businessConfigs = (_businessDetails$busi = businessDetails === null || businessDetails === void 0 ? void 0 : (_businessDetails$busi2 = businessDetails.business) === null || _businessDetails$busi2 === void 0 ? void 0 : _businessDetails$busi2.configs) !== null && _businessDetails$busi !== void 0 ? _businessDetails$busi : [];
|
|
109
|
+
var isTableNumberEnabled = configs === null || configs === void 0 ? void 0 : (_configs$table_numer_ = configs.table_numer_enabled) === null || _configs$table_numer_ === void 0 ? void 0 : _configs$table_numer_.value;
|
|
110
|
+
var isWalletCashEnabled = ((_businessConfigs$find = businessConfigs.find(function (config) {
|
|
111
|
+
return config.key === 'wallet_cash_enabled';
|
|
112
|
+
})) === null || _businessConfigs$find === void 0 ? void 0 : _businessConfigs$find.value) === '1';
|
|
113
|
+
var isWalletCreditPointsEnabled = ((_businessConfigs$find2 = businessConfigs.find(function (config) {
|
|
114
|
+
return config.key === 'wallet_credit_point_enabled';
|
|
115
|
+
})) === null || _businessConfigs$find2 === void 0 ? void 0 : _businessConfigs$find2.value) === '1';
|
|
116
|
+
var isWalletEnabled = (configs === null || configs === void 0 ? void 0 : (_configs$cash_wallet = configs.cash_wallet) === null || _configs$cash_wallet === void 0 ? void 0 : _configs$cash_wallet.value) && (configs === null || configs === void 0 ? void 0 : (_configs$wallet_enabl = configs.wallet_enabled) === null || _configs$wallet_enabl === void 0 ? void 0 : _configs$wallet_enabl.value) === '1' && (isWalletCashEnabled || isWalletCreditPointsEnabled) && !isCustomerMode;
|
|
117
|
+
var isGiftCardCart = !(cart !== null && cart !== void 0 && cart.business_id);
|
|
118
|
+
var validateCommentsCartField = (validationFields === null || validationFields === void 0 ? void 0 : (_validationFields$fie = validationFields.fields) === null || _validationFields$fie === void 0 ? void 0 : (_validationFields$fie2 = _validationFields$fie.checkout) === null || _validationFields$fie2 === void 0 ? void 0 : (_validationFields$fie3 = _validationFields$fie2.comments) === null || _validationFields$fie3 === void 0 ? void 0 : _validationFields$fie3.enabled) && (validationFields === null || validationFields === void 0 ? void 0 : (_validationFields$fie4 = validationFields.fields) === null || _validationFields$fie4 === void 0 ? void 0 : (_validationFields$fie5 = _validationFields$fie4.checkout) === null || _validationFields$fie5 === void 0 ? void 0 : (_validationFields$fie6 = _validationFields$fie5.comments) === null || _validationFields$fie6 === void 0 ? void 0 : _validationFields$fie6.required) && ((cart === null || cart === void 0 ? void 0 : cart.comment) === null || (cart === null || cart === void 0 ? void 0 : (_cart$comment = cart.comment) === null || _cart$comment === void 0 ? void 0 : _cart$comment.trim().length) === 0);
|
|
119
|
+
var validateZipcodeCard = (validationFields === null || validationFields === void 0 ? void 0 : (_validationFields$fie7 = validationFields.fields) === null || _validationFields$fie7 === void 0 ? void 0 : (_validationFields$fie8 = _validationFields$fie7.card) === null || _validationFields$fie8 === void 0 ? void 0 : (_validationFields$fie9 = _validationFields$fie8.zipcode) === null || _validationFields$fie9 === void 0 ? void 0 : _validationFields$fie9.enabled) && (validationFields === null || validationFields === void 0 ? void 0 : (_validationFields$fie10 = validationFields.fields) === null || _validationFields$fie10 === void 0 ? void 0 : (_validationFields$fie11 = _validationFields$fie10.card) === null || _validationFields$fie11 === void 0 ? void 0 : (_validationFields$fie12 = _validationFields$fie11.zipcode) === null || _validationFields$fie12 === void 0 ? void 0 : _validationFields$fie12.required) && (paymethodSelected === null || paymethodSelected === void 0 ? void 0 : paymethodSelected.gateway) === 'stripe' && (paymethodSelected === null || paymethodSelected === void 0 ? void 0 : (_paymethodSelected$da = paymethodSelected.data) === null || _paymethodSelected$da === void 0 ? void 0 : _paymethodSelected$da.card) && !(paymethodSelected !== null && paymethodSelected !== void 0 && (_paymethodSelected$da2 = paymethodSelected.data) !== null && _paymethodSelected$da2 !== void 0 && (_paymethodSelected$da3 = _paymethodSelected$da2.card) !== null && _paymethodSelected$da3 !== void 0 && _paymethodSelected$da3.zipcode);
|
|
120
|
+
var isDisablePlaceOrderButton = !(cart !== null && cart !== void 0 && cart.valid) || !paymethodSelected && (cart === null || cart === void 0 ? void 0 : cart.balance) > 0 || cardsMethods.includes(paymethodSelected === null || paymethodSelected === void 0 ? void 0 : paymethodSelected.gateway) && (cardList === null || cardList === void 0 ? void 0 : (_cardList$cards = cardList.cards) === null || _cardList$cards === void 0 ? void 0 : _cardList$cards.length) === 0 || placing || errorCash || loading || isTableNumberEnabled === '1' && (options === null || options === void 0 ? void 0 : options.type) === 3 && !(cartState !== null && cartState !== void 0 && (_cartState$cart = cartState.cart) !== null && _cartState$cart !== void 0 && _cartState$cart.spot_number || cart !== null && cart !== void 0 && cart.spot_number || placeSpotNumber) || !(cart !== null && cart !== void 0 && cart.valid_maximum) || !(cart !== null && cart !== void 0 && cart.valid_minimum) && !((cart === null || cart === void 0 ? void 0 : cart.discount_type) === 1 && (cart === null || cart === void 0 ? void 0 : cart.discount_rate) === 100) || options.type === 1 && (validationFields === null || validationFields === void 0 ? void 0 : (_validationFields$fie13 = validationFields.fields) === null || _validationFields$fie13 === void 0 ? void 0 : (_validationFields$fie14 = _validationFields$fie13.checkout) === null || _validationFields$fie14 === void 0 ? void 0 : (_validationFields$fie15 = _validationFields$fie14.driver_tip) === null || _validationFields$fie15 === void 0 ? void 0 : _validationFields$fie15.enabled) && (validationFields === null || validationFields === void 0 ? void 0 : (_validationFields$fie16 = validationFields.fields) === null || _validationFields$fie16 === void 0 ? void 0 : (_validationFields$fie17 = _validationFields$fie16.checkout) === null || _validationFields$fie17 === void 0 ? void 0 : (_validationFields$fie18 = _validationFields$fie17.driver_tip) === null || _validationFields$fie18 === void 0 ? void 0 : _validationFields$fie18.required) && Number(cart === null || cart === void 0 ? void 0 : cart.driver_tip) <= 0 || validateCommentsCartField || validateZipcodeCard;
|
|
121
|
+
var driverTipsOptions = typeof (configs === null || configs === void 0 ? void 0 : (_configs$driver_tip_o = configs.driver_tip_options) === null || _configs$driver_tip_o === void 0 ? void 0 : _configs$driver_tip_o.value) === 'string' ? JSON.parse(configs === null || configs === void 0 ? void 0 : (_configs$driver_tip_o2 = configs.driver_tip_options) === null || _configs$driver_tip_o2 === void 0 ? void 0 : _configs$driver_tip_o2.value) || [] : (configs === null || configs === void 0 ? void 0 : (_configs$driver_tip_o3 = configs.driver_tip_options) === null || _configs$driver_tip_o3 === void 0 ? void 0 : _configs$driver_tip_o3.value) || [];
|
|
122
|
+
var driverTipsField = !cartState.loading && cart && (cart === null || cart === void 0 ? void 0 : cart.business_id) && options.type === 1 && (cart === null || cart === void 0 ? void 0 : cart.status) !== 2 && (validationFields === null || validationFields === void 0 ? void 0 : (_validationFields$fie19 = validationFields.fields) === null || _validationFields$fie19 === void 0 ? void 0 : (_validationFields$fie20 = _validationFields$fie19.checkout) === null || _validationFields$fie20 === void 0 ? void 0 : (_validationFields$fie21 = _validationFields$fie20.driver_tip) === null || _validationFields$fie21 === void 0 ? void 0 : _validationFields$fie21.enabled) && driverTipsOptions.length > 0;
|
|
123
|
+
var handlePlaceOrder = function handlePlaceOrder() {
|
|
124
|
+
if (!userErrors.length && (!(requiredFields !== null && requiredFields !== void 0 && requiredFields.length) || (paymethodSelected === null || paymethodSelected === void 0 ? void 0 : paymethodSelected.gateway) === 'cash' || (paymethodSelected === null || paymethodSelected === void 0 ? void 0 : paymethodSelected.gateway) === 'card_delivery')) {
|
|
125
|
+
var body = {};
|
|
126
|
+
handlerClickPlaceOrder && handlerClickPlaceOrder(null, body);
|
|
127
|
+
return;
|
|
128
|
+
}
|
|
129
|
+
setAlertState({
|
|
130
|
+
open: true,
|
|
131
|
+
content: Object.values(userErrors).map(function (error) {
|
|
132
|
+
return error;
|
|
133
|
+
})
|
|
134
|
+
});
|
|
135
|
+
};
|
|
136
|
+
var checkValidationFields = function checkValidationFields() {
|
|
137
|
+
var _validationFields$fie22, _validationFields$fie23, _validationFields$fie24, _validationFields$fie25, _validationFields$fie26, _validationFields$fie27, _validationFields$fie28, _configs$verification;
|
|
138
|
+
setUserErrors([]);
|
|
139
|
+
var errors = [];
|
|
140
|
+
var notFields = ['coupon', 'driver_tip', 'mobile_phone', 'address', 'zipcode', 'address_notes', 'comments'];
|
|
141
|
+
var userSelected = isCustomerMode ? customerState.user : user;
|
|
142
|
+
var _requiredFields = [];
|
|
143
|
+
Object.values(validationFields === null || validationFields === void 0 ? void 0 : (_validationFields$fie22 = validationFields.fields) === null || _validationFields$fie22 === void 0 ? void 0 : _validationFields$fie22.checkout).map(function (field) {
|
|
144
|
+
if (field !== null && field !== void 0 && field.enabled && field !== null && field !== void 0 && field.required && !notFields.includes(field.code)) {
|
|
145
|
+
if (userSelected && !userSelected[field === null || field === void 0 ? void 0 : field.code]) {
|
|
146
|
+
_requiredFields.push(field === null || field === void 0 ? void 0 : field.code);
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
});
|
|
150
|
+
if (userSelected && !(userSelected !== null && userSelected !== void 0 && userSelected.cellphone) && (validationFields !== null && validationFields !== void 0 && (_validationFields$fie23 = validationFields.fields) !== null && _validationFields$fie23 !== void 0 && (_validationFields$fie24 = _validationFields$fie23.checkout) !== null && _validationFields$fie24 !== void 0 && (_validationFields$fie25 = _validationFields$fie24.cellphone) !== null && _validationFields$fie25 !== void 0 && _validationFields$fie25.enabled && validationFields !== null && validationFields !== void 0 && (_validationFields$fie26 = validationFields.fields) !== null && _validationFields$fie26 !== void 0 && (_validationFields$fie27 = _validationFields$fie26.checkout) !== null && _validationFields$fie27 !== void 0 && (_validationFields$fie28 = _validationFields$fie27.cellphone) !== null && _validationFields$fie28 !== void 0 && _validationFields$fie28.required || (configs === null || configs === void 0 ? void 0 : (_configs$verification = configs.verification_phone_required) === null || _configs$verification === void 0 ? void 0 : _configs$verification.value) === '1')) {
|
|
151
|
+
_requiredFields.push('cellphone');
|
|
152
|
+
}
|
|
153
|
+
setRequiredFields(_requiredFields);
|
|
154
|
+
if (userSelected && userSelected !== null && userSelected !== void 0 && userSelected.cellphone) {
|
|
155
|
+
if (userSelected !== null && userSelected !== void 0 && userSelected.country_phone_code) {
|
|
156
|
+
var phone = null;
|
|
157
|
+
phone = "+".concat(userSelected === null || userSelected === void 0 ? void 0 : userSelected.country_phone_code).concat(userSelected === null || userSelected === void 0 ? void 0 : userSelected.cellphone.replace("+".concat(userSelected === null || userSelected === void 0 ? void 0 : userSelected.country_phone_code), ''));
|
|
158
|
+
var phoneNumber = (0, _libphonenumberJs.default)(phone);
|
|
159
|
+
if (!(phoneNumber !== null && phoneNumber !== void 0 && phoneNumber.isValid())) {
|
|
160
|
+
errors.push(t('VALIDATION_ERROR_MOBILE_PHONE_INVALID', 'The field Phone number is invalid.'));
|
|
161
|
+
}
|
|
162
|
+
} else {
|
|
163
|
+
errors.push(t('INVALID_ERROR_COUNTRY_CODE_PHONE_NUMBER', 'The country code of the phone number is invalid'));
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
setUserErrors(errors);
|
|
167
|
+
};
|
|
168
|
+
(0, _react.useEffect)(function () {
|
|
169
|
+
var _validationFields$fie29;
|
|
170
|
+
if (validationFields && validationFields !== null && validationFields !== void 0 && (_validationFields$fie29 = validationFields.fields) !== null && _validationFields$fie29 !== void 0 && _validationFields$fie29.checkout) {
|
|
171
|
+
checkValidationFields();
|
|
172
|
+
}
|
|
173
|
+
}, [validationFields, user, customerState]);
|
|
174
|
+
(0, _react.useEffect)(function () {
|
|
175
|
+
if (errors) {
|
|
176
|
+
setAlertState({
|
|
177
|
+
open: true,
|
|
178
|
+
content: errors
|
|
179
|
+
});
|
|
180
|
+
}
|
|
181
|
+
}, [errors]);
|
|
182
|
+
(0, _react.useEffect)(function () {
|
|
183
|
+
if (isResetPaymethod) {
|
|
184
|
+
handlePaymethodChange(null);
|
|
185
|
+
setIsResetPaymethod(true);
|
|
186
|
+
}
|
|
187
|
+
}, [isResetPaymethod]);
|
|
188
|
+
return /*#__PURE__*/_react.default.createElement(_styles2.Conatiner, null, !cartState.loading && (cart === null || cart === void 0 ? void 0 : cart.status) === 2 && /*#__PURE__*/_react.default.createElement(_styles2.WarningMessage, null, /*#__PURE__*/_react.default.createElement(_VscWarning.default, null), /*#__PURE__*/_react.default.createElement("h1", null, t('CART_STATUS_PENDING_MESSAGE', 'Your order is being processed, please wait a little more. if you\'ve been waiting too long, please reload the page'))), !cartState.loading && cart && /*#__PURE__*/_react.default.createElement(_styles2.PaymentMethodContainer, {
|
|
189
|
+
className: "paymentsContainer"
|
|
190
|
+
}, /*#__PURE__*/_react.default.createElement(_styles2.SectionTitleContainer, null, /*#__PURE__*/_react.default.createElement("h3", null, t('PAYMENT_METHODS', 'Payment Methods')), /*#__PURE__*/_react.default.createElement(_styles2.Flag, null, t('REQUIRED', 'Required'))), !cartState.loading && (cart === null || cart === void 0 ? void 0 : cart.status) === 4 && /*#__PURE__*/_react.default.createElement(_styles2.WarningMessage, {
|
|
191
|
+
style: {
|
|
192
|
+
marginTop: 20
|
|
193
|
+
}
|
|
194
|
+
}, /*#__PURE__*/_react.default.createElement(_VscWarning.default, null), /*#__PURE__*/_react.default.createElement("h1", null, t('CART_STATUS_CANCEL_MESSAGE', 'The payment has not been successful, please try again'))), /*#__PURE__*/_react.default.createElement(_PaymentOptions.PaymentOptions, {
|
|
195
|
+
cart: cart,
|
|
196
|
+
isDisabled: (cart === null || cart === void 0 ? void 0 : cart.status) === 2,
|
|
197
|
+
businessId: !isGiftCardCart ? businessDetails === null || businessDetails === void 0 ? void 0 : (_businessDetails$busi3 = businessDetails.business) === null || _businessDetails$busi3 === void 0 ? void 0 : _businessDetails$busi3.id : -1,
|
|
198
|
+
isLoading: !isGiftCardCart ? businessDetails.loading : false,
|
|
199
|
+
paymethods: businessDetails === null || businessDetails === void 0 ? void 0 : (_businessDetails$busi4 = businessDetails.business) === null || _businessDetails$busi4 === void 0 ? void 0 : _businessDetails$busi4.paymethods,
|
|
200
|
+
onPaymentChange: handlePaymethodChange,
|
|
201
|
+
errorCash: errorCash,
|
|
202
|
+
setErrorCash: setErrorCash,
|
|
203
|
+
handleOrderRedirect: handleOrderRedirect,
|
|
204
|
+
isCustomerMode: isCustomerMode,
|
|
205
|
+
paySelected: paymethodSelected,
|
|
206
|
+
handlePlaceOrder: handlePlaceOrder,
|
|
207
|
+
onPlaceOrderClick: onPlaceOrderClick,
|
|
208
|
+
setCardList: setCardList,
|
|
209
|
+
requiredFields: requiredFields,
|
|
210
|
+
paymethodClicked: paymethodClicked,
|
|
211
|
+
setPaymethodClicked: setPaymethodClicked
|
|
212
|
+
})), isWalletEnabled && !(businessDetails !== null && businessDetails !== void 0 && businessDetails.loading) && /*#__PURE__*/_react.default.createElement(_PaymentOptionWallet.PaymentOptionWallet, {
|
|
213
|
+
cart: cart,
|
|
214
|
+
loyaltyPlansState: loyaltyPlansState,
|
|
215
|
+
businessConfigs: businessDetails === null || businessDetails === void 0 ? void 0 : (_businessDetails$busi5 = businessDetails.business) === null || _businessDetails$busi5 === void 0 ? void 0 : _businessDetails$busi5.configs
|
|
216
|
+
}), driverTipsField && /*#__PURE__*/_react.default.createElement(_DriverTips.DriverTips, {
|
|
217
|
+
businessId: cart === null || cart === void 0 ? void 0 : cart.business_id,
|
|
218
|
+
driverTipsOptions: driverTipsOptions,
|
|
219
|
+
isFixedPrice: parseInt(configs === null || configs === void 0 ? void 0 : (_configs$driver_tip_t = configs.driver_tip_type) === null || _configs$driver_tip_t === void 0 ? void 0 : _configs$driver_tip_t.value, 10) === 1,
|
|
220
|
+
isDriverTipUseCustom: !!parseInt(configs === null || configs === void 0 ? void 0 : (_configs$driver_tip_u = configs.driver_tip_use_custom) === null || _configs$driver_tip_u === void 0 ? void 0 : _configs$driver_tip_u.value, 10),
|
|
221
|
+
driverTip: parseInt(configs === null || configs === void 0 ? void 0 : (_configs$driver_tip_t2 = configs.driver_tip_type) === null || _configs$driver_tip_t2 === void 0 ? void 0 : _configs$driver_tip_t2.value, 10) === 1 ? cart === null || cart === void 0 ? void 0 : cart.driver_tip : cart === null || cart === void 0 ? void 0 : cart.driver_tip_rate,
|
|
222
|
+
cart: cart,
|
|
223
|
+
useOrderContext: true
|
|
224
|
+
}), !cartState.loading && cart && /*#__PURE__*/_react.default.createElement(_CartBill.CartBill, {
|
|
225
|
+
cart: cart
|
|
226
|
+
}), !cartState.loading && cart && (cart === null || cart === void 0 ? void 0 : cart.status) !== 2 && /*#__PURE__*/_react.default.createElement(_styles2.WrapperPlaceOrderButton, null, /*#__PURE__*/_react.default.createElement(_styles.Button, {
|
|
227
|
+
color: !(cart !== null && cart !== void 0 && cart.valid_maximum) || !(cart !== null && cart !== void 0 && cart.valid_minimum) && !((cart === null || cart === void 0 ? void 0 : cart.discount_type) === 1 && (cart === null || cart === void 0 ? void 0 : cart.discount_rate) === 100) ? 'secundary' : 'primary',
|
|
228
|
+
disabled: isDisablePlaceOrderButton,
|
|
229
|
+
onClick: function onClick() {
|
|
230
|
+
return handlePlaceOrder();
|
|
231
|
+
}
|
|
232
|
+
}, !(cart !== null && cart !== void 0 && cart.valid_maximum) ? "".concat(t('MAXIMUM_SUBTOTAL_ORDER', 'Maximum subtotal order'), ": ").concat(parsePrice(cart === null || cart === void 0 ? void 0 : cart.maximum)) : !(cart !== null && cart !== void 0 && cart.valid_minimum) && !((cart === null || cart === void 0 ? void 0 : cart.discount_type) === 1 && (cart === null || cart === void 0 ? void 0 : cart.discount_rate) === 100) ? "".concat(t('MINIMUN_SUBTOTAL_ORDER', 'Minimum subtotal order:'), " ").concat(parsePrice(cart === null || cart === void 0 ? void 0 : cart.minimum)) : placing ? t('PLACING', 'Placing') : t('PLACE_ORDER', 'Place Order'))), !(cart !== null && cart !== void 0 && cart.valid_address) && (cart === null || cart === void 0 ? void 0 : cart.status) !== 2 && /*#__PURE__*/_react.default.createElement(_styles2.WarningText, null, t('INVALID_CART_ADDRESS', 'Selected address is invalid, please select a closer address.')), !paymethodSelected && (cart === null || cart === void 0 ? void 0 : cart.balance) > 0 && (cart === null || cart === void 0 ? void 0 : cart.status) !== 2 && /*#__PURE__*/_react.default.createElement(_styles2.WarningText, null, t('WARNING_NOT_PAYMENT_SELECTED', 'Please, select a payment method to place order.')), !(cart !== null && cart !== void 0 && cart.valid_products) && (cart === null || cart === void 0 ? void 0 : cart.status) !== 2 && /*#__PURE__*/_react.default.createElement(_styles2.WarningText, null, t('WARNING_INVALID_PRODUCTS', 'Some products are invalid, please check them.')), isTableNumberEnabled === '1' && (options === null || options === void 0 ? void 0 : options.type) === 3 && !(cart !== null && cart !== void 0 && cart.spot_number || placeSpotNumber) && /*#__PURE__*/_react.default.createElement(_styles2.WarningText, null, t('WARNING_PLACE_SPOT', 'Please, select your spot to place order.')), options.type === 1 && (validationFields === null || validationFields === void 0 ? void 0 : (_validationFields$fie30 = validationFields.fields) === null || _validationFields$fie30 === void 0 ? void 0 : (_validationFields$fie31 = _validationFields$fie30.checkout) === null || _validationFields$fie31 === void 0 ? void 0 : (_validationFields$fie32 = _validationFields$fie31.driver_tip) === null || _validationFields$fie32 === void 0 ? void 0 : _validationFields$fie32.enabled) && (validationFields === null || validationFields === void 0 ? void 0 : (_validationFields$fie33 = validationFields.fields) === null || _validationFields$fie33 === void 0 ? void 0 : (_validationFields$fie34 = _validationFields$fie33.checkout) === null || _validationFields$fie34 === void 0 ? void 0 : (_validationFields$fie35 = _validationFields$fie34.driver_tip) === null || _validationFields$fie35 === void 0 ? void 0 : _validationFields$fie35.required) && Number(cart === null || cart === void 0 ? void 0 : cart.driver_tip) <= 0 && /*#__PURE__*/_react.default.createElement(_styles2.WarningText, null, t('WARNING_INVALID_DRIVER_TIP', 'Driver Tip is required.')), validateCommentsCartField && /*#__PURE__*/_react.default.createElement(_styles2.WarningText, null, t('WARNING_INVALID_CART_COMMENTS', 'Cart comments is required.')), validateZipcodeCard && /*#__PURE__*/_react.default.createElement(_styles2.WarningText, null, t('WARNING_CARD_ZIPCODE_REQUIRED', 'Your card selected has not zipcode')), (cart === null || cart === void 0 ? void 0 : cart.valid_preorder) !== undefined && !(cart !== null && cart !== void 0 && cart.valid_preorder) && /*#__PURE__*/_react.default.createElement(_styles2.WarningText, null, t('INVALID_CART_MOMENT', 'Selected schedule time is invalid, please select a schedule into the business schedule interval.')), /*#__PURE__*/_react.default.createElement(_Shared.Alert, {
|
|
233
|
+
title: t('CUSTOMER_DETAILS', 'Customer Details'),
|
|
234
|
+
content: alertState.content,
|
|
235
|
+
acceptText: t('ACCEPT', 'Accept'),
|
|
236
|
+
open: alertState.open,
|
|
237
|
+
onClose: function onClose() {
|
|
238
|
+
return setAlertState({
|
|
239
|
+
open: false,
|
|
240
|
+
content: []
|
|
241
|
+
});
|
|
242
|
+
},
|
|
243
|
+
onAccept: function onAccept() {
|
|
244
|
+
return setAlertState({
|
|
245
|
+
open: false,
|
|
246
|
+
content: []
|
|
247
|
+
});
|
|
248
|
+
},
|
|
249
|
+
closeOnBackdrop: false
|
|
250
|
+
}));
|
|
251
|
+
};
|
|
252
|
+
var Checkout = function Checkout(props) {
|
|
253
|
+
var _Object$values, _cartState$error, _cartState$cart2;
|
|
254
|
+
var errors = props.errors,
|
|
255
|
+
clearErrors = props.clearErrors,
|
|
256
|
+
cartUuid = props.cartUuid,
|
|
257
|
+
handleOrderRedirect = props.handleOrderRedirect,
|
|
258
|
+
handleSearchRedirect = props.handleSearchRedirect,
|
|
259
|
+
handleCheckoutListRedirect = props.handleCheckoutListRedirect,
|
|
260
|
+
businessSlug = props.businessSlug;
|
|
261
|
+
var _useOrder3 = (0, _orderingComponentsAdminExternal.useOrder)(),
|
|
262
|
+
_useOrder4 = _slicedToArray(_useOrder3, 2),
|
|
263
|
+
orderState = _useOrder4[0],
|
|
264
|
+
confirmCart = _useOrder4[1].confirmCart;
|
|
265
|
+
var _useSession3 = (0, _orderingComponentsAdminExternal.useSession)(),
|
|
266
|
+
_useSession4 = _slicedToArray(_useSession3, 1),
|
|
267
|
+
token = _useSession4[0].token;
|
|
268
|
+
var _useApi = (0, _orderingComponentsAdminExternal.useApi)(),
|
|
269
|
+
_useApi2 = _slicedToArray(_useApi, 1),
|
|
270
|
+
ordering = _useApi2[0];
|
|
271
|
+
var _useLanguage3 = (0, _orderingComponentsAdminExternal.useLanguage)(),
|
|
272
|
+
_useLanguage4 = _slicedToArray(_useLanguage3, 2),
|
|
273
|
+
t = _useLanguage4[1];
|
|
274
|
+
var _useState13 = (0, _react.useState)({
|
|
275
|
+
loading: true,
|
|
276
|
+
error: null,
|
|
277
|
+
cart: null
|
|
278
|
+
}),
|
|
279
|
+
_useState14 = _slicedToArray(_useState13, 2),
|
|
280
|
+
cartState = _useState14[0],
|
|
281
|
+
setCartState = _useState14[1];
|
|
282
|
+
var _useState15 = (0, _react.useState)(null),
|
|
283
|
+
_useState16 = _slicedToArray(_useState15, 2),
|
|
284
|
+
currentCart = _useState16[0],
|
|
285
|
+
setCurrentCart = _useState16[1];
|
|
286
|
+
var _useState17 = (0, _react.useState)({
|
|
287
|
+
open: false,
|
|
288
|
+
content: []
|
|
289
|
+
}),
|
|
290
|
+
_useState18 = _slicedToArray(_useState17, 2),
|
|
291
|
+
alertState = _useState18[0],
|
|
292
|
+
setAlertState = _useState18[1];
|
|
293
|
+
var _useState19 = (0, _react.useState)(false),
|
|
294
|
+
_useState20 = _slicedToArray(_useState19, 2),
|
|
295
|
+
isResetPaymethod = _useState20[0],
|
|
296
|
+
setIsResetPaymethod = _useState20[1];
|
|
297
|
+
var cartsWithProducts = (orderState === null || orderState === void 0 ? void 0 : orderState.carts) && (((_Object$values = Object.values(orderState === null || orderState === void 0 ? void 0 : orderState.carts)) === null || _Object$values === void 0 ? void 0 : _Object$values.filter(function (cart) {
|
|
298
|
+
var _cart$products;
|
|
299
|
+
return (cart === null || cart === void 0 ? void 0 : cart.products) && (cart === null || cart === void 0 ? void 0 : (_cart$products = cart.products) === null || _cart$products === void 0 ? void 0 : _cart$products.length);
|
|
300
|
+
})) || null);
|
|
301
|
+
var carts = businessSlug ? cartsWithProducts.filter(function (cart) {
|
|
302
|
+
var _cart$business;
|
|
303
|
+
return (cart === null || cart === void 0 ? void 0 : (_cart$business = cart.business) === null || _cart$business === void 0 ? void 0 : _cart$business.slug) === businessSlug || businessSlug === (cart === null || cart === void 0 ? void 0 : cart.business_id);
|
|
304
|
+
}) : cartsWithProducts;
|
|
305
|
+
var closeAlert = function closeAlert() {
|
|
306
|
+
setAlertState({
|
|
307
|
+
open: false,
|
|
308
|
+
content: []
|
|
309
|
+
});
|
|
310
|
+
clearErrors && clearErrors();
|
|
311
|
+
};
|
|
312
|
+
(0, _react.useEffect)(function () {
|
|
313
|
+
if (!orderState.loading && currentCart !== null && currentCart !== void 0 && currentCart.business_id) {
|
|
314
|
+
var _Object$values2;
|
|
315
|
+
setCurrentCart.apply(void 0, _toConsumableArray((_Object$values2 = Object.values(orderState.carts)) === null || _Object$values2 === void 0 ? void 0 : _Object$values2.filter(function (cart) {
|
|
316
|
+
return (cart === null || cart === void 0 ? void 0 : cart.business_id) === (currentCart === null || currentCart === void 0 ? void 0 : currentCart.business_id);
|
|
317
|
+
})));
|
|
318
|
+
}
|
|
319
|
+
}, [orderState.loading]);
|
|
320
|
+
(0, _react.useEffect)(function () {
|
|
321
|
+
if (errors !== null && errors !== void 0 && errors.length) {
|
|
322
|
+
setAlertState({
|
|
323
|
+
open: true,
|
|
324
|
+
content: errors
|
|
325
|
+
});
|
|
326
|
+
}
|
|
327
|
+
}, [errors]);
|
|
328
|
+
var getOrder = /*#__PURE__*/function () {
|
|
329
|
+
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(cartId) {
|
|
330
|
+
var _result$order, result, cart, userCustomer, url, response, content, _result, _result$paymethod_dat, credomaticData, urlParams, paramsObj, _confirmCartRes$resul, confirmCartRes, _cart, spotNumberFromStorage, _JSON$parse, _JSON$parse2, _cart2, _cart2$business, spotNumber, slug;
|
|
331
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
332
|
+
while (1) switch (_context.prev = _context.next) {
|
|
333
|
+
case 0:
|
|
334
|
+
_context.prev = 0;
|
|
335
|
+
result = {};
|
|
336
|
+
cart = carts.find(function (cart) {
|
|
337
|
+
return cart.uuid === cartId;
|
|
338
|
+
});
|
|
339
|
+
userCustomer = JSON.parse(window.localStorage.getItem('user-customer'));
|
|
340
|
+
if (!(cart && !userCustomer)) {
|
|
341
|
+
_context.next = 8;
|
|
342
|
+
break;
|
|
343
|
+
}
|
|
344
|
+
result = JSON.parse(JSON.stringify(cart));
|
|
345
|
+
_context.next = 17;
|
|
346
|
+
break;
|
|
347
|
+
case 8:
|
|
348
|
+
setCartState(_objectSpread(_objectSpread({}, cartState), {}, {
|
|
349
|
+
loading: true
|
|
350
|
+
}));
|
|
351
|
+
url = userCustomer ? "".concat(ordering.root, "/carts/").concat(cartId, "?user_id=").concat(userCustomer === null || userCustomer === void 0 ? void 0 : userCustomer.id) : "".concat(ordering.root, "/carts/").concat(cartId);
|
|
352
|
+
_context.next = 12;
|
|
353
|
+
return fetch(url, {
|
|
354
|
+
method: 'GET',
|
|
355
|
+
headers: {
|
|
356
|
+
'Content-Type': 'application/json',
|
|
357
|
+
Authorization: "Bearer ".concat(token),
|
|
358
|
+
'X-App-X': ordering.appId
|
|
359
|
+
}
|
|
360
|
+
});
|
|
361
|
+
case 12:
|
|
362
|
+
response = _context.sent;
|
|
363
|
+
_context.next = 15;
|
|
364
|
+
return response.json();
|
|
365
|
+
case 15:
|
|
366
|
+
content = _context.sent;
|
|
367
|
+
result = content.result;
|
|
368
|
+
case 17:
|
|
369
|
+
if (!(result.status === 1 && (_result$order = result.order) !== null && _result$order !== void 0 && _result$order.uuid)) {
|
|
370
|
+
_context.next = 22;
|
|
371
|
+
break;
|
|
372
|
+
}
|
|
373
|
+
handleOrderRedirect(result.order.uuid);
|
|
374
|
+
setCartState(_objectSpread(_objectSpread({}, cartState), {}, {
|
|
375
|
+
loading: false
|
|
376
|
+
}));
|
|
377
|
+
_context.next = 43;
|
|
378
|
+
break;
|
|
379
|
+
case 22:
|
|
380
|
+
if (!(result.status === 2)) {
|
|
381
|
+
_context.next = 39;
|
|
382
|
+
break;
|
|
383
|
+
}
|
|
384
|
+
credomaticData = null;
|
|
385
|
+
if (((_result = result) === null || _result === void 0 ? void 0 : (_result$paymethod_dat = _result.paymethod_data) === null || _result$paymethod_dat === void 0 ? void 0 : _result$paymethod_dat.gateway) === 'credomatic') {
|
|
386
|
+
urlParams = new URLSearchParams(window.location.search);
|
|
387
|
+
paramsObj = Object.fromEntries(urlParams.entries());
|
|
388
|
+
credomaticData = {
|
|
389
|
+
credomatic: _objectSpread({}, paramsObj)
|
|
390
|
+
};
|
|
391
|
+
}
|
|
392
|
+
_context.prev = 25;
|
|
393
|
+
_context.next = 28;
|
|
394
|
+
return confirmCart(cartUuid, credomaticData);
|
|
395
|
+
case 28:
|
|
396
|
+
confirmCartRes = _context.sent;
|
|
397
|
+
if (confirmCartRes.error) {
|
|
398
|
+
setAlertState({
|
|
399
|
+
open: true,
|
|
400
|
+
content: typeof confirmCartRes.result === 'string' ? [confirmCartRes.result] : confirmCartRes.result
|
|
401
|
+
});
|
|
402
|
+
setIsResetPaymethod(true);
|
|
403
|
+
}
|
|
404
|
+
if ((_confirmCartRes$resul = confirmCartRes.result.order) !== null && _confirmCartRes$resul !== void 0 && _confirmCartRes$resul.uuid) {
|
|
405
|
+
handleOrderRedirect(confirmCartRes.result.order.uuid);
|
|
406
|
+
}
|
|
407
|
+
setCartState(_objectSpread(_objectSpread({}, cartState), {}, {
|
|
408
|
+
loading: false,
|
|
409
|
+
cart: result
|
|
410
|
+
}));
|
|
411
|
+
_context.next = 37;
|
|
412
|
+
break;
|
|
413
|
+
case 34:
|
|
414
|
+
_context.prev = 34;
|
|
415
|
+
_context.t0 = _context["catch"](25);
|
|
416
|
+
setAlertState({
|
|
417
|
+
open: true,
|
|
418
|
+
content: [_context.t0.message]
|
|
419
|
+
});
|
|
420
|
+
case 37:
|
|
421
|
+
_context.next = 43;
|
|
422
|
+
break;
|
|
423
|
+
case 39:
|
|
424
|
+
_cart = Array.isArray(result) ? null : JSON.parse(JSON.stringify(result));
|
|
425
|
+
spotNumberFromStorage = window.localStorage.getItem('table_number');
|
|
426
|
+
if (spotNumberFromStorage) {
|
|
427
|
+
spotNumber = (_JSON$parse = JSON.parse(spotNumberFromStorage)) === null || _JSON$parse === void 0 ? void 0 : _JSON$parse.tableNumber;
|
|
428
|
+
slug = (_JSON$parse2 = JSON.parse(spotNumberFromStorage)) === null || _JSON$parse2 === void 0 ? void 0 : _JSON$parse2.slug;
|
|
429
|
+
if (((_cart2 = _cart) === null || _cart2 === void 0 ? void 0 : (_cart2$business = _cart2.business) === null || _cart2$business === void 0 ? void 0 : _cart2$business.slug) === slug) {
|
|
430
|
+
_cart = _objectSpread(_objectSpread({}, _cart), {}, {
|
|
431
|
+
spot_number: parseInt(spotNumber, 10)
|
|
432
|
+
});
|
|
433
|
+
}
|
|
434
|
+
}
|
|
435
|
+
setCartState({
|
|
436
|
+
loading: false,
|
|
437
|
+
cart: _cart,
|
|
438
|
+
error: _cart ? null : result
|
|
439
|
+
});
|
|
440
|
+
case 43:
|
|
441
|
+
_context.next = 48;
|
|
442
|
+
break;
|
|
443
|
+
case 45:
|
|
444
|
+
_context.prev = 45;
|
|
445
|
+
_context.t1 = _context["catch"](0);
|
|
446
|
+
setCartState(_objectSpread(_objectSpread({}, cartState), {}, {
|
|
447
|
+
loading: false,
|
|
448
|
+
error: [_context.t1.toString()]
|
|
449
|
+
}));
|
|
450
|
+
case 48:
|
|
451
|
+
case "end":
|
|
452
|
+
return _context.stop();
|
|
453
|
+
}
|
|
454
|
+
}, _callee, null, [[0, 45], [25, 34]]);
|
|
455
|
+
}));
|
|
456
|
+
return function getOrder(_x2) {
|
|
457
|
+
return _ref.apply(this, arguments);
|
|
458
|
+
};
|
|
459
|
+
}();
|
|
460
|
+
(0, _react.useEffect)(function () {
|
|
461
|
+
if (token && cartUuid) {
|
|
462
|
+
getOrder(cartUuid);
|
|
463
|
+
} else {
|
|
464
|
+
setCartState(_objectSpread(_objectSpread({}, cartState), {}, {
|
|
465
|
+
loading: false
|
|
466
|
+
}));
|
|
467
|
+
}
|
|
468
|
+
}, [token, cartUuid]);
|
|
469
|
+
var checkoutProps = _objectSpread(_objectSpread({}, props), {}, {
|
|
470
|
+
UIComponent: CheckoutUI,
|
|
471
|
+
cartState: cartState,
|
|
472
|
+
uuid: cartUuid,
|
|
473
|
+
isResetPaymethod: isResetPaymethod,
|
|
474
|
+
setIsResetPaymethod: setIsResetPaymethod
|
|
475
|
+
});
|
|
476
|
+
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, !cartUuid && orderState.carts && carts && (carts === null || carts === void 0 ? void 0 : carts.length) === 0 && /*#__PURE__*/_react.default.createElement(_Shared.NotFoundSource, {
|
|
477
|
+
content: t('NOT_FOUND_CARTS', 'Sorry, You don\'t seem to have any carts.'),
|
|
478
|
+
btnTitle: t('SEARCH_REDIRECT', 'Go to Businesses'),
|
|
479
|
+
onClickButton: handleSearchRedirect
|
|
480
|
+
}), cartUuid && cartState.error && ((_cartState$error = cartState.error) === null || _cartState$error === void 0 ? void 0 : _cartState$error.length) > 0 && /*#__PURE__*/_react.default.createElement(_Shared.NotFoundSource, {
|
|
481
|
+
content: t('ERROR_CART_SELECTED', 'Sorry, the selected cart was not found.'),
|
|
482
|
+
btnTitle: t('CHECKOUT_REDIRECT', 'Go to Checkout list'),
|
|
483
|
+
onClickButton: handleCheckoutListRedirect
|
|
484
|
+
}), cartUuid && cartState.cart && ((_cartState$cart2 = cartState.cart) === null || _cartState$cart2 === void 0 ? void 0 : _cartState$cart2.status) !== 1 && /*#__PURE__*/_react.default.createElement(_orderingComponentsAdminExternal.Checkout, checkoutProps), /*#__PURE__*/_react.default.createElement(_Shared.Alert, {
|
|
485
|
+
title: t('CHECKOUT ', 'Checkout'),
|
|
486
|
+
content: alertState.content,
|
|
487
|
+
acceptText: t('ACCEPT', 'Accept'),
|
|
488
|
+
open: alertState.open,
|
|
489
|
+
onClose: function onClose() {
|
|
490
|
+
return closeAlert();
|
|
491
|
+
},
|
|
492
|
+
onAccept: function onAccept() {
|
|
493
|
+
return closeAlert();
|
|
494
|
+
},
|
|
495
|
+
closeOnBackdrop: false
|
|
496
|
+
}));
|
|
497
|
+
};
|
|
498
|
+
exports.Checkout = Checkout;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.WrapperPlaceOrderButton = exports.WarningText = exports.WarningMessage = exports.SectionTitleContainer = exports.PaymentMethodContainer = exports.Flag = exports.Conatiner = void 0;
|
|
8
|
+
var _styledComponents = _interopRequireWildcard(require("styled-components"));
|
|
9
|
+
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8;
|
|
10
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
11
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
12
|
+
function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
|
|
13
|
+
var Conatiner = _styledComponents.default.div(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n\n"])));
|
|
14
|
+
exports.Conatiner = Conatiner;
|
|
15
|
+
var WarningMessage = _styledComponents.default.div(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n width: 100%;\n height: fit-content;\n max-height: fit-content;\n min-height: 150px;\n background-color: #F2BB40;\n display: flex;\n justify-content: center;\n align-items: center;\n opacity: 0.8;\n border-radius: 10px;\n position: relative;\n\n svg {\n position: absolute;\n font-size: 30px;\n top: 0;\n left: 0;\n margin: 11px;\n ", "\n }\n\n h1 {\n font-size: 20px;\n margin: 0px 60px;\n text-align: center;\n }\n"])), function (props) {
|
|
16
|
+
var _props$theme;
|
|
17
|
+
return ((_props$theme = props.theme) === null || _props$theme === void 0 ? void 0 : _props$theme.rtl) && (0, _styledComponents.css)(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n right: 0;\n left: initial;\n "])));
|
|
18
|
+
});
|
|
19
|
+
exports.WarningMessage = WarningMessage;
|
|
20
|
+
var Flag = _styledComponents.default.span(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n font-size: 13px;\n margin: 0px;\n text-transform: capitalize;\n color: #E63757;\n font-weight: 500;\n\n @media (min-width: 381px) {\n font-size: 14px;\n }\n"])));
|
|
21
|
+
exports.Flag = Flag;
|
|
22
|
+
var SectionTitleContainer = _styledComponents.default.div(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["\n display: flex;\n align-items: center;\n justify-content: space-between;\n"])));
|
|
23
|
+
exports.SectionTitleContainer = SectionTitleContainer;
|
|
24
|
+
var PaymentMethodContainer = _styledComponents.default.div(_templateObject6 || (_templateObject6 = _taggedTemplateLiteral(["\n display: flex;\n flex-direction: column;\n margin: 50px 0px 0px;\n"])));
|
|
25
|
+
exports.PaymentMethodContainer = PaymentMethodContainer;
|
|
26
|
+
var WarningText = _styledComponents.default.p(_templateObject7 || (_templateObject7 = _taggedTemplateLiteral(["\n margin: 10px auto;\n text-align: center;\n color: ", ";\n"])), function (props) {
|
|
27
|
+
return props.theme.colors.primary;
|
|
28
|
+
});
|
|
29
|
+
exports.WarningText = WarningText;
|
|
30
|
+
var WrapperPlaceOrderButton = _styledComponents.default.div(_templateObject8 || (_templateObject8 = _taggedTemplateLiteral(["\n padding: 15px 0px;\n display: flex;\n align-items: center;\n justify-content: space-between;\n box-sizing: border-box;\n\n span {\n font-weight: 600;\n font-size: 16px;\n\n @media (min-width: 1200px) {\n font-size: 18px;\n padding-left: 20px;\n }\n }\n\n button {\n min-height: 44px;\n border-radius: 7.6px;\n }\n"])));
|
|
31
|
+
exports.WrapperPlaceOrderButton = WrapperPlaceOrderButton;
|