@heycater/qualification-funnel 1.18.0 → 1.19.1

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
@@ -4272,6 +4272,11 @@ const useIsGb = () => {
4272
4272
  return getIsGb(query);
4273
4273
  };
4274
4274
  const getIsGb = (query) => {
4275
+ if (typeof window !== "undefined") {
4276
+ if (window.location.pathname.toLowerCase().includes("london")) {
4277
+ return true;
4278
+ }
4279
+ }
4275
4280
  if (query == null ? void 0 : query.slug) {
4276
4281
  return query.slug === "catering-london";
4277
4282
  }
@@ -4984,6 +4989,7 @@ const CITY_VALUES = [
4984
4989
  "duesseldorf",
4985
4990
  "koeln",
4986
4991
  "stuttgart",
4992
+ "london",
4987
4993
  "other"
4988
4994
  ];
4989
4995
  const CITY_QUESTION_ITEMS = [
@@ -5029,6 +5035,22 @@ const CITY_QUESTION_ITEMS = [
5029
5035
  value: "stuttgart",
5030
5036
  imageComponent: Stuttgart
5031
5037
  },
5038
+ {
5039
+ labelEn: "London",
5040
+ labelDe: "London",
5041
+ value: "london",
5042
+ imageComponent: () => /* @__PURE__ */ jsx(
5043
+ Box,
5044
+ {
5045
+ height: "80px",
5046
+ width: "80px",
5047
+ display: "flex",
5048
+ alignItems: "center",
5049
+ justifyContent: "center",
5050
+ children: /* @__PURE__ */ jsx(Other, { width: "24px" })
5051
+ }
5052
+ )
5053
+ },
5032
5054
  {
5033
5055
  value: "other",
5034
5056
  labelEn: "Other City",
@@ -5050,13 +5072,23 @@ const cityQuestion = Object.freeze(
5050
5072
  createSelectorQuestion({
5051
5073
  id: "city",
5052
5074
  getValidator: ({ selectedCaterer }) => {
5053
- const supportedCityValues = getSupportedCityValues(selectedCaterer);
5075
+ const isGb = getIsGb();
5076
+ if (isGb) {
5077
+ return yup.mixed().oneOf(["london"]).required();
5078
+ }
5079
+ const supportedCityValues = getSupportedCityValues(selectedCaterer).filter(
5080
+ (city) => city !== "london"
5081
+ );
5054
5082
  return yup.mixed().oneOf(supportedCityValues).required();
5055
5083
  },
5056
5084
  getItems: ({ selectedCaterer }) => {
5085
+ const isGb = getIsGb();
5086
+ if (isGb) {
5087
+ return CITY_QUESTION_ITEMS.filter(({ value }) => value === "london");
5088
+ }
5057
5089
  const supportedCityValues = getSupportedCityValues(selectedCaterer);
5058
5090
  return CITY_QUESTION_ITEMS.filter(
5059
- ({ value }) => supportedCityValues.includes(value)
5091
+ ({ value }) => supportedCityValues.includes(value) && value !== "london"
5060
5092
  );
5061
5093
  }
5062
5094
  })
@@ -8383,6 +8415,7 @@ function answerDefaultValue(question, state, actions) {
8383
8415
  }
8384
8416
  }
8385
8417
  function isDataInStorageInvalid(data) {
8418
+ var _a2, _b;
8386
8419
  try {
8387
8420
  const validator = yup.object({
8388
8421
  qualification: yup.object({
@@ -8395,6 +8428,14 @@ function isDataInStorageInvalid(data) {
8395
8428
  })
8396
8429
  });
8397
8430
  validator.validateSync(data);
8431
+ const cityItems = cityQuestion.getItems({});
8432
+ if (cityItems.length === 1) {
8433
+ const storedData = data;
8434
+ const cityStep2 = (_b = (_a2 = storedData.qualification) == null ? void 0 : _a2.steps) == null ? void 0 : _b.find((s3) => s3.id === "city");
8435
+ if (cityStep2 && !cityStep2.disabled) {
8436
+ return true;
8437
+ }
8438
+ }
8398
8439
  return false;
8399
8440
  } catch {
8400
8441
  return true;
@@ -10217,24 +10258,36 @@ function TrackingProvider({
10217
10258
  trackedSteps = [];
10218
10259
  }
10219
10260
  }
10220
- if (isFirstTracking && stepIndex > 0 && isValidServiceType(serviceType)) {
10261
+ if (isFirstTracking && isValidServiceType(serviceType)) {
10221
10262
  const stepOrder = getStepOrderForServiceType(serviceType);
10222
- for (let i2 = 0; i2 < stepIndex && i2 < stepOrder.length; i2++) {
10223
- const skippedStepId = stepOrder[i2];
10224
- if (trackedSteps.includes(skippedStepId)) continue;
10225
- const skippedSchemaStep = SCHEMA_STEPS[skippedStepId];
10226
- const skippedQuestions = (skippedSchemaStep == null ? void 0 : skippedSchemaStep.questions) || [];
10227
- skippedQuestions.forEach((question, qIdx) => {
10263
+ const allSteps = qual.steps || [];
10264
+ for (let i2 = 0; i2 < stepOrder.length; i2++) {
10265
+ const stepId = stepOrder[i2];
10266
+ if (trackedSteps.includes(stepId)) continue;
10267
+ const stepState = allSteps.find((s3) => s3.id === stepId);
10268
+ const isDisabled = (stepState == null ? void 0 : stepState.disabled) === true;
10269
+ const isBeforeCurrentStep = i2 < stepIndex;
10270
+ const isCurrentStep = stepId === step2.id;
10271
+ if (isCurrentStep) continue;
10272
+ const shouldTrack = isBeforeCurrentStep || isDisabled;
10273
+ if (!shouldTrack) continue;
10274
+ const schemaStep2 = SCHEMA_STEPS[stepId];
10275
+ const questions22 = (schemaStep2 == null ? void 0 : schemaStep2.questions) || [];
10276
+ if (isDisabled) {
10277
+ const hasAnswer = questions22.some((q2) => answerOf(q2.id) !== void 0);
10278
+ if (!hasAnswer) continue;
10279
+ }
10280
+ questions22.forEach((question, qIdx) => {
10228
10281
  const value = answerOf(question.id);
10229
10282
  trackAnswerSelected(funnelContextRef.current, {
10230
- step_id: skippedStepId,
10283
+ step_id: stepId,
10231
10284
  step_index: i2,
10232
10285
  question_id: question.id,
10233
10286
  answer_value: serializeAnswerValue(value),
10234
- is_last_question: qIdx === skippedQuestions.length - 1
10287
+ is_last_question: qIdx === questions22.length - 1
10235
10288
  });
10236
10289
  });
10237
- trackedSteps.push(skippedStepId);
10290
+ trackedSteps.push(stepId);
10238
10291
  }
10239
10292
  }
10240
10293
  if (trackedSteps.includes(step2.id)) return;
@@ -12979,14 +13032,7 @@ var implementation$1 = function bind(that) {
12979
13032
  };
12980
13033
  var implementation = implementation$1;
12981
13034
  var functionBind = Function.prototype.bind || implementation;
12982
- var functionCall;
12983
- var hasRequiredFunctionCall;
12984
- function requireFunctionCall() {
12985
- if (hasRequiredFunctionCall) return functionCall;
12986
- hasRequiredFunctionCall = 1;
12987
- functionCall = Function.prototype.call;
12988
- return functionCall;
12989
- }
13035
+ var functionCall = Function.prototype.call;
12990
13036
  var functionApply;
12991
13037
  var hasRequiredFunctionApply;
12992
13038
  function requireFunctionApply() {
@@ -12998,12 +13044,12 @@ function requireFunctionApply() {
12998
13044
  var reflectApply = typeof Reflect !== "undefined" && Reflect && Reflect.apply;
12999
13045
  var bind$2 = functionBind;
13000
13046
  var $apply$1 = requireFunctionApply();
13001
- var $call$2 = requireFunctionCall();
13047
+ var $call$2 = functionCall;
13002
13048
  var $reflectApply = reflectApply;
13003
13049
  var actualApply = $reflectApply || bind$2.call($call$2, $apply$1);
13004
13050
  var bind$1 = functionBind;
13005
13051
  var $TypeError$4 = type;
13006
- var $call$1 = requireFunctionCall();
13052
+ var $call$1 = functionCall;
13007
13053
  var $actualApply = actualApply;
13008
13054
  var callBindApplyHelpers = function callBindBasic(args) {
13009
13055
  if (args.length < 1 || typeof args[0] !== "function") {
@@ -13118,7 +13164,7 @@ var getProto = requireGetProto();
13118
13164
  var $ObjectGPO = requireObject_getPrototypeOf();
13119
13165
  var $ReflectGPO = requireReflect_getPrototypeOf();
13120
13166
  var $apply = requireFunctionApply();
13121
- var $call = requireFunctionCall();
13167
+ var $call = functionCall;
13122
13168
  var needsEval = {};
13123
13169
  var TypedArray = typeof Uint8Array === "undefined" || !getProto ? undefined$1 : getProto(Uint8Array);
13124
13170
  var INTRINSICS = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@heycater/qualification-funnel",
3
- "version": "1.18.0",
3
+ "version": "1.19.1",
4
4
  "type": "module",
5
5
  "description": "Heycater embedded qualification funnel widget",
6
6
  "main": "dist/index.cjs.js",