@heycater/qualification-funnel 1.19.30 → 1.19.31

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
@@ -31277,18 +31277,21 @@ const REDESIGN_STEPS = {
31277
31277
  breadcrumbEn: "Get quotes"
31278
31278
  }
31279
31279
  };
31280
- function getRedesignTotalSteps() {
31281
- return REDESIGN_STEP_ORDER.length + 1;
31282
- }
31283
- const RAIL_DISPLAY_STEPS = [
31284
- ...REDESIGN_STEP_ORDER,
31285
- REDESIGN_STEP_IDS.contact
31286
- ];
31287
31280
  const StepRail = ({ currentStepId, onStepClick, answers }) => {
31288
31281
  var _a2;
31289
31282
  const { i18n } = useTranslation();
31290
31283
  const isGerman = (_a2 = i18n.language) == null ? void 0 : _a2.startsWith("de");
31291
- const currentIndex = RAIL_DISPLAY_STEPS.indexOf(currentStepId);
31284
+ const { state } = useQualification();
31285
+ const isCityStepDisabled = useMemo(() => {
31286
+ if (!("qualification" in state)) return false;
31287
+ const cityStep2 = state.qualification.steps.find((s3) => s3.id === "city");
31288
+ return (cityStep2 == null ? void 0 : cityStep2.disabled) === true;
31289
+ }, ["qualification" in state ? state.qualification.steps : null]);
31290
+ const railDisplaySteps = useMemo(() => {
31291
+ const steps2 = isCityStepDisabled ? REDESIGN_STEP_ORDER.filter((step2) => step2 !== REDESIGN_STEP_IDS.city) : [...REDESIGN_STEP_ORDER];
31292
+ return [...steps2, REDESIGN_STEP_IDS.contact];
31293
+ }, [isCityStepDisabled]);
31294
+ const currentIndex = railDisplaySteps.indexOf(currentStepId);
31292
31295
  const handleStepClick = (stepId, index) => {
31293
31296
  if (index < currentIndex && onStepClick && stepId !== REDESIGN_STEP_IDS.contact) {
31294
31297
  onStepClick(stepId);
@@ -31316,7 +31319,7 @@ const StepRail = ({ currentStepId, onStepClick, answers }) => {
31316
31319
  /* @__PURE__ */ jsx(LogoWrapper$1, { children: /* @__PURE__ */ jsx(Logo, { height: 26 }) }),
31317
31320
  /* @__PURE__ */ jsx(SectionLabel, { children: isGerman ? "Catering anfragen" : "Request catering" }),
31318
31321
  /* @__PURE__ */ jsx(Title$1, { children: isGerman ? "In wenigen Schritten zum passenden Catering." : "Get the perfect catering in just a few steps." }),
31319
- /* @__PURE__ */ jsx(StepList, { children: RAIL_DISPLAY_STEPS.map((stepId, index) => {
31322
+ /* @__PURE__ */ jsx(StepList, { children: railDisplaySteps.map((stepId, index) => {
31320
31323
  const step2 = REDESIGN_STEPS[stepId];
31321
31324
  const isActive = index === currentIndex;
31322
31325
  const isCompleted = index < currentIndex;
@@ -32391,6 +32394,17 @@ const RedesignedFunnel = ({
32391
32394
  const isGerman = (_a2 = i18n.language) == null ? void 0 : _a2.startsWith("de");
32392
32395
  const router = useRouter();
32393
32396
  const { state, actions, answerOf } = useQualification();
32397
+ const isCityStepDisabled = React__default.useMemo(() => {
32398
+ if (!("qualification" in state)) return false;
32399
+ const cityStep2 = state.qualification.steps.find((s3) => s3.id === "city");
32400
+ return (cityStep2 == null ? void 0 : cityStep2.disabled) === true;
32401
+ }, ["qualification" in state ? state.qualification.steps : null]);
32402
+ const stepOrder = React__default.useMemo(() => {
32403
+ if (isCityStepDisabled) {
32404
+ return REDESIGN_STEP_ORDER.filter((step2) => step2 !== REDESIGN_STEP_IDS.city);
32405
+ }
32406
+ return REDESIGN_STEP_ORDER;
32407
+ }, [isCityStepDisabled]);
32394
32408
  const [currentStepIndex, setCurrentStepIndex] = useState(0);
32395
32409
  const [phase, setPhase] = useState("questions");
32396
32410
  const [budgetPerPerson2, setBudgetPerPerson] = useState(20);
@@ -32399,7 +32413,7 @@ const RedesignedFunnel = ({
32399
32413
  const [redirectUrl, setRedirectUrl] = useState(null);
32400
32414
  const hasTrackedStart = useRef(false);
32401
32415
  const { submitAsNewCustomer } = useRequestForm();
32402
- const currentStepId = REDESIGN_STEP_ORDER[currentStepIndex];
32416
+ const currentStepId = stepOrder[currentStepIndex];
32403
32417
  const handleCancel = onCancel || (() => window.history.back());
32404
32418
  useEffect(() => {
32405
32419
  if (currentStepId === "redesign_people_count") {
@@ -32440,26 +32454,26 @@ const RedesignedFunnel = ({
32440
32454
  }, [funnelContextRef, currentStepIndex, currentStepId]);
32441
32455
  const nextStep = useCallback(() => {
32442
32456
  const nextIndex = currentStepIndex + 1;
32443
- if (nextIndex >= REDESIGN_STEP_ORDER.length) {
32457
+ if (nextIndex >= stepOrder.length) {
32444
32458
  setPhase("loading");
32445
32459
  } else {
32446
32460
  setCurrentStepIndex(nextIndex);
32447
32461
  }
32448
- }, [currentStepIndex]);
32462
+ }, [currentStepIndex, stepOrder.length]);
32449
32463
  const previousStep = useCallback(() => {
32450
32464
  if (currentStepIndex > 0) {
32451
32465
  setCurrentStepIndex(currentStepIndex - 1);
32452
32466
  }
32453
32467
  }, [currentStepIndex]);
32454
32468
  const goToStep = useCallback((stepId) => {
32455
- const index = REDESIGN_STEP_ORDER.indexOf(stepId);
32469
+ const index = stepOrder.indexOf(stepId);
32456
32470
  if (index >= 0) {
32457
32471
  if (phase === "contact") {
32458
32472
  setPhase("questions");
32459
32473
  }
32460
32474
  setCurrentStepIndex(index);
32461
32475
  }
32462
- }, [phase]);
32476
+ }, [phase, stepOrder]);
32463
32477
  const handleCitySelect = useCallback((city) => {
32464
32478
  actions.answerQuestion("city", city);
32465
32479
  trackAnswer("city", city);
@@ -32472,9 +32486,9 @@ const RedesignedFunnel = ({
32472
32486
  actions.answerQuestion("service_type", mapping.service_type);
32473
32487
  actions.answerQuestion("catering_categories", [mapping.catering_category]);
32474
32488
  trackAnswer("event_type", eventType);
32475
- updateContext({ service_type: mapping.service_type, total_steps: getRedesignTotalSteps() });
32489
+ updateContext({ service_type: mapping.service_type, total_steps: stepOrder.length + 1 });
32476
32490
  nextStep();
32477
- }, [actions, trackAnswer, updateContext, nextStep]);
32491
+ }, [actions, trackAnswer, updateContext, nextStep, stepOrder.length]);
32478
32492
  const handleDateChange = useCallback((date2) => {
32479
32493
  if (date2) {
32480
32494
  actions.answerQuestion("event_date", date2);
@@ -32532,8 +32546,8 @@ const RedesignedFunnel = ({
32532
32546
  }, [submitAsNewCustomer, funnelContextRef, router.locale]);
32533
32547
  const handleContactBack = useCallback(() => {
32534
32548
  setPhase("questions");
32535
- setCurrentStepIndex(REDESIGN_STEP_ORDER.length - 1);
32536
- }, []);
32549
+ setCurrentStepIndex(stepOrder.length - 1);
32550
+ }, [stepOrder.length]);
32537
32551
  const canContinue = useCallback(() => {
32538
32552
  switch (currentStepId) {
32539
32553
  case "redesign_city":
@@ -32651,7 +32665,7 @@ const RedesignedFunnel = ({
32651
32665
  const currentStep = REDESIGN_STEPS[currentStepId];
32652
32666
  const stepTitle = isGerman ? currentStep.titleDe : currentStep.titleEn;
32653
32667
  const stepSubtitle = isGerman ? currentStep.subtitleDe : currentStep.subtitleEn;
32654
- const totalSteps = getRedesignTotalSteps();
32668
+ const totalSteps = stepOrder.length + 1;
32655
32669
  const chips = buildSelectionChips();
32656
32670
  const showBack = currentStepIndex > 0;
32657
32671
  const showChips = currentStepIndex >= 1 && chips.length > 0;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@heycater/qualification-funnel",
3
- "version": "1.19.30",
3
+ "version": "1.19.31",
4
4
  "type": "module",
5
5
  "description": "Heycater embedded qualification funnel widget",
6
6
  "main": "dist/index.cjs.js",