@heycater/qualification-funnel 1.4.2 → 1.4.3

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
@@ -26584,8 +26584,31 @@ function RequestForm({ header = null }) {
26584
26584
  }, [deliveryAddress]);
26585
26585
  const { mode } = useTracking();
26586
26586
  const handleSubmit = async (values2) => {
26587
- var _a3, _b2;
26587
+ var _a3;
26588
26588
  handleDisableCTA(true);
26589
+ const serviceType = (_a3 = qualification == null ? void 0 : qualification.answers) == null ? void 0 : _a3.service_type;
26590
+ const isLeadOnlyFunnel = serviceType === "regular_employee_catering" || serviceType === "full_service_event";
26591
+ const { deliveryAddressCountry: deliveryAddressCountry2 } = values2;
26592
+ const isUkLead = ["United Kingdom", "Great Britain", "UK"].includes(
26593
+ deliveryAddressCountry2
26594
+ );
26595
+ if (isLeadOnlyFunnel || isUkLead) {
26596
+ const response = await submitAsNewCustomer(values2);
26597
+ const { success } = response;
26598
+ if (success) {
26599
+ setIsActualUkLead(isUkLead);
26600
+ setShowLeadSuccess(true);
26601
+ const contextProps2 = getContextualProperties(state);
26602
+ trackFormSubmitted(mode, {
26603
+ is_uk_lead: isUkLead,
26604
+ ...contextProps2
26605
+ });
26606
+ trackFunnelCompleted(mode, contextProps2);
26607
+ return;
26608
+ } else {
26609
+ console.error("[HeyCater Funnel] Expected success screen but got success=false. Result:", response);
26610
+ }
26611
+ }
26589
26612
  let redirectRoute = "";
26590
26613
  if (currentUserAccount) {
26591
26614
  try {
@@ -26599,23 +26622,8 @@ function RequestForm({ header = null }) {
26599
26622
  } else {
26600
26623
  const {
26601
26624
  signInToken,
26602
- opportunity,
26603
- isUkLead,
26604
- success
26625
+ opportunity
26605
26626
  } = await submitAsNewCustomer(values2);
26606
- if (success) {
26607
- setIsActualUkLead(isUkLead);
26608
- setShowLeadSuccess(true);
26609
- const contextProps2 = getContextualProperties(state);
26610
- trackFormSubmitted(mode, {
26611
- is_uk_lead: isUkLead,
26612
- ...contextProps2
26613
- });
26614
- trackFunnelCompleted(mode, contextProps2);
26615
- return;
26616
- } else if (isUkLead || ((_a3 = qualification == null ? void 0 : qualification.answers) == null ? void 0 : _a3.service_type) === "regular_employee_catering" || ((_b2 = qualification == null ? void 0 : qualification.answers) == null ? void 0 : _b2.service_type) === "full_service_event") {
26617
- console.error("[HeyCater Funnel] Expected success screen but got success=false. Result:", { signInToken, opportunity, isUkLead, success });
26618
- }
26619
26627
  if (signInToken) {
26620
26628
  redirectRoute = `/${router.locale}/account/requests/${opportunity.id}?one_time_sign_in_token=${signInToken}`;
26621
26629
  } else {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@heycater/qualification-funnel",
3
- "version": "1.4.2",
3
+ "version": "1.4.3",
4
4
  "type": "module",
5
5
  "description": "Heycater embedded qualification funnel widget",
6
6
  "main": "dist/index.cjs.js",