ordering-ui-external 14.1.49 → 14.1.52
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/{7.ordering-ui.697d19ddfcc29dfbeb52.js → 7.ordering-ui.746cebc54de638e8e528.js} +1 -1
- package/_bundles/ordering-ui.746cebc54de638e8e528.js +2 -0
- package/_modules/components/GoogleGpsButton/index.js +11 -3
- package/_modules/components/VerticalOrdersLayout/styles.js +1 -1
- package/_modules/themes/callcenterOriginal/index.js +7 -0
- package/_modules/themes/callcenterOriginal/src/components/AddressForm/index.js +22 -5
- package/_modules/themes/callcenterOriginal/src/components/AddressForm/styles.js +10 -7
- package/_modules/themes/callcenterOriginal/src/components/AddressList/index.js +59 -19
- package/_modules/themes/callcenterOriginal/src/components/AddressList/styles.js +10 -4
- package/_modules/themes/callcenterOriginal/src/components/ConfirmAddressForm/index.js +638 -0
- package/_modules/themes/callcenterOriginal/src/components/ConfirmAddressForm/styles.js +50 -0
- package/_modules/themes/callcenterOriginal/src/components/Header/index.js +33 -4
- package/_modules/themes/callcenterOriginal/src/components/InputPhoneNumber/index.js +17 -10
- package/_modules/themes/callcenterOriginal/src/components/PhoneAutocomplete/index.js +58 -106
- package/_modules/themes/callcenterOriginal/src/components/PhoneAutocomplete/styles.js +6 -29
- package/_modules/themes/callcenterOriginal/src/components/SearchBar/index.js +2 -2
- package/_modules/themes/callcenterOriginal/src/components/SignUpForm/index.js +21 -1
- package/_modules/themes/callcenterOriginal/src/components/UserDetails/index.js +49 -8
- package/_modules/themes/callcenterOriginal/src/components/UserDetails/styles.js +12 -9
- package/_modules/themes/callcenterOriginal/src/components/UserFormDetails/index.js +30 -12
- package/_modules/themes/callcenterOriginal/src/components/UserFormDetails/styles.js +11 -5
- package/_modules/themes/five/src/components/BusinessBasicInformation/index.js +1 -1
- package/_modules/themes/five/src/components/BusinessController/franchises/OloBusinessController/index.js +192 -0
- package/_modules/themes/five/src/components/BusinessController/franchises/OloBusinessController/styles.js +114 -0
- package/_modules/themes/five/src/components/BusinessesListing/franchises/OloBusinessesListing/index.js +572 -0
- package/_modules/themes/five/src/components/BusinessesListing/franchises/OloBusinessesListing/styles.js +89 -0
- package/_modules/themes/five/src/components/BusinessesListing/index.js +6 -2
- package/_modules/themes/five/src/components/BusinessesListing/layouts/OriginalBusinessesListing/index.js +31 -118
- package/_modules/themes/five/src/components/BusinessesListing/layouts/OriginalBusinessesListing/styles.js +1 -1
- package/_modules/themes/five/src/components/Checkout/OrderDetail.js +1 -3
- package/_modules/themes/five/src/components/Checkout/index.js +22 -4
- package/_modules/themes/five/src/components/DriverTips/styles.js +1 -1
- package/_modules/themes/five/src/components/Header/index.js +8 -7
- package/_modules/themes/five/src/components/Header/styles.js +28 -25
- package/_modules/themes/five/src/components/HighestRated/franchises/OloHighestRated/index.js +116 -0
- package/_modules/themes/five/src/components/HighestRated/franchises/OloHighestRated/styles.js +22 -0
- package/_modules/themes/five/src/components/HomeHero/franchises/OloHomeHero/index.js +136 -0
- package/_modules/themes/five/src/components/HomeHero/franchises/OloHomeHero/styles.js +46 -0
- package/_modules/themes/five/src/components/HomeHero/index.js +5 -2
- package/_modules/themes/five/src/components/InputPhoneNumber/index.js +19 -12
- package/_modules/themes/five/src/components/LogoutPopup/index.js +2 -1
- package/_modules/themes/five/src/components/Modal/index.js +6 -3
- package/_modules/themes/five/src/components/MultiOrdersDetails/styles.js +2 -2
- package/_modules/themes/five/src/components/OrderDetails/layouts/Kiosk/index.js +2 -1
- package/_modules/themes/five/src/components/OrderItAgain/styles.js +1 -1
- package/_modules/themes/five/src/components/OrderTypesSquares/index.js +160 -0
- package/_modules/themes/five/src/components/OrderTypesSquares/styles.js +39 -0
- package/_modules/themes/five/src/components/ProductItemAccordion/index.js +4 -4
- package/_modules/themes/five/src/components/RenderProductsLayout/styles.js +1 -1
- package/_modules/themes/five/src/components/SearchBar/index.js +2 -2
- package/_modules/themes/five/src/components/SignUpForm/index.js +11 -8
- package/_modules/themes/five/src/components/SingleProductCard/layouts/original/styles.js +1 -1
- package/_modules/themes/five/src/components/UserDetails/index.js +5 -2
- package/_modules/themes/five/src/styles/Buttons/index.js +1 -1
- package/index-template.js +9 -1
- package/package.json +2 -2
- package/src/components/GoogleGpsButton/index.js +10 -2
- package/src/components/VerticalOrdersLayout/styles.js +2 -2
- package/src/themes/callcenterOriginal/index.js +2 -0
- package/src/themes/callcenterOriginal/src/components/AddressForm/index.js +44 -23
- package/src/themes/callcenterOriginal/src/components/AddressForm/styles.js +8 -0
- package/src/themes/callcenterOriginal/src/components/AddressList/index.js +67 -22
- package/src/themes/callcenterOriginal/src/components/AddressList/styles.js +16 -1
- package/src/themes/callcenterOriginal/src/components/ConfirmAddressForm/index.js +579 -0
- package/src/themes/callcenterOriginal/src/components/ConfirmAddressForm/styles.js +275 -0
- package/src/themes/callcenterOriginal/src/components/Header/index.js +22 -0
- package/src/themes/callcenterOriginal/src/components/InputPhoneNumber/index.js +13 -8
- package/src/themes/callcenterOriginal/src/components/PhoneAutocomplete/index.js +34 -100
- package/src/themes/callcenterOriginal/src/components/PhoneAutocomplete/styles.js +0 -52
- package/src/themes/callcenterOriginal/src/components/SearchBar/index.js +2 -2
- package/src/themes/callcenterOriginal/src/components/SignUpForm/index.js +19 -1
- package/src/themes/callcenterOriginal/src/components/UserDetails/index.js +45 -11
- package/src/themes/callcenterOriginal/src/components/UserDetails/styles.js +3 -1
- package/src/themes/callcenterOriginal/src/components/UserFormDetails/index.js +40 -14
- package/src/themes/callcenterOriginal/src/components/UserFormDetails/styles.js +19 -1
- package/src/themes/five/src/components/BusinessBasicInformation/index.js +1 -1
- package/src/themes/five/src/components/BusinessController/franchises/OloBusinessController/index.js +237 -0
- package/src/themes/five/src/components/BusinessController/franchises/OloBusinessController/styles.js +367 -0
- package/src/themes/five/src/components/BusinessesListing/franchises/OloBusinessesListing/index.js +582 -0
- package/src/themes/five/src/components/BusinessesListing/franchises/OloBusinessesListing/styles.js +307 -0
- package/src/themes/five/src/components/BusinessesListing/index.js +19 -4
- package/src/themes/five/src/components/BusinessesListing/layouts/OriginalBusinessesListing/index.js +7 -104
- package/src/themes/five/src/components/BusinessesListing/layouts/OriginalBusinessesListing/styles.js +2 -2
- package/src/themes/five/src/components/Checkout/OrderDetail.js +1 -5
- package/src/themes/five/src/components/Checkout/index.js +20 -2
- package/src/themes/five/src/components/DriverTips/styles.js +1 -0
- package/src/themes/five/src/components/Header/index.js +17 -12
- package/src/themes/five/src/components/Header/styles.js +51 -4
- package/src/themes/five/src/components/HighestRated/franchises/OloHighestRated/index.js +114 -0
- package/src/themes/five/src/components/HighestRated/franchises/OloHighestRated/styles.js +57 -0
- package/src/themes/five/src/components/HomeHero/franchises/OloHomeHero/index.js +122 -0
- package/src/themes/five/src/components/HomeHero/franchises/OloHomeHero/styles.js +125 -0
- package/src/themes/five/src/components/HomeHero/index.js +16 -3
- package/src/themes/five/src/components/InputPhoneNumber/index.js +14 -9
- package/src/themes/five/src/components/LogoutPopup/index.js +3 -1
- package/src/themes/five/src/components/Modal/index.js +6 -3
- package/src/themes/five/src/components/MultiOrdersDetails/styles.js +3 -3
- package/src/themes/five/src/components/OrderDetails/layouts/Kiosk/index.js +3 -1
- package/src/themes/five/src/components/OrderItAgain/styles.js +2 -0
- package/src/themes/five/src/components/OrderTypesSquares/index.js +157 -0
- package/src/themes/five/src/components/OrderTypesSquares/styles.js +62 -0
- package/src/themes/five/src/components/ProductItemAccordion/index.js +2 -2
- package/src/themes/five/src/components/RenderProductsLayout/styles.js +2 -0
- package/src/themes/five/src/components/SearchBar/index.js +2 -2
- package/src/themes/five/src/components/SignUpForm/index.js +5 -3
- package/src/themes/five/src/components/SingleProductCard/layouts/original/styles.js +1 -1
- package/src/themes/five/src/components/UserDetails/index.js +3 -1
- package/src/themes/five/src/styles/Buttons/index.js +2 -2
- package/template/app.js +14 -11
- package/template/assets/images/catering.svg +13 -0
- package/template/assets/images/curbside.svg +19 -0
- package/template/assets/images/drivethru.svg +19 -0
- package/template/assets/images/eatin.svg +17 -0
- package/template/components/SubdomainComponent/index.js +4 -8
- package/template/pages/BusinessesList/index.js +1 -1
- package/_bundles/ordering-ui.697d19ddfcc29dfbeb52.js +0 -2
- /package/_bundles/{0.ordering-ui.697d19ddfcc29dfbeb52.js → 0.ordering-ui.746cebc54de638e8e528.js} +0 -0
- /package/_bundles/{1.ordering-ui.697d19ddfcc29dfbeb52.js → 1.ordering-ui.746cebc54de638e8e528.js} +0 -0
- /package/_bundles/{2.ordering-ui.697d19ddfcc29dfbeb52.js → 2.ordering-ui.746cebc54de638e8e528.js} +0 -0
- /package/_bundles/{4.ordering-ui.697d19ddfcc29dfbeb52.js → 4.ordering-ui.746cebc54de638e8e528.js} +0 -0
- /package/_bundles/{5.ordering-ui.697d19ddfcc29dfbeb52.js → 5.ordering-ui.746cebc54de638e8e528.js} +0 -0
- /package/_bundles/{6.ordering-ui.697d19ddfcc29dfbeb52.js → 6.ordering-ui.746cebc54de638e8e528.js} +0 -0
- /package/_bundles/{7.ordering-ui.697d19ddfcc29dfbeb52.js.LICENSE.txt → 7.ordering-ui.746cebc54de638e8e528.js.LICENSE.txt} +0 -0
- /package/_bundles/{8.ordering-ui.697d19ddfcc29dfbeb52.js → 8.ordering-ui.746cebc54de638e8e528.js} +0 -0
- /package/_bundles/{9.ordering-ui.697d19ddfcc29dfbeb52.js → 9.ordering-ui.746cebc54de638e8e528.js} +0 -0
- /package/_bundles/{ordering-ui.697d19ddfcc29dfbeb52.js.LICENSE.txt → ordering-ui.746cebc54de638e8e528.js.LICENSE.txt} +0 -0
|
@@ -0,0 +1,638 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.ConfirmAddressForm = void 0;
|
|
8
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
9
|
+
var _reactLoadingSkeleton = _interopRequireDefault(require("react-loading-skeleton"));
|
|
10
|
+
var _CgSearchLoading = _interopRequireDefault(require("@meronex/icons/cg/CgSearchLoading"));
|
|
11
|
+
var _reactBootstrapIcons = require("react-bootstrap-icons");
|
|
12
|
+
var _styledComponents = require("styled-components");
|
|
13
|
+
var _reactHookForm = require("react-hook-form");
|
|
14
|
+
var _orderingComponentsExternal = require("ordering-components-external");
|
|
15
|
+
var _Confirm = require("../Confirm");
|
|
16
|
+
var _GoogleGpsButton = require("../../../../../components/GoogleGpsButton");
|
|
17
|
+
var _styles = require("./styles");
|
|
18
|
+
var _Buttons = require("../../styles/Buttons");
|
|
19
|
+
var _Inputs = require("../../styles/Inputs");
|
|
20
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
21
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
|
22
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
23
|
+
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 e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
|
|
24
|
+
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); } }
|
|
25
|
+
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); }); }; }
|
|
26
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
27
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
28
|
+
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; }
|
|
29
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
30
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
31
|
+
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
|
32
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
33
|
+
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."); }
|
|
34
|
+
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); }
|
|
35
|
+
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; }
|
|
36
|
+
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
37
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
38
|
+
var ConfirmAddressFormUI = function ConfirmAddressFormUI(props) {
|
|
39
|
+
var _addressState$address, _ref, _formState$changes$ad, _formState$changes, _addressState$address2, _addressState$address3, _addressState$address4, _formState$changes$lo, _formState$changes2, _theme$address, _theme$address2, _configState$configs, _configState$configs2, _configState$configs3, _configState$configs4, _navigator;
|
|
40
|
+
var addressesList = props.addressesList,
|
|
41
|
+
googleMapsControls = props.googleMapsControls,
|
|
42
|
+
formState = props.formState,
|
|
43
|
+
addressState = props.addressState,
|
|
44
|
+
isRequiredField = props.isRequiredField,
|
|
45
|
+
showField = props.showField,
|
|
46
|
+
updateChanges = props.updateChanges,
|
|
47
|
+
handleChangeInput = props.handleChangeInput,
|
|
48
|
+
saveAddress = props.saveAddress,
|
|
49
|
+
setIsEdit = props.setIsEdit,
|
|
50
|
+
userCustomerSetup = props.userCustomerSetup;
|
|
51
|
+
var _useConfig = (0, _orderingComponentsExternal.useConfig)(),
|
|
52
|
+
_useConfig2 = _slicedToArray(_useConfig, 1),
|
|
53
|
+
configState = _useConfig2[0];
|
|
54
|
+
var _useOrder = (0, _orderingComponentsExternal.useOrder)(),
|
|
55
|
+
_useOrder2 = _slicedToArray(_useOrder, 1),
|
|
56
|
+
orderState = _useOrder2[0];
|
|
57
|
+
var _useLanguage = (0, _orderingComponentsExternal.useLanguage)(),
|
|
58
|
+
_useLanguage2 = _slicedToArray(_useLanguage, 2),
|
|
59
|
+
t = _useLanguage2[1];
|
|
60
|
+
var formMethods = (0, _reactHookForm.useForm)();
|
|
61
|
+
var _useSession = (0, _orderingComponentsExternal.useSession)(),
|
|
62
|
+
_useSession2 = _slicedToArray(_useSession, 1),
|
|
63
|
+
auth = _useSession2[0].auth;
|
|
64
|
+
var theme = (0, _styledComponents.useTheme)();
|
|
65
|
+
var _useState = (0, _react.useState)(addressState === null || addressState === void 0 || (_addressState$address = addressState.address) === null || _addressState$address === void 0 ? void 0 : _addressState$address.tag),
|
|
66
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
67
|
+
addressTag = _useState2[0],
|
|
68
|
+
setAddressTag = _useState2[1];
|
|
69
|
+
var _useState3 = (0, _react.useState)({
|
|
70
|
+
open: false,
|
|
71
|
+
content: []
|
|
72
|
+
}),
|
|
73
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
74
|
+
alertState = _useState4[0],
|
|
75
|
+
setAlertState = _useState4[1];
|
|
76
|
+
var _useState5 = (0, _react.useState)((_ref = (_formState$changes$ad = (_formState$changes = formState.changes) === null || _formState$changes === void 0 ? void 0 : _formState$changes.address) !== null && _formState$changes$ad !== void 0 ? _formState$changes$ad : (_addressState$address2 = addressState.address) === null || _addressState$address2 === void 0 ? void 0 : _addressState$address2.address) !== null && _ref !== void 0 ? _ref : ''),
|
|
77
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
78
|
+
addressValue = _useState6[0],
|
|
79
|
+
setAddressValue = _useState6[1];
|
|
80
|
+
var _useState7 = (0, _react.useState)({
|
|
81
|
+
value: null
|
|
82
|
+
}),
|
|
83
|
+
_useState8 = _slicedToArray(_useState7, 2),
|
|
84
|
+
firstLocationNoEdit = _useState8[0],
|
|
85
|
+
setFirstLocationNoEdit = _useState8[1];
|
|
86
|
+
var _useState9 = (0, _react.useState)({
|
|
87
|
+
result: null,
|
|
88
|
+
error: false
|
|
89
|
+
}),
|
|
90
|
+
_useState10 = _slicedToArray(_useState9, 2),
|
|
91
|
+
geolocationState = _useState10[0],
|
|
92
|
+
setGeolocationState = _useState10[1];
|
|
93
|
+
var isEditing = !!((_addressState$address3 = addressState.address) !== null && _addressState$address3 !== void 0 && _addressState$address3.id);
|
|
94
|
+
var googleInputRef = (0, _react.useRef)();
|
|
95
|
+
var _useState11 = (0, _react.useState)(isEditing ? addressState === null || addressState === void 0 || (_addressState$address4 = addressState.address) === null || _addressState$address4 === void 0 ? void 0 : _addressState$address4.location : (_formState$changes$lo = (_formState$changes2 = formState.changes) === null || _formState$changes2 === void 0 ? void 0 : _formState$changes2.location) !== null && _formState$changes$lo !== void 0 ? _formState$changes$lo : null),
|
|
96
|
+
_useState12 = _slicedToArray(_useState11, 2),
|
|
97
|
+
locationChange = _useState12[0],
|
|
98
|
+
setLocationChange = _useState12[1];
|
|
99
|
+
var isHideMap = theme === null || theme === void 0 || (_theme$address = theme.address) === null || _theme$address === void 0 || (_theme$address = _theme$address.components) === null || _theme$address === void 0 || (_theme$address = _theme$address.map) === null || _theme$address === void 0 ? void 0 : _theme$address.hidden;
|
|
100
|
+
var isHideIcons = theme === null || theme === void 0 || (_theme$address2 = theme.address) === null || _theme$address2 === void 0 || (_theme$address2 = _theme$address2.components) === null || _theme$address2 === void 0 || (_theme$address2 = _theme$address2.icons) === null || _theme$address2 === void 0 ? void 0 : _theme$address2.hidden;
|
|
101
|
+
var maxLimitLocation = configState === null || configState === void 0 || (_configState$configs = configState.configs) === null || _configState$configs === void 0 || (_configState$configs = _configState$configs.meters_to_change_address) === null || _configState$configs === void 0 ? void 0 : _configState$configs.value;
|
|
102
|
+
var googleMapsApiKey = configState === null || configState === void 0 || (_configState$configs2 = configState.configs) === null || _configState$configs2 === void 0 || (_configState$configs2 = _configState$configs2.google_maps_api_key) === null || _configState$configs2 === void 0 ? void 0 : _configState$configs2.value;
|
|
103
|
+
var isLocationRequired = ((_configState$configs3 = configState.configs) === null || _configState$configs3 === void 0 || (_configState$configs3 = _configState$configs3.google_autocomplete_selection_required) === null || _configState$configs3 === void 0 ? void 0 : _configState$configs3.value) === '1' || ((_configState$configs4 = configState.configs) === null || _configState$configs4 === void 0 || (_configState$configs4 = _configState$configs4.google_autocomplete_selection_required) === null || _configState$configs4 === void 0 ? void 0 : _configState$configs4.value) === 'true';
|
|
104
|
+
var mapErrors = {
|
|
105
|
+
ERROR_NOT_FOUND_ADDRESS: 'Sorry, we couldn\'t find an address',
|
|
106
|
+
ERROR_MAX_LIMIT_LOCATION: "Sorry, You can only set the position to ".concat(maxLimitLocation, "m")
|
|
107
|
+
};
|
|
108
|
+
var inputNames = [{
|
|
109
|
+
name: 'address',
|
|
110
|
+
code: 'Address'
|
|
111
|
+
}, {
|
|
112
|
+
name: 'internal_number',
|
|
113
|
+
code: 'Internal number'
|
|
114
|
+
}, {
|
|
115
|
+
name: 'zipcode',
|
|
116
|
+
code: 'Zipcode'
|
|
117
|
+
}, {
|
|
118
|
+
name: 'address_notes',
|
|
119
|
+
code: 'Address notes'
|
|
120
|
+
}];
|
|
121
|
+
var closeAlert = function closeAlert() {
|
|
122
|
+
setAlertState({
|
|
123
|
+
open: false,
|
|
124
|
+
content: []
|
|
125
|
+
});
|
|
126
|
+
};
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* Returns true when the user made no changes
|
|
130
|
+
* @param {object} address
|
|
131
|
+
*/
|
|
132
|
+
var checkAddress = function checkAddress(address, addressToCompare) {
|
|
133
|
+
var props = ['address', 'address_notes', 'zipcode', 'location', 'internal_number'];
|
|
134
|
+
var values = [];
|
|
135
|
+
props.forEach(function (prop) {
|
|
136
|
+
if (addressToCompare[prop]) {
|
|
137
|
+
if (prop === 'location') {
|
|
138
|
+
var _address$prop, _addressToCompare$pro, _address$prop2, _addressToCompare$pro2;
|
|
139
|
+
values.push(((_address$prop = address[prop]) === null || _address$prop === void 0 ? void 0 : _address$prop.lat) === ((_addressToCompare$pro = addressToCompare[prop]) === null || _addressToCompare$pro === void 0 ? void 0 : _addressToCompare$pro.lat) && ((_address$prop2 = address[prop]) === null || _address$prop2 === void 0 ? void 0 : _address$prop2.lng) === ((_addressToCompare$pro2 = addressToCompare[prop]) === null || _addressToCompare$pro2 === void 0 ? void 0 : _addressToCompare$pro2.lng));
|
|
140
|
+
} else {
|
|
141
|
+
values.push(address[prop] === addressToCompare[prop]);
|
|
142
|
+
}
|
|
143
|
+
} else {
|
|
144
|
+
values.push(!address[prop]);
|
|
145
|
+
}
|
|
146
|
+
});
|
|
147
|
+
return values.every(function (value) {
|
|
148
|
+
return value;
|
|
149
|
+
});
|
|
150
|
+
};
|
|
151
|
+
var getAddressFormatted = function getAddressFormatted(addressChange) {
|
|
152
|
+
var data = {
|
|
153
|
+
address: null,
|
|
154
|
+
error: null
|
|
155
|
+
};
|
|
156
|
+
var geocoder = window.google && new window.google.maps.Geocoder();
|
|
157
|
+
if (geocoder) {
|
|
158
|
+
geocoder.geocode({
|
|
159
|
+
address: addressChange
|
|
160
|
+
}, function (results, status) {
|
|
161
|
+
var postalCode = null;
|
|
162
|
+
if (status === 'OK' && results && results.length > 0) {
|
|
163
|
+
var _results$0$utc_offset, _arrayList$map$some;
|
|
164
|
+
var _iterator = _createForOfIteratorHelper(results === null || results === void 0 ? void 0 : results[0].address_components),
|
|
165
|
+
_step;
|
|
166
|
+
try {
|
|
167
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
168
|
+
var _component$types;
|
|
169
|
+
var component = _step.value;
|
|
170
|
+
var addressType = (_component$types = component.types) === null || _component$types === void 0 ? void 0 : _component$types[0];
|
|
171
|
+
if (addressType === 'postal_code') {
|
|
172
|
+
postalCode = component.short_name;
|
|
173
|
+
break;
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
} catch (err) {
|
|
177
|
+
_iterator.e(err);
|
|
178
|
+
} finally {
|
|
179
|
+
_iterator.f();
|
|
180
|
+
}
|
|
181
|
+
data.address = {
|
|
182
|
+
address: addressChange,
|
|
183
|
+
location: {
|
|
184
|
+
lat: results === null || results === void 0 ? void 0 : results[0].geometry.location.lat(),
|
|
185
|
+
lng: results === null || results === void 0 ? void 0 : results[0].geometry.location.lng()
|
|
186
|
+
},
|
|
187
|
+
utc_offset: (_results$0$utc_offset = results === null || results === void 0 ? void 0 : results[0].utc_offset_minutes) !== null && _results$0$utc_offset !== void 0 ? _results$0$utc_offset : 0,
|
|
188
|
+
map_data: {
|
|
189
|
+
library: 'google',
|
|
190
|
+
place_id: results === null || results === void 0 ? void 0 : results[0].place_id
|
|
191
|
+
}
|
|
192
|
+
};
|
|
193
|
+
if (postalCode) {
|
|
194
|
+
data.address.zipcode = postalCode;
|
|
195
|
+
}
|
|
196
|
+
var arrayList = isEditing ? addressesList.filter(function (address) {
|
|
197
|
+
var _addressState$address5;
|
|
198
|
+
return address.id !== ((_addressState$address5 = addressState.address) === null || _addressState$address5 === void 0 ? void 0 : _addressState$address5.id);
|
|
199
|
+
}) || [] : addressesList || [];
|
|
200
|
+
var addressToCompare = isEditing ? _objectSpread(_objectSpread(_objectSpread({}, addressState.address), data.address), formState === null || formState === void 0 ? void 0 : formState.changes) : _objectSpread(_objectSpread({}, data.address), formState === null || formState === void 0 ? void 0 : formState.changes);
|
|
201
|
+
var isAddressAlreadyExist = (_arrayList$map$some = arrayList.map(function (address) {
|
|
202
|
+
return checkAddress(address, addressToCompare);
|
|
203
|
+
}).some(function (value) {
|
|
204
|
+
return value;
|
|
205
|
+
})) !== null && _arrayList$map$some !== void 0 ? _arrayList$map$some : false;
|
|
206
|
+
if (!isAddressAlreadyExist) {
|
|
207
|
+
saveAddress(data.address, userCustomerSetup);
|
|
208
|
+
return;
|
|
209
|
+
}
|
|
210
|
+
setAlertState({
|
|
211
|
+
open: true,
|
|
212
|
+
content: [t('ADDRESS_ALREADY_EXIST', 'The address already exists')]
|
|
213
|
+
});
|
|
214
|
+
} else {
|
|
215
|
+
setAlertState({
|
|
216
|
+
open: true,
|
|
217
|
+
content: [t('ERROR_NOT_FOUND_ADDRESS', 'Error, address not found')]
|
|
218
|
+
});
|
|
219
|
+
}
|
|
220
|
+
});
|
|
221
|
+
} else {
|
|
222
|
+
setAlertState({
|
|
223
|
+
open: true,
|
|
224
|
+
content: [t('ERROR_FAILED_LOAD_GEOCODER', 'Failed to load geocoder, please try again.')]
|
|
225
|
+
});
|
|
226
|
+
}
|
|
227
|
+
};
|
|
228
|
+
var checkKeyDown = function checkKeyDown(e) {
|
|
229
|
+
var keyCode = e.keyCode ? e.keyCode : e.which;
|
|
230
|
+
if (keyCode === 13) {
|
|
231
|
+
e.preventDefault();
|
|
232
|
+
}
|
|
233
|
+
};
|
|
234
|
+
var showFieldWithTheme = function showFieldWithTheme(name) {
|
|
235
|
+
var _theme$address3;
|
|
236
|
+
return !(theme !== null && theme !== void 0 && (_theme$address3 = theme.address) !== null && _theme$address3 !== void 0 && (_theme$address3 = _theme$address3.components) !== null && _theme$address3 !== void 0 && (_theme$address3 = _theme$address3[name]) !== null && _theme$address3 !== void 0 && _theme$address3.hidden);
|
|
237
|
+
};
|
|
238
|
+
var onSubmit = /*#__PURE__*/function () {
|
|
239
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
240
|
+
var _formState$changes3, _addressState$address6, _formState$changes4, _formState$changes5, _arrayList$map$some2;
|
|
241
|
+
var _formState$changes6, arrayList, addressToCompare, isAddressAlreadyExist;
|
|
242
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
243
|
+
while (1) switch (_context.prev = _context.next) {
|
|
244
|
+
case 0:
|
|
245
|
+
if (!(!auth && (formState === null || formState === void 0 || (_formState$changes3 = formState.changes) === null || _formState$changes3 === void 0 ? void 0 : _formState$changes3.address) === '' && addressState !== null && addressState !== void 0 && (_addressState$address6 = addressState.address) !== null && _addressState$address6 !== void 0 && _addressState$address6.address)) {
|
|
246
|
+
_context.next = 4;
|
|
247
|
+
break;
|
|
248
|
+
}
|
|
249
|
+
setAlertState({
|
|
250
|
+
open: true,
|
|
251
|
+
content: [t('VALIDATION_ERROR_ADDRESS_REQUIRED', 'The field Address is required')]
|
|
252
|
+
});
|
|
253
|
+
setLocationChange(null);
|
|
254
|
+
return _context.abrupt("return");
|
|
255
|
+
case 4:
|
|
256
|
+
if (!(formState !== null && formState !== void 0 && (_formState$changes4 = formState.changes) !== null && _formState$changes4 !== void 0 && _formState$changes4.address && !(formState !== null && formState !== void 0 && (_formState$changes5 = formState.changes) !== null && _formState$changes5 !== void 0 && _formState$changes5.location))) {
|
|
257
|
+
_context.next = 10;
|
|
258
|
+
break;
|
|
259
|
+
}
|
|
260
|
+
if (!isLocationRequired) {
|
|
261
|
+
_context.next = 8;
|
|
262
|
+
break;
|
|
263
|
+
}
|
|
264
|
+
setAlertState({
|
|
265
|
+
open: true,
|
|
266
|
+
content: [t('ADDRESS_REQUIRE_LOCATION', 'The address needs a location, please select one of the suggested')]
|
|
267
|
+
});
|
|
268
|
+
return _context.abrupt("return");
|
|
269
|
+
case 8:
|
|
270
|
+
getAddressFormatted(formState === null || formState === void 0 || (_formState$changes6 = formState.changes) === null || _formState$changes6 === void 0 ? void 0 : _formState$changes6.address);
|
|
271
|
+
return _context.abrupt("return");
|
|
272
|
+
case 10:
|
|
273
|
+
arrayList = isEditing ? (addressesList === null || addressesList === void 0 ? void 0 : addressesList.filter(function (address) {
|
|
274
|
+
var _addressState$address7;
|
|
275
|
+
return (address === null || address === void 0 ? void 0 : address.id) !== (addressState === null || addressState === void 0 || (_addressState$address7 = addressState.address) === null || _addressState$address7 === void 0 ? void 0 : _addressState$address7.id);
|
|
276
|
+
})) || [] : addressesList || [];
|
|
277
|
+
addressToCompare = isEditing ? _objectSpread(_objectSpread({}, addressState.address), formState.changes) : formState === null || formState === void 0 ? void 0 : formState.changes;
|
|
278
|
+
isAddressAlreadyExist = (_arrayList$map$some2 = arrayList.map(function (address) {
|
|
279
|
+
return checkAddress(address, addressToCompare);
|
|
280
|
+
}).some(function (value) {
|
|
281
|
+
return value;
|
|
282
|
+
})) !== null && _arrayList$map$some2 !== void 0 ? _arrayList$map$some2 : false;
|
|
283
|
+
if (isAddressAlreadyExist) {
|
|
284
|
+
_context.next = 18;
|
|
285
|
+
break;
|
|
286
|
+
}
|
|
287
|
+
_context.next = 16;
|
|
288
|
+
return saveAddress({}, userCustomerSetup);
|
|
289
|
+
case 16:
|
|
290
|
+
setAlertState({
|
|
291
|
+
open: true,
|
|
292
|
+
content: [t('ADDRESS_CAN_CLOSE_PAGE', 'Your address has been added, you can now close this page')]
|
|
293
|
+
});
|
|
294
|
+
return _context.abrupt("return");
|
|
295
|
+
case 18:
|
|
296
|
+
setAlertState({
|
|
297
|
+
open: true,
|
|
298
|
+
content: [t('ADDRESS_ALREADY_EXIST', 'The address already exists')]
|
|
299
|
+
});
|
|
300
|
+
case 19:
|
|
301
|
+
case "end":
|
|
302
|
+
return _context.stop();
|
|
303
|
+
}
|
|
304
|
+
}, _callee);
|
|
305
|
+
}));
|
|
306
|
+
return function onSubmit() {
|
|
307
|
+
return _ref2.apply(this, arguments);
|
|
308
|
+
};
|
|
309
|
+
}();
|
|
310
|
+
var handleAddressTag = function handleAddressTag(tag) {
|
|
311
|
+
setAddressTag(tag);
|
|
312
|
+
handleChangeInput({
|
|
313
|
+
target: {
|
|
314
|
+
name: 'tag',
|
|
315
|
+
value: tag
|
|
316
|
+
}
|
|
317
|
+
});
|
|
318
|
+
};
|
|
319
|
+
var handleChangeAddress = /*#__PURE__*/function () {
|
|
320
|
+
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(address, isGps) {
|
|
321
|
+
var _googleInputRef$curre;
|
|
322
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
323
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
324
|
+
case 0:
|
|
325
|
+
updateChanges(_objectSpread(_objectSpread({}, address), {}, {
|
|
326
|
+
address: isGps ? address === null || address === void 0 ? void 0 : address.address : (googleInputRef === null || googleInputRef === void 0 || (_googleInputRef$curre = googleInputRef.current) === null || _googleInputRef$curre === void 0 ? void 0 : _googleInputRef$curre.value) || (address === null || address === void 0 ? void 0 : address.address)
|
|
327
|
+
}));
|
|
328
|
+
if (isGps && googleInputRef.current) {
|
|
329
|
+
googleInputRef.current.value = address === null || address === void 0 ? void 0 : address.address;
|
|
330
|
+
}
|
|
331
|
+
setGeolocationState({
|
|
332
|
+
result: 'OK',
|
|
333
|
+
error: null
|
|
334
|
+
});
|
|
335
|
+
case 3:
|
|
336
|
+
case "end":
|
|
337
|
+
return _context2.stop();
|
|
338
|
+
}
|
|
339
|
+
}, _callee2);
|
|
340
|
+
}));
|
|
341
|
+
return function handleChangeAddress(_x, _x2) {
|
|
342
|
+
return _ref3.apply(this, arguments);
|
|
343
|
+
};
|
|
344
|
+
}();
|
|
345
|
+
var setMapErrors = function setMapErrors(errKey) {
|
|
346
|
+
setAlertState({
|
|
347
|
+
open: true,
|
|
348
|
+
content: !(errKey === 'ERROR_MAX_LIMIT_LOCATION') ? [t(errKey, mapErrors[errKey])] : "".concat([t(errKey, mapErrors[errKey])], " ").concat(maxLimitLocation, " ").concat([t('METTERS', 'meters')])
|
|
349
|
+
});
|
|
350
|
+
};
|
|
351
|
+
var onErrorGps = function onErrorGps(error) {
|
|
352
|
+
setGeolocationState({
|
|
353
|
+
result: null,
|
|
354
|
+
error: error
|
|
355
|
+
});
|
|
356
|
+
};
|
|
357
|
+
(0, _react.useEffect)(function () {
|
|
358
|
+
var _formState$result, _ref6, _formState$changes$ad3, _formState$changes9, _addressState$address8, _ref7, _formState$changes$ad4, _formState$changes10, _addressState$address9;
|
|
359
|
+
if (!auth) {
|
|
360
|
+
var _ref4, _formState$changes$lo2, _formState$changes7, _orderState$options, _ref5, _formState$changes$ad2, _formState$changes8, _orderState$options2;
|
|
361
|
+
setLocationChange((_ref4 = (_formState$changes$lo2 = formState === null || formState === void 0 || (_formState$changes7 = formState.changes) === null || _formState$changes7 === void 0 ? void 0 : _formState$changes7.location) !== null && _formState$changes$lo2 !== void 0 ? _formState$changes$lo2 : orderState === null || orderState === void 0 || (_orderState$options = orderState.options) === null || _orderState$options === void 0 || (_orderState$options = _orderState$options.address) === null || _orderState$options === void 0 ? void 0 : _orderState$options.location) !== null && _ref4 !== void 0 ? _ref4 : '');
|
|
362
|
+
setAddressValue((_ref5 = (_formState$changes$ad2 = formState === null || formState === void 0 || (_formState$changes8 = formState.changes) === null || _formState$changes8 === void 0 ? void 0 : _formState$changes8.address) !== null && _formState$changes$ad2 !== void 0 ? _formState$changes$ad2 : orderState === null || orderState === void 0 || (_orderState$options2 = orderState.options) === null || _orderState$options2 === void 0 || (_orderState$options2 = _orderState$options2.address) === null || _orderState$options2 === void 0 ? void 0 : _orderState$options2.address) !== null && _ref5 !== void 0 ? _ref5 : '');
|
|
363
|
+
inputNames.forEach(function (field) {
|
|
364
|
+
var _orderState$options3, _orderState$options4;
|
|
365
|
+
return formMethods.setValue(field.name, (formState === null || formState === void 0 ? void 0 : formState.changes[field.name]) || (orderState === null || orderState === void 0 || (_orderState$options3 = orderState.options) === null || _orderState$options3 === void 0 ? void 0 : _orderState$options3.address) && (orderState === null || orderState === void 0 || (_orderState$options4 = orderState.options) === null || _orderState$options4 === void 0 ? void 0 : _orderState$options4.address[field.name]) || '');
|
|
366
|
+
});
|
|
367
|
+
return;
|
|
368
|
+
}
|
|
369
|
+
if (!formState.loading && (_formState$result = formState.result) !== null && _formState$result !== void 0 && _formState$result.error) {
|
|
370
|
+
var _formState$result2;
|
|
371
|
+
setAlertState({
|
|
372
|
+
open: true,
|
|
373
|
+
content: ((_formState$result2 = formState.result) === null || _formState$result2 === void 0 ? void 0 : _formState$result2.result) || [t('ERROR', 'Error')]
|
|
374
|
+
});
|
|
375
|
+
}
|
|
376
|
+
setAddressValue((_ref6 = (_formState$changes$ad3 = formState === null || formState === void 0 || (_formState$changes9 = formState.changes) === null || _formState$changes9 === void 0 ? void 0 : _formState$changes9.address) !== null && _formState$changes$ad3 !== void 0 ? _formState$changes$ad3 : (_addressState$address8 = addressState.address) === null || _addressState$address8 === void 0 ? void 0 : _addressState$address8.address) !== null && _ref6 !== void 0 ? _ref6 : '');
|
|
377
|
+
formMethods.setValue('address', (_ref7 = (_formState$changes$ad4 = formState === null || formState === void 0 || (_formState$changes10 = formState.changes) === null || _formState$changes10 === void 0 ? void 0 : _formState$changes10.address) !== null && _formState$changes$ad4 !== void 0 ? _formState$changes$ad4 : (_addressState$address9 = addressState.address) === null || _addressState$address9 === void 0 ? void 0 : _addressState$address9.address) !== null && _ref7 !== void 0 ? _ref7 : '');
|
|
378
|
+
if (!isEditing) {
|
|
379
|
+
var _formState$changes11, _formState$changes12, _formState$changes13, _formState$changes14, _formState$changes15, _formState$changes16, _firstLocationNoEdit$, _formState$changes17, _firstLocationNoEdit$2;
|
|
380
|
+
inputNames.forEach(function (field) {
|
|
381
|
+
return formMethods.setValue(field.name, (formState === null || formState === void 0 ? void 0 : formState.changes[field.name]) || '');
|
|
382
|
+
});
|
|
383
|
+
(formState === null || formState === void 0 || (_formState$changes11 = formState.changes) === null || _formState$changes11 === void 0 ? void 0 : _formState$changes11.address) && setLocationChange(formState === null || formState === void 0 || (_formState$changes12 = formState.changes) === null || _formState$changes12 === void 0 ? void 0 : _formState$changes12.location);
|
|
384
|
+
if (formState !== null && formState !== void 0 && (_formState$changes13 = formState.changes) !== null && _formState$changes13 !== void 0 && _formState$changes13.address && (formState === null || formState === void 0 || (_formState$changes14 = formState.changes) === null || _formState$changes14 === void 0 ? void 0 : _formState$changes14.address) !== (firstLocationNoEdit === null || firstLocationNoEdit === void 0 ? void 0 : firstLocationNoEdit.address) && formState !== null && formState !== void 0 && (_formState$changes15 = formState.changes) !== null && _formState$changes15 !== void 0 && _formState$changes15.location && (formState === null || formState === void 0 || (_formState$changes16 = formState.changes) === null || _formState$changes16 === void 0 || (_formState$changes16 = _formState$changes16.location) === null || _formState$changes16 === void 0 ? void 0 : _formState$changes16.lat) !== ((_firstLocationNoEdit$ = firstLocationNoEdit.value) === null || _firstLocationNoEdit$ === void 0 ? void 0 : _firstLocationNoEdit$.lat) && (formState === null || formState === void 0 || (_formState$changes17 = formState.changes) === null || _formState$changes17 === void 0 || (_formState$changes17 = _formState$changes17.location) === null || _formState$changes17 === void 0 ? void 0 : _formState$changes17.lng) !== ((_firstLocationNoEdit$2 = firstLocationNoEdit.value) === null || _firstLocationNoEdit$2 === void 0 ? void 0 : _firstLocationNoEdit$2.lng)) {
|
|
385
|
+
var _formState$changes18, _formState$changes19;
|
|
386
|
+
setFirstLocationNoEdit({
|
|
387
|
+
value: formState === null || formState === void 0 || (_formState$changes18 = formState.changes) === null || _formState$changes18 === void 0 ? void 0 : _formState$changes18.location,
|
|
388
|
+
address: formState === null || formState === void 0 || (_formState$changes19 = formState.changes) === null || _formState$changes19 === void 0 ? void 0 : _formState$changes19.address
|
|
389
|
+
});
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
if (isEditing) {
|
|
393
|
+
var _formState$changes20;
|
|
394
|
+
if (formState !== null && formState !== void 0 && (_formState$changes20 = formState.changes) !== null && _formState$changes20 !== void 0 && _formState$changes20.location) {
|
|
395
|
+
var _formState$changes21, _formState$changes22;
|
|
396
|
+
var prevLocation = {
|
|
397
|
+
lat: Math.trunc(locationChange === null || locationChange === void 0 ? void 0 : locationChange.lat),
|
|
398
|
+
lng: Math.trunc(locationChange === null || locationChange === void 0 ? void 0 : locationChange.lng)
|
|
399
|
+
};
|
|
400
|
+
var newLocation = {
|
|
401
|
+
lat: Math.trunc(formState === null || formState === void 0 || (_formState$changes21 = formState.changes) === null || _formState$changes21 === void 0 || (_formState$changes21 = _formState$changes21.location) === null || _formState$changes21 === void 0 ? void 0 : _formState$changes21.lat),
|
|
402
|
+
lng: Math.trunc(formState === null || formState === void 0 || (_formState$changes22 = formState.changes) === null || _formState$changes22 === void 0 || (_formState$changes22 = _formState$changes22.location) === null || _formState$changes22 === void 0 ? void 0 : _formState$changes22.lng)
|
|
403
|
+
};
|
|
404
|
+
if (prevLocation.lat !== newLocation.lat && prevLocation.lng !== newLocation.lng) {
|
|
405
|
+
var _formState$changes23;
|
|
406
|
+
setLocationChange(formState === null || formState === void 0 || (_formState$changes23 = formState.changes) === null || _formState$changes23 === void 0 ? void 0 : _formState$changes23.location);
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
}, [formState]);
|
|
411
|
+
(0, _react.useEffect)(function () {
|
|
412
|
+
if (isEditing) {
|
|
413
|
+
var _addressState$address10;
|
|
414
|
+
setIsEdit && setIsEdit(true);
|
|
415
|
+
setAddressValue((_addressState$address10 = addressState.address) === null || _addressState$address10 === void 0 ? void 0 : _addressState$address10.address);
|
|
416
|
+
} else {
|
|
417
|
+
setIsEdit && setIsEdit(false);
|
|
418
|
+
}
|
|
419
|
+
}, [addressState]);
|
|
420
|
+
(0, _react.useEffect)(function () {
|
|
421
|
+
if (!auth) {
|
|
422
|
+
var _ref8, _formState$changes$lo3, _formState$changes24, _orderState$options5;
|
|
423
|
+
setLocationChange((_ref8 = (_formState$changes$lo3 = formState === null || formState === void 0 || (_formState$changes24 = formState.changes) === null || _formState$changes24 === void 0 ? void 0 : _formState$changes24.location) !== null && _formState$changes$lo3 !== void 0 ? _formState$changes$lo3 : orderState === null || orderState === void 0 || (_orderState$options5 = orderState.options) === null || _orderState$options5 === void 0 || (_orderState$options5 = _orderState$options5.address) === null || _orderState$options5 === void 0 ? void 0 : _orderState$options5.location) !== null && _ref8 !== void 0 ? _ref8 : '');
|
|
424
|
+
}
|
|
425
|
+
return function () {
|
|
426
|
+
setFirstLocationNoEdit({
|
|
427
|
+
value: null
|
|
428
|
+
});
|
|
429
|
+
};
|
|
430
|
+
}, []);
|
|
431
|
+
|
|
432
|
+
/** Form events control */
|
|
433
|
+
|
|
434
|
+
(0, _react.useEffect)(function () {
|
|
435
|
+
if (Object.keys(formMethods.errors).length > 0) {
|
|
436
|
+
setAlertState({
|
|
437
|
+
open: true,
|
|
438
|
+
content: Object.values(formMethods.errors).map(function (error) {
|
|
439
|
+
return error.message;
|
|
440
|
+
})
|
|
441
|
+
});
|
|
442
|
+
}
|
|
443
|
+
}, [formMethods.errors]);
|
|
444
|
+
(0, _react.useEffect)(function () {
|
|
445
|
+
inputNames.forEach(function (field) {
|
|
446
|
+
var _ref9, _formState$changes$fi, _formState$changes25, _addressState$address11;
|
|
447
|
+
formMethods.register(field.name, {
|
|
448
|
+
required: isRequiredField(field.name) ? t("VALIDATION_ERROR_".concat(field.name, "_REQUIRED"), "The field ".concat(field.code, " is required")) : null
|
|
449
|
+
});
|
|
450
|
+
formMethods.setValue(field.name, (_ref9 = (_formState$changes$fi = (_formState$changes25 = formState.changes) === null || _formState$changes25 === void 0 ? void 0 : _formState$changes25[field.name]) !== null && _formState$changes$fi !== void 0 ? _formState$changes$fi : (_addressState$address11 = addressState.address) === null || _addressState$address11 === void 0 ? void 0 : _addressState$address11[field.name]) !== null && _ref9 !== void 0 ? _ref9 : '');
|
|
451
|
+
});
|
|
452
|
+
}, [formMethods]);
|
|
453
|
+
(0, _react.useEffect)(function () {
|
|
454
|
+
var _window$navigator;
|
|
455
|
+
if (!((_window$navigator = window.navigator) !== null && _window$navigator !== void 0 && _window$navigator.geolocation)) {
|
|
456
|
+
setGeolocationState({
|
|
457
|
+
result: null,
|
|
458
|
+
error: t('GEOLOCATION_NOT_SUPPORTED_BROWSER', 'Geolocation not supported in your browser')
|
|
459
|
+
});
|
|
460
|
+
}
|
|
461
|
+
}, [(_navigator = navigator) === null || _navigator === void 0 ? void 0 : _navigator.geolocation]);
|
|
462
|
+
return /*#__PURE__*/_react.default.createElement(_styles.AddressFormContainer, null, /*#__PURE__*/_react.default.createElement("h1", null, t('ADD_YOUR_ADDRESS', 'Add your address')), /*#__PURE__*/_react.default.createElement("div", {
|
|
463
|
+
className: "address-form"
|
|
464
|
+
}, (configState.loading || addressState.loading) && /*#__PURE__*/_react.default.createElement(_styles.WrapperSkeleton, null, /*#__PURE__*/_react.default.createElement(_reactLoadingSkeleton.default, {
|
|
465
|
+
height: 50,
|
|
466
|
+
count: 5,
|
|
467
|
+
style: {
|
|
468
|
+
marginBottom: '10px'
|
|
469
|
+
}
|
|
470
|
+
})), !configState.loading && !addressState.loading && /*#__PURE__*/_react.default.createElement("div", null, /*#__PURE__*/_react.default.createElement(_styles.FormControl, {
|
|
471
|
+
onSubmit: formMethods.handleSubmit(onSubmit),
|
|
472
|
+
onKeyDown: function onKeyDown(e) {
|
|
473
|
+
return checkKeyDown(e);
|
|
474
|
+
},
|
|
475
|
+
autoComplete: "off"
|
|
476
|
+
}, inputNames.map(function (field) {
|
|
477
|
+
var _addressState$address12, _formState$changes26, _formState$result3, _formState$result4, _formState$changes$ad5, _formState$changes27, _configState$configs5, _addressState$address13, _formState$changes28, _addressState$address14, _formState$changes29, _ref10, _formState$changes$fi2, _formState$changes30, _addressState$address15, _ref11, _formState$changes$ad6, _formState$changes31;
|
|
478
|
+
return showField && showField(field.name) && (field.name === 'address' ? /*#__PURE__*/_react.default.createElement(_react.default.Fragment, {
|
|
479
|
+
key: field.name
|
|
480
|
+
}, /*#__PURE__*/_react.default.createElement(_styles.AddressWrap, {
|
|
481
|
+
className: "google-control"
|
|
482
|
+
}, /*#__PURE__*/_react.default.createElement(_styles.WrapAddressInput, null, !(addressState !== null && addressState !== void 0 && (_addressState$address12 = addressState.address) !== null && _addressState$address12 !== void 0 && _addressState$address12.location || formState !== null && formState !== void 0 && (_formState$changes26 = formState.changes) !== null && _formState$changes26 !== void 0 && _formState$changes26.location) && /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, !(geolocationState !== null && geolocationState !== void 0 && geolocationState.result) && !(geolocationState !== null && geolocationState !== void 0 && geolocationState.error) && /*#__PURE__*/_react.default.createElement(_styles.AddressMarkContainer, null, /*#__PURE__*/_react.default.createElement("p", null, t('GEOCALITION_PLEASE_ACCEPT_PERMISSIONS', 'We are geolocating you, please accept the permissions'))), (geolocationState === null || geolocationState === void 0 ? void 0 : geolocationState.error) && /*#__PURE__*/_react.default.createElement(_styles.AddressMarkContainer, {
|
|
483
|
+
error: true
|
|
484
|
+
}, /*#__PURE__*/_react.default.createElement("p", null, geolocationState === null || geolocationState === void 0 ? void 0 : geolocationState.error))), /*#__PURE__*/_react.default.createElement(_orderingComponentsExternal.GoogleAutocompleteInput, {
|
|
485
|
+
className: "input-autocomplete",
|
|
486
|
+
apiKey: googleMapsApiKey,
|
|
487
|
+
placeholder: t('ADDRESS', 'Address'),
|
|
488
|
+
onChangeAddress: function onChangeAddress(e) {
|
|
489
|
+
formMethods.setValue('address', e.address);
|
|
490
|
+
handleChangeAddress(e);
|
|
491
|
+
},
|
|
492
|
+
onChange: function onChange(e) {
|
|
493
|
+
handleChangeInput({
|
|
494
|
+
target: {
|
|
495
|
+
name: 'address',
|
|
496
|
+
value: e.target.value
|
|
497
|
+
}
|
|
498
|
+
});
|
|
499
|
+
setAddressValue(e.target.value);
|
|
500
|
+
},
|
|
501
|
+
childRef: function childRef(ref) {
|
|
502
|
+
googleInputRef.current = ref;
|
|
503
|
+
},
|
|
504
|
+
defaultValue: formState !== null && formState !== void 0 && (_formState$result3 = formState.result) !== null && _formState$result3 !== void 0 && _formState$result3.result ? formState === null || formState === void 0 || (_formState$result4 = formState.result) === null || _formState$result4 === void 0 || (_formState$result4 = _formState$result4.result) === null || _formState$result4 === void 0 ? void 0 : _formState$result4.address : (_formState$changes$ad5 = formState === null || formState === void 0 || (_formState$changes27 = formState.changes) === null || _formState$changes27 === void 0 ? void 0 : _formState$changes27.address) !== null && _formState$changes$ad5 !== void 0 ? _formState$changes$ad5 : addressValue,
|
|
505
|
+
autoComplete: "new-password",
|
|
506
|
+
countryCode: (configState === null || configState === void 0 || (_configState$configs5 = configState.configs) === null || _configState$configs5 === void 0 || (_configState$configs5 = _configState$configs5.country_autocomplete) === null || _configState$configs5 === void 0 ? void 0 : _configState$configs5.value) || '*'
|
|
507
|
+
})), /*#__PURE__*/_react.default.createElement(_GoogleGpsButton.GoogleGpsButton, {
|
|
508
|
+
enableAutoGeolocation: true,
|
|
509
|
+
className: "gps-button",
|
|
510
|
+
apiKey: googleMapsApiKey,
|
|
511
|
+
onAddress: function onAddress(e) {
|
|
512
|
+
formMethods.setValue('address', e.address);
|
|
513
|
+
handleChangeAddress(e, true);
|
|
514
|
+
},
|
|
515
|
+
onError: onErrorGps,
|
|
516
|
+
IconButton: _reactBootstrapIcons.GeoAlt,
|
|
517
|
+
IconLoadingButton: _CgSearchLoading.default,
|
|
518
|
+
geolocationState: geolocationState,
|
|
519
|
+
location: (addressState === null || addressState === void 0 || (_addressState$address13 = addressState.address) === null || _addressState$address13 === void 0 ? void 0 : _addressState$address13.location) || (formState === null || formState === void 0 || (_formState$changes28 = formState.changes) === null || _formState$changes28 === void 0 ? void 0 : _formState$changes28.location)
|
|
520
|
+
})), /*#__PURE__*/_react.default.createElement(_styles.WrapperMap, {
|
|
521
|
+
height: Math.ceil(window.innerHeight * 0.31)
|
|
522
|
+
}, !isHideMap && locationChange && (addressState !== null && addressState !== void 0 && (_addressState$address14 = addressState.address) !== null && _addressState$address14 !== void 0 && _addressState$address14.location || formState !== null && formState !== void 0 && (_formState$changes29 = formState.changes) !== null && _formState$changes29 !== void 0 && _formState$changes29.location) ? /*#__PURE__*/_react.default.createElement(_orderingComponentsExternal.GoogleMapsMap, {
|
|
523
|
+
apiKey: googleMapsApiKey,
|
|
524
|
+
location: locationChange,
|
|
525
|
+
fixedLocation: !isEditing ? firstLocationNoEdit.value : null,
|
|
526
|
+
mapControls: googleMapsControls,
|
|
527
|
+
handleChangeAddressMap: handleChangeAddress,
|
|
528
|
+
setErrors: setMapErrors,
|
|
529
|
+
maxLimitLocation: parseInt(maxLimitLocation, 10)
|
|
530
|
+
}) : /*#__PURE__*/_react.default.createElement(_reactLoadingSkeleton.default, {
|
|
531
|
+
height: Math.ceil(window.innerHeight * 0.31)
|
|
532
|
+
}))) : /*#__PURE__*/_react.default.createElement(_react.default.Fragment, {
|
|
533
|
+
key: field.name
|
|
534
|
+
}, (isRequiredField(field.name) || showFieldWithTheme(field.name)) && /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, field.name !== 'address_notes' ? /*#__PURE__*/_react.default.createElement(_Inputs.Input, {
|
|
535
|
+
className: field.name,
|
|
536
|
+
placeholder: t(field.name.toUpperCase(), field.code),
|
|
537
|
+
value: (_ref10 = (_formState$changes$fi2 = (_formState$changes30 = formState.changes) === null || _formState$changes30 === void 0 ? void 0 : _formState$changes30[field.name]) !== null && _formState$changes$fi2 !== void 0 ? _formState$changes$fi2 : (_addressState$address15 = addressState.address) === null || _addressState$address15 === void 0 ? void 0 : _addressState$address15[field.name]) !== null && _ref10 !== void 0 ? _ref10 : '',
|
|
538
|
+
onChange: function onChange(e) {
|
|
539
|
+
formMethods.setValue(field.name, e.target.value);
|
|
540
|
+
handleChangeInput({
|
|
541
|
+
target: {
|
|
542
|
+
name: field.name,
|
|
543
|
+
value: e.target.value
|
|
544
|
+
}
|
|
545
|
+
});
|
|
546
|
+
},
|
|
547
|
+
autoComplete: "new-field",
|
|
548
|
+
maxLength: 30
|
|
549
|
+
}) : /*#__PURE__*/_react.default.createElement(_Inputs.TextArea, {
|
|
550
|
+
rows: 3,
|
|
551
|
+
placeholder: t('ADDRESS_NOTES', 'Address Notes'),
|
|
552
|
+
value: (_ref11 = (_formState$changes$ad6 = (_formState$changes31 = formState.changes) === null || _formState$changes31 === void 0 ? void 0 : _formState$changes31.address_notes) !== null && _formState$changes$ad6 !== void 0 ? _formState$changes$ad6 : addressState.address.address_notes) !== null && _ref11 !== void 0 ? _ref11 : '',
|
|
553
|
+
onChange: function onChange(e) {
|
|
554
|
+
formMethods.setValue('address_notes', e.target.value);
|
|
555
|
+
handleChangeInput({
|
|
556
|
+
target: {
|
|
557
|
+
name: 'address_notes',
|
|
558
|
+
value: e.target.value
|
|
559
|
+
}
|
|
560
|
+
});
|
|
561
|
+
},
|
|
562
|
+
autoComplete: "new-field",
|
|
563
|
+
maxLength: 250
|
|
564
|
+
}))));
|
|
565
|
+
}), !formState.loading && formState.error && /*#__PURE__*/_react.default.createElement("p", {
|
|
566
|
+
style: {
|
|
567
|
+
color: '#c10000'
|
|
568
|
+
}
|
|
569
|
+
}, formState.error), !isHideIcons && /*#__PURE__*/_react.default.createElement(_styles.AddressTagSection, null, /*#__PURE__*/_react.default.createElement(_Buttons.Button, {
|
|
570
|
+
className: addressTag === 'home' ? 'active' : '',
|
|
571
|
+
bgtransparent: true,
|
|
572
|
+
type: "button",
|
|
573
|
+
onClick: function onClick() {
|
|
574
|
+
return handleAddressTag('home');
|
|
575
|
+
}
|
|
576
|
+
}, /*#__PURE__*/_react.default.createElement("span", null, /*#__PURE__*/_react.default.createElement(_reactBootstrapIcons.House, null))), /*#__PURE__*/_react.default.createElement(_Buttons.Button, {
|
|
577
|
+
className: addressTag === 'office' ? 'active' : '',
|
|
578
|
+
bgtransparent: true,
|
|
579
|
+
type: "button",
|
|
580
|
+
onClick: function onClick() {
|
|
581
|
+
return handleAddressTag('office');
|
|
582
|
+
}
|
|
583
|
+
}, /*#__PURE__*/_react.default.createElement("span", null, /*#__PURE__*/_react.default.createElement(_reactBootstrapIcons.Building, null))), /*#__PURE__*/_react.default.createElement(_Buttons.Button, {
|
|
584
|
+
className: addressTag === 'favorite' ? 'active' : '',
|
|
585
|
+
bgtransparent: true,
|
|
586
|
+
type: "button",
|
|
587
|
+
onClick: function onClick() {
|
|
588
|
+
return handleAddressTag('favorite');
|
|
589
|
+
}
|
|
590
|
+
}, /*#__PURE__*/_react.default.createElement("span", null, /*#__PURE__*/_react.default.createElement(_reactBootstrapIcons.Heart, null))), /*#__PURE__*/_react.default.createElement(_Buttons.Button, {
|
|
591
|
+
className: addressTag === 'other' ? 'active' : '',
|
|
592
|
+
bgtransparent: true,
|
|
593
|
+
type: "button",
|
|
594
|
+
onClick: function onClick() {
|
|
595
|
+
return handleAddressTag('other');
|
|
596
|
+
}
|
|
597
|
+
}, /*#__PURE__*/_react.default.createElement("span", null, /*#__PURE__*/_react.default.createElement(_reactBootstrapIcons.PlusLg, null)))), /*#__PURE__*/_react.default.createElement(_styles.FormActions, null, Object.keys(formState === null || formState === void 0 ? void 0 : formState.changes).length > 0 && /*#__PURE__*/_react.default.createElement(_Buttons.Button, {
|
|
598
|
+
id: "submit-btn",
|
|
599
|
+
type: "submit",
|
|
600
|
+
disabled: formState.loading,
|
|
601
|
+
color: "primary"
|
|
602
|
+
}, !formState.loading ? /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, t('ADD_ADDRESS', 'Add address')) : t('LOADING', 'Loading'))))), /*#__PURE__*/_react.default.createElement(_Confirm.Alert, {
|
|
603
|
+
title: t('ADDRESS', 'Address'),
|
|
604
|
+
content: alertState.content,
|
|
605
|
+
acceptText: t('ACCEPT', 'Accept'),
|
|
606
|
+
open: alertState.open,
|
|
607
|
+
onClose: function onClose() {
|
|
608
|
+
return closeAlert();
|
|
609
|
+
},
|
|
610
|
+
onAccept: function onAccept() {
|
|
611
|
+
return closeAlert();
|
|
612
|
+
},
|
|
613
|
+
closeOnBackdrop: false
|
|
614
|
+
})));
|
|
615
|
+
};
|
|
616
|
+
var ConfirmAddressForm = exports.ConfirmAddressForm = function ConfirmAddressForm(props) {
|
|
617
|
+
var googleMapsControls = {
|
|
618
|
+
defaultZoom: 17,
|
|
619
|
+
zoomControl: true,
|
|
620
|
+
streetViewControl: false,
|
|
621
|
+
fullscreenControl: false,
|
|
622
|
+
mapTypeId: 'roadmap',
|
|
623
|
+
// 'roadmap', 'satellite', 'hybrid', 'terrain'
|
|
624
|
+
mapTypeControl: true,
|
|
625
|
+
mapTypeControlOptions: {
|
|
626
|
+
mapTypeIds: ['roadmap', 'satellite']
|
|
627
|
+
},
|
|
628
|
+
isMarkerDraggable: true
|
|
629
|
+
};
|
|
630
|
+
var addressFormProps = _objectSpread(_objectSpread({}, props), {}, {
|
|
631
|
+
UIComponent: ConfirmAddressFormUI,
|
|
632
|
+
googleMapsControls: googleMapsControls,
|
|
633
|
+
isSelectedAfterAdd: false,
|
|
634
|
+
confirmAddress: true,
|
|
635
|
+
avoidRefreshUserInfo: true
|
|
636
|
+
});
|
|
637
|
+
return /*#__PURE__*/_react.default.createElement(_orderingComponentsExternal.AddressForm, addressFormProps);
|
|
638
|
+
};
|