@heycater/qualification-funnel 1.3.17 → 1.3.19

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.esm.js CHANGED
@@ -12449,7 +12449,7 @@ var objectInspect = function inspect_(obj, options, depth, seen) {
12449
12449
  var ys = arrObjKeys(obj, inspect2);
12450
12450
  var isPlainObject2 = gPO ? gPO(obj) === Object.prototype : obj instanceof Object || obj.constructor === Object;
12451
12451
  var protoTag = obj instanceof Object ? "" : "null prototype";
12452
- var stringTag2 = !isPlainObject2 && toStringTag && Object(obj) === obj && toStringTag in obj ? $slice.call(toStr(obj), 8, -1) : protoTag ? "Object" : "";
12452
+ var stringTag2 = !isPlainObject2 && toStringTag && Object(obj) === obj && toStringTag in obj ? $slice.call(toStr$1(obj), 8, -1) : protoTag ? "Object" : "";
12453
12453
  var constructorTag = isPlainObject2 || typeof obj.constructor !== "function" ? "" : obj.constructor.name ? obj.constructor.name + " " : "";
12454
12454
  var tag = constructorTag + (stringTag2 || protoTag ? "[" + $join.call($concat$1.call([], stringTag2 || [], protoTag || []), ": ") + "] " : "");
12455
12455
  if (ys.length === 0) {
@@ -12474,25 +12474,25 @@ function canTrustToString(obj) {
12474
12474
  return !toStringTag || !(typeof obj === "object" && (toStringTag in obj || typeof obj[toStringTag] !== "undefined"));
12475
12475
  }
12476
12476
  function isArray$2(obj) {
12477
- return toStr(obj) === "[object Array]" && canTrustToString(obj);
12477
+ return toStr$1(obj) === "[object Array]" && canTrustToString(obj);
12478
12478
  }
12479
12479
  function isDate(obj) {
12480
- return toStr(obj) === "[object Date]" && canTrustToString(obj);
12480
+ return toStr$1(obj) === "[object Date]" && canTrustToString(obj);
12481
12481
  }
12482
12482
  function isRegExp$1(obj) {
12483
- return toStr(obj) === "[object RegExp]" && canTrustToString(obj);
12483
+ return toStr$1(obj) === "[object RegExp]" && canTrustToString(obj);
12484
12484
  }
12485
12485
  function isError(obj) {
12486
- return toStr(obj) === "[object Error]" && canTrustToString(obj);
12486
+ return toStr$1(obj) === "[object Error]" && canTrustToString(obj);
12487
12487
  }
12488
12488
  function isString(obj) {
12489
- return toStr(obj) === "[object String]" && canTrustToString(obj);
12489
+ return toStr$1(obj) === "[object String]" && canTrustToString(obj);
12490
12490
  }
12491
12491
  function isNumber(obj) {
12492
- return toStr(obj) === "[object Number]" && canTrustToString(obj);
12492
+ return toStr$1(obj) === "[object Number]" && canTrustToString(obj);
12493
12493
  }
12494
12494
  function isBoolean(obj) {
12495
- return toStr(obj) === "[object Boolean]" && canTrustToString(obj);
12495
+ return toStr$1(obj) === "[object Boolean]" && canTrustToString(obj);
12496
12496
  }
12497
12497
  function isSymbol(obj) {
12498
12498
  if (hasShammedSymbols) {
@@ -12528,7 +12528,7 @@ var hasOwn$1 = Object.prototype.hasOwnProperty || function(key) {
12528
12528
  function has$3(obj, key) {
12529
12529
  return hasOwn$1.call(obj, key);
12530
12530
  }
12531
- function toStr(obj) {
12531
+ function toStr$1(obj) {
12532
12532
  return objectToString.call(obj);
12533
12533
  }
12534
12534
  function nameOf(f) {
@@ -12837,7 +12837,7 @@ var syntax = SyntaxError;
12837
12837
  var uri = URIError;
12838
12838
  var abs$1 = Math.abs;
12839
12839
  var floor$1 = Math.floor;
12840
- var max$1 = Math.max;
12840
+ var max$2 = Math.max;
12841
12841
  var min$1 = Math.min;
12842
12842
  var pow$1 = Math.pow;
12843
12843
  var round$2 = Math.round;
@@ -12966,91 +12966,77 @@ function requireObject_getPrototypeOf() {
12966
12966
  Object_getPrototypeOf = $Object2.getPrototypeOf || null;
12967
12967
  return Object_getPrototypeOf;
12968
12968
  }
12969
- var implementation;
12970
- var hasRequiredImplementation;
12971
- function requireImplementation() {
12972
- if (hasRequiredImplementation) return implementation;
12973
- hasRequiredImplementation = 1;
12974
- var ERROR_MESSAGE = "Function.prototype.bind called on incompatible ";
12975
- var toStr2 = Object.prototype.toString;
12976
- var max2 = Math.max;
12977
- var funcType = "[object Function]";
12978
- var concatty = function concatty2(a3, b2) {
12979
- var arr = [];
12980
- for (var i2 = 0; i2 < a3.length; i2 += 1) {
12981
- arr[i2] = a3[i2];
12982
- }
12983
- for (var j = 0; j < b2.length; j += 1) {
12984
- arr[j + a3.length] = b2[j];
12985
- }
12986
- return arr;
12987
- };
12988
- var slicy = function slicy2(arrLike, offset2) {
12989
- var arr = [];
12990
- for (var i2 = offset2, j = 0; i2 < arrLike.length; i2 += 1, j += 1) {
12991
- arr[j] = arrLike[i2];
12992
- }
12993
- return arr;
12994
- };
12995
- var joiny = function(arr, joiner) {
12996
- var str = "";
12997
- for (var i2 = 0; i2 < arr.length; i2 += 1) {
12998
- str += arr[i2];
12999
- if (i2 + 1 < arr.length) {
13000
- str += joiner;
13001
- }
12969
+ var ERROR_MESSAGE = "Function.prototype.bind called on incompatible ";
12970
+ var toStr = Object.prototype.toString;
12971
+ var max$1 = Math.max;
12972
+ var funcType = "[object Function]";
12973
+ var concatty = function concatty2(a3, b2) {
12974
+ var arr = [];
12975
+ for (var i2 = 0; i2 < a3.length; i2 += 1) {
12976
+ arr[i2] = a3[i2];
12977
+ }
12978
+ for (var j = 0; j < b2.length; j += 1) {
12979
+ arr[j + a3.length] = b2[j];
12980
+ }
12981
+ return arr;
12982
+ };
12983
+ var slicy = function slicy2(arrLike, offset2) {
12984
+ var arr = [];
12985
+ for (var i2 = offset2, j = 0; i2 < arrLike.length; i2 += 1, j += 1) {
12986
+ arr[j] = arrLike[i2];
12987
+ }
12988
+ return arr;
12989
+ };
12990
+ var joiny = function(arr, joiner) {
12991
+ var str = "";
12992
+ for (var i2 = 0; i2 < arr.length; i2 += 1) {
12993
+ str += arr[i2];
12994
+ if (i2 + 1 < arr.length) {
12995
+ str += joiner;
13002
12996
  }
13003
- return str;
13004
- };
13005
- implementation = function bind2(that) {
13006
- var target = this;
13007
- if (typeof target !== "function" || toStr2.apply(target) !== funcType) {
13008
- throw new TypeError(ERROR_MESSAGE + target);
13009
- }
13010
- var args = slicy(arguments, 1);
13011
- var bound;
13012
- var binder = function() {
13013
- if (this instanceof bound) {
13014
- var result = target.apply(
13015
- this,
13016
- concatty(args, arguments)
13017
- );
13018
- if (Object(result) === result) {
13019
- return result;
13020
- }
13021
- return this;
13022
- }
13023
- return target.apply(
13024
- that,
12997
+ }
12998
+ return str;
12999
+ };
13000
+ var implementation$1 = function bind(that) {
13001
+ var target = this;
13002
+ if (typeof target !== "function" || toStr.apply(target) !== funcType) {
13003
+ throw new TypeError(ERROR_MESSAGE + target);
13004
+ }
13005
+ var args = slicy(arguments, 1);
13006
+ var bound;
13007
+ var binder = function() {
13008
+ if (this instanceof bound) {
13009
+ var result = target.apply(
13010
+ this,
13025
13011
  concatty(args, arguments)
13026
13012
  );
13027
- };
13028
- var boundLength = max2(0, target.length - args.length);
13029
- var boundArgs = [];
13030
- for (var i2 = 0; i2 < boundLength; i2++) {
13031
- boundArgs[i2] = "$" + i2;
13032
- }
13033
- bound = Function("binder", "return function (" + joiny(boundArgs, ",") + "){ return binder.apply(this,arguments); }")(binder);
13034
- if (target.prototype) {
13035
- var Empty = function Empty2() {
13036
- };
13037
- Empty.prototype = target.prototype;
13038
- bound.prototype = new Empty();
13039
- Empty.prototype = null;
13013
+ if (Object(result) === result) {
13014
+ return result;
13015
+ }
13016
+ return this;
13040
13017
  }
13041
- return bound;
13018
+ return target.apply(
13019
+ that,
13020
+ concatty(args, arguments)
13021
+ );
13042
13022
  };
13043
- return implementation;
13044
- }
13045
- var functionBind;
13046
- var hasRequiredFunctionBind;
13047
- function requireFunctionBind() {
13048
- if (hasRequiredFunctionBind) return functionBind;
13049
- hasRequiredFunctionBind = 1;
13050
- var implementation2 = requireImplementation();
13051
- functionBind = Function.prototype.bind || implementation2;
13052
- return functionBind;
13053
- }
13023
+ var boundLength = max$1(0, target.length - args.length);
13024
+ var boundArgs = [];
13025
+ for (var i2 = 0; i2 < boundLength; i2++) {
13026
+ boundArgs[i2] = "$" + i2;
13027
+ }
13028
+ bound = Function("binder", "return function (" + joiny(boundArgs, ",") + "){ return binder.apply(this,arguments); }")(binder);
13029
+ if (target.prototype) {
13030
+ var Empty = function Empty2() {
13031
+ };
13032
+ Empty.prototype = target.prototype;
13033
+ bound.prototype = new Empty();
13034
+ Empty.prototype = null;
13035
+ }
13036
+ return bound;
13037
+ };
13038
+ var implementation = implementation$1;
13039
+ var functionBind = Function.prototype.bind || implementation;
13054
13040
  var functionCall = Function.prototype.call;
13055
13041
  var functionApply;
13056
13042
  var hasRequiredFunctionApply;
@@ -13061,12 +13047,12 @@ function requireFunctionApply() {
13061
13047
  return functionApply;
13062
13048
  }
13063
13049
  var reflectApply = typeof Reflect !== "undefined" && Reflect && Reflect.apply;
13064
- var bind$2 = requireFunctionBind();
13050
+ var bind$2 = functionBind;
13065
13051
  var $apply$1 = requireFunctionApply();
13066
13052
  var $call$2 = functionCall;
13067
13053
  var $reflectApply = reflectApply;
13068
13054
  var actualApply = $reflectApply || bind$2.call($call$2, $apply$1);
13069
- var bind$1 = requireFunctionBind();
13055
+ var bind$1 = functionBind;
13070
13056
  var $TypeError$4 = type;
13071
13057
  var $call$1 = functionCall;
13072
13058
  var $actualApply = actualApply;
@@ -13134,8 +13120,8 @@ function requireHasown() {
13134
13120
  hasRequiredHasown = 1;
13135
13121
  var call = Function.prototype.call;
13136
13122
  var $hasOwn = Object.prototype.hasOwnProperty;
13137
- var bind2 = requireFunctionBind();
13138
- hasown = bind2.call(call, $hasOwn);
13123
+ var bind3 = functionBind;
13124
+ hasown = bind3.call(call, $hasOwn);
13139
13125
  return hasown;
13140
13126
  }
13141
13127
  var undefined$1;
@@ -13149,7 +13135,7 @@ var $TypeError$3 = type;
13149
13135
  var $URIError = uri;
13150
13136
  var abs = abs$1;
13151
13137
  var floor = floor$1;
13152
- var max = max$1;
13138
+ var max = max$2;
13153
13139
  var min = min$1;
13154
13140
  var pow = pow$1;
13155
13141
  var round$1 = round$2;
@@ -13354,13 +13340,13 @@ var LEGACY_ALIASES = {
13354
13340
  "%WeakMapPrototype%": ["WeakMap", "prototype"],
13355
13341
  "%WeakSetPrototype%": ["WeakSet", "prototype"]
13356
13342
  };
13357
- var bind = requireFunctionBind();
13343
+ var bind2 = functionBind;
13358
13344
  var hasOwn = requireHasown();
13359
- var $concat = bind.call($call, Array.prototype.concat);
13360
- var $spliceApply = bind.call($apply, Array.prototype.splice);
13361
- var $replace = bind.call($call, String.prototype.replace);
13362
- var $strSlice = bind.call($call, String.prototype.slice);
13363
- var $exec = bind.call($call, RegExp.prototype.exec);
13345
+ var $concat = bind2.call($call, Array.prototype.concat);
13346
+ var $spliceApply = bind2.call($apply, Array.prototype.splice);
13347
+ var $replace = bind2.call($call, String.prototype.replace);
13348
+ var $strSlice = bind2.call($call, String.prototype.slice);
13349
+ var $exec = bind2.call($call, RegExp.prototype.exec);
13364
13350
  var rePropName = /[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g;
13365
13351
  var reEscapeChar = /\\(\\)?/g;
13366
13352
  var stringToPath = function stringToPath2(string2) {
@@ -25668,11 +25654,9 @@ const StyledInput = styled(Input)`
25668
25654
  `;
25669
25655
  function Success() {
25670
25656
  const { actions } = useQualification();
25671
- const router = useRouter();
25672
25657
  const { t: t2 } = useTranslation("qualification");
25673
25658
  const handleClose = () => {
25674
25659
  actions.initialize();
25675
- router.push("/en/catering-london");
25676
25660
  };
25677
25661
  return /* @__PURE__ */ jsxs(Fragment, { children: [
25678
25662
  /* @__PURE__ */ jsx(Box, { display: "flex", justifyContent: "end", children: /* @__PURE__ */ jsx(Box, { px: 2, children: /* @__PURE__ */ jsx(IconButton$2, { onClick: handleClose, "aria-label": "back", component: "span", children: /* @__PURE__ */ jsx(CloseIcon$1, {}) }) }) }),
@@ -25819,6 +25803,7 @@ function useFunnelCheckout() {
25819
25803
  function useQfLeadCreator() {
25820
25804
  const client = useClient();
25821
25805
  const createQfLead = async (variables) => {
25806
+ var _a2;
25822
25807
  try {
25823
25808
  const {
25824
25809
  company,
@@ -25841,44 +25826,34 @@ function useQfLeadCreator() {
25841
25826
  number_of_vegans,
25842
25827
  number_of_vegetarians,
25843
25828
  price_per_person,
25844
- service_type,
25845
- team_size,
25846
- delivery_frequency,
25847
- budget_range,
25848
- min_order_number
25829
+ min_order_number,
25830
+ team_size
25849
25831
  } = variables;
25850
25832
  const hasDietaryBreakdown = number_of_vegans != null && number_of_vegetarians != null && number_of_carnivore != null;
25851
- const numberOfPeople = hasDietaryBreakdown ? number_of_vegans + number_of_vegetarians + number_of_carnivore : min_order_number || team_size || null;
25852
- const totalBudget = numberOfPeople && price_per_person ? numberOfPeople * price_per_person : null;
25853
- const {
25854
- data: { createQfLead: response }
25855
- } = await createQfLeadMutation(
25856
- {
25857
- email,
25858
- firstName: first_name,
25859
- lastName: last_name,
25860
- phone,
25861
- company,
25862
- comment,
25863
- address: `${deliveryAddressStreet} ${deliveryAddressStreetNumber}, ${deliveryAddressPostalCode} ${deliveryAddressCity}, ${deliveryAddressCountry}`,
25864
- cateringCategories: catering_categories || null,
25865
- eventDate: event_date ? new Date(event_date).toDateString() : null,
25866
- hasRecurringNeed: has_recurring_need || null,
25867
- isMultiDay: is_multi_day || null,
25868
- numberOfOmnivores: number_of_carnivore || null,
25869
- numberOfVegans: number_of_vegans || null,
25870
- numberOfVegetarians: number_of_vegetarians || null,
25871
- numberOfPeople,
25872
- totalBudget,
25873
- leadType: lead_type || null,
25874
- serviceType: service_type,
25875
- teamSize: team_size || null,
25876
- deliveryFrequency: delivery_frequency || null,
25877
- budgetRange: budget_range || null
25878
- },
25879
- { client }
25880
- );
25881
- return response;
25833
+ const numberOfPeople = hasDietaryBreakdown ? number_of_vegans + number_of_vegetarians + number_of_carnivore : min_order_number || team_size || void 0;
25834
+ const totalBudget = numberOfPeople && price_per_person ? numberOfPeople * price_per_person : void 0;
25835
+ const payload = {
25836
+ email,
25837
+ firstName: first_name,
25838
+ lastName: last_name,
25839
+ phone,
25840
+ company,
25841
+ comment,
25842
+ address: `${deliveryAddressStreet} ${deliveryAddressStreetNumber}, ${deliveryAddressPostalCode} ${deliveryAddressCity}, ${deliveryAddressCountry}`,
25843
+ cateringCategories: catering_categories,
25844
+ eventDate: event_date ? new Date(event_date).toDateString() : void 0,
25845
+ hasRecurringNeed: has_recurring_need,
25846
+ isMultiDay: is_multi_day,
25847
+ numberOfOmnivores: number_of_carnivore,
25848
+ numberOfVegans: number_of_vegans,
25849
+ numberOfVegetarians: number_of_vegetarians,
25850
+ numberOfPeople,
25851
+ totalBudget,
25852
+ leadType: lead_type
25853
+ };
25854
+ const result = await createQfLeadMutation(payload, { client });
25855
+ const response = (_a2 = result == null ? void 0 : result.data) == null ? void 0 : _a2.createQfLead;
25856
+ return response || { success: false };
25882
25857
  } catch (error) {
25883
25858
  if (error) {
25884
25859
  BugsnagExport.notify(error, (event) => {
@@ -25950,13 +25925,13 @@ function useRequestForm() {
25950
25925
  deliveryAddressCountry
25951
25926
  );
25952
25927
  if (isLeadOnlyFunnel || isUkLead) {
25953
- const { success } = await createQfLead({
25928
+ const response = await createQfLead({
25954
25929
  ...values2,
25955
25930
  ...qualification == null ? void 0 : qualification.answers
25956
25931
  });
25957
25932
  return {
25958
- success,
25959
- isUkLead: true
25933
+ success: response == null ? void 0 : response.success,
25934
+ isLeadOnly: true
25960
25935
  };
25961
25936
  } else {
25962
25937
  const {
@@ -25968,7 +25943,7 @@ function useRequestForm() {
25968
25943
  signInToken,
25969
25944
  customerAccount,
25970
25945
  opportunity,
25971
- isUkLead: false
25946
+ isLeadOnly: false
25972
25947
  };
25973
25948
  }
25974
25949
  };
@@ -26048,8 +26023,21 @@ function RequestForm({ header = null }) {
26048
26023
  handleDeliveryAddressChange();
26049
26024
  }, [deliveryAddress]);
26050
26025
  const handleSubmit = async (values2) => {
26051
- var _a3, _b2;
26026
+ var _a3, _b2, _c2, _d;
26052
26027
  handleDisableCTA(true);
26028
+ const serviceType = (_a3 = qualification == null ? void 0 : qualification.answers) == null ? void 0 : _a3.service_type;
26029
+ const isLeadOnlyFunnel = serviceType === "regular_employee_catering" || serviceType === "full_service_event";
26030
+ if (isLeadOnlyFunnel) {
26031
+ const result = await submitAsNewCustomer(values2);
26032
+ if (result == null ? void 0 : result.success) {
26033
+ setShowLeadSuccess(true);
26034
+ window.gtag && window.gtag("event", "submit_qf_request");
26035
+ (_b2 = window.dataLayer) == null ? void 0 : _b2.push({ event: "funnel_form_submit" });
26036
+ } else {
26037
+ handleDisableCTA(false);
26038
+ }
26039
+ return;
26040
+ }
26053
26041
  let redirectRoute = "";
26054
26042
  if (currentUserAccount) {
26055
26043
  try {
@@ -26061,16 +26049,16 @@ function RequestForm({ header = null }) {
26061
26049
  }
26062
26050
  }
26063
26051
  } else {
26064
- const {
26065
- signInToken,
26066
- opportunity,
26067
- isUkLead,
26068
- success
26069
- } = await submitAsNewCustomer(values2);
26070
- if (success && isUkLead) {
26071
- setShowLeadSuccess(true);
26072
- window.gtag && window.gtag("event", "submit_qf_request");
26073
- (_a3 = window.dataLayer) == null ? void 0 : _a3.push({ event: "funnel_form_submit" });
26052
+ const result = await submitAsNewCustomer(values2);
26053
+ const { signInToken, opportunity, isLeadOnly, success } = result;
26054
+ if (isLeadOnly) {
26055
+ if (success) {
26056
+ setShowLeadSuccess(true);
26057
+ window.gtag && window.gtag("event", "submit_qf_request");
26058
+ (_c2 = window.dataLayer) == null ? void 0 : _c2.push({ event: "funnel_form_submit" });
26059
+ } else {
26060
+ handleDisableCTA(false);
26061
+ }
26074
26062
  return;
26075
26063
  }
26076
26064
  if (signInToken) {
@@ -26081,7 +26069,7 @@ function RequestForm({ header = null }) {
26081
26069
  }
26082
26070
  if (qualification == null ? void 0 : qualification.selectedMenu) ;
26083
26071
  window.gtag && window.gtag("event", "submit_qf_request");
26084
- (_b2 = window.dataLayer) == null ? void 0 : _b2.push({ event: "funnel_form_submit" });
26072
+ (_d = window.dataLayer) == null ? void 0 : _d.push({ event: "funnel_form_submit" });
26085
26073
  actions.setRequest(values2);
26086
26074
  redirectToCustomerAccountRequest(redirectRoute);
26087
26075
  };