@heycater/qualification-funnel 1.19.25 → 1.19.28
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/heycater-funnel.iife.js +477 -478
- package/dist/index.cjs.js +8 -9
- package/dist/index.esm.js +31 -23
- package/package.json +1 -1
package/dist/index.cjs.js
CHANGED
|
@@ -1347,7 +1347,7 @@ object-assign
|
|
|
1347
1347
|
justify-content: center;
|
|
1348
1348
|
background-size: cover;
|
|
1349
1349
|
background-position: bottom center;
|
|
1350
|
-
`,E_=({children:e,height:n,isFloating:r,...i})=>t.jsxs(t.Fragment,{children:[t.jsx(v,{display:"flex",flexDirection:"column",flexGrow:"1",bottom:"0",left:"0",right:"0",position:r?"fixed":"relative",...i,children:e}),r&&t.jsx("div",{style:{height:`${n}px`}})]});const O_={de:"German",en:"English"};function $_(e){const{billingAddressStreetAndNumber:t,billingAddressCity:n,billingAddressPostalCode:r,email:i,company:o,has_recurring_need:a}=e;return{billingAddressStreetAndNumber:t,billingAddressCity:n,billingAddressPostalCode:r,billingEmail:i,billingName:o,name:o,hasRecurringNeed:a}}function D_(){const{locale:e}=du(),t=a.useClient();return{funnelCheckout:async n=>{try{const{data:{funnelCheckout:r}}=await((e,{client:t})=>t.mutation(Vb,{attributes:e}).toPromise())({userAttributes:{email:n.email,firstName:n.first_name,lastName:n.last_name,phone:n.phone,language:O_[e]||O_.de},accountAttributes:$_(n),opportunityAttributes:Zb(n)},{client:t});return r}catch(r){r instanceof Error&&i_.notify(r,e=>{e.addMetadata("funnelCheckoutArgs",n)})}}}}function z_(){const e=a.useClient();return{createQfLead:async t=>{try{const{company:n,comment:r,deliveryAddressCity:i,deliveryAddressCountry:o,deliveryAddressPostalCode:a,deliveryAddressStreet:s,deliveryAddressStreetNumber:l,email:u,first_name:c,last_name:d,phone:f,catering_categories:p,event_date:h,has_recurring_need:m,is_multi_day:g,number_of_carnivore:y,lead_type:v,number_of_vegans:b,number_of_vegetarians:x,price_per_person:C,service_type:w,team_size:L,delivery_frequency:k,budget_range:j,leadSource:M,conversionUrl:S,entranceUrl:_,referrerUrl:E,landingPageSource:O}=t,$=b+x+y,{data:{createQfLead:D}}=await((e,{client:t})=>t.mutation(Ub,{attributes:e}).toPromise())({email:u,firstName:c,lastName:d,phone:f,company:n,comment:r,address:`${s} ${l}, ${a} ${i}, ${o}`,cateringCategories:p,eventDate:new Date(h).toDateString(),hasRecurringNeed:m,isMultiDay:g,numberOfOmnivores:y,numberOfVegans:b,numberOfVegetarians:x,numberOfPeople:$,totalBudget:$*C,leadType:v,serviceType:w,teamSize:L,deliveryFrequency:k,budgetRange:j,leadSource:M,conversionUrl:S,entranceUrl:_,referrerUrl:E,landingPageSource:O},{client:e});return D}catch(n){n&&i_.notify(n,e=>{e.addMetadata("createQfLead",t)})}}}}const A_=e=>{const t=document.cookie.match(new RegExp("(^| )"+e+"=([^;]+)"));return t?decodeURIComponent(t[2]):void 0};function T_(){const{state:e}=Mf(),t="qualification"in e?e.qualification:null,n=a.useClient(),{currentUserAccount:r}=Lf(),i=du(),{funnelCheckout:o}=D_(),{createQfLead:s}=z_(),l=e=>{var n,o,a,s;const l=`${e.deliveryAddressStreet} ${e.deliveryAddressStreetNumber}`,{street:u,postalCode:c,city:d,country:f}=(null==(o=null==(n=null==r?void 0:r.owner)?void 0:n.salesforceCustomer)?void 0:o.billingAddress)||{street:l,postalCode:e.deliveryAddressPostalCode,city:e.deliveryAddressCity,country:e.deliveryAddressCountry};if(!t)throw new Error("cannot create an opportunity outside of the qualification");const p=(null==(a=t.leadSource)?void 0:a.includes("/events"))?"events-landingpage":"Qualification Funnel",h=t.answers,m=!!h.event_type,g=h.min_order_number||0,y=m?{number_of_carnivore:g,number_of_vegans:0,number_of_vegetarians:0}:{};return{...h,...y,...e,phone:e.phone||"",catererSlug:null==(s=null==t?void 0:t.selectedCaterer)?void 0:s.slug,landingPageSource:t.leadSource,billingAddressStreetAndNumber:u||"",billingAddressPostalCode:c||"",billingAddressCity:d||"",billingCountry:f||"",conversion_url:window.location.href,deliveryAddressStreetAndNumber:l,deliveryCountry:e.deliveryAddressCountry,lead_language:i.locale,leadSource:p,commentByHeycaterForCaterer:e.comment}};return{submitAsNewCustomer:async e=>{var n,r;const i=null==(n=null==t?void 0:t.answers)?void 0:n.service_type,a="regular_employee_catering"===i||"full_service_event"===i,{deliveryAddressCountry:u}=e,c=["United Kingdom","Great Britain","UK"].includes(u);if(!a&&!c){const{signInToken:t,customerAccount:n,opportunity:r}=await o(l(e));return{signInToken:t,customerAccount:n,opportunity:r,isUkLead:!1}}try{const n=(null==(r=null==t?void 0:t.leadSource)?void 0:r.includes("/events"))?"events-landingpage":"Qualification Funnel",i=(null==t?void 0:t.answers)||{},o=await s({...e,...i,leadSource:n,conversionUrl:window.location.href,entranceUrl:A_("entrance_url"),referrerUrl:A_("referrer_url"),landingPageSource:null==t?void 0:t.leadSource});if(!o)return console.error("[HeyCater Funnel] createQfLead returned undefined/null"),{success:!1,isUkLead:c};const{success:a}=o;return void 0===a&&console.error("[HeyCater Funnel] createQfLead response missing success field:",o),{success:a,isUkLead:c}}catch(d){return console.error("[HeyCater Funnel] createQfLead failed:",d),{success:!1,isUkLead:c}}},submitAsExistingCustomer:async e=>{const t=l(e),{createOpportunity:{opportunity:r}}=await async function(e,{client:t}){const n=Zb(e),{data:r}=await t.mutation(Bb,{attributes:n}).toPromise();return r}(t,{client:n});return r}}}const P_="qualification-request-form",F_={},R_=/^\+?[1-9]\d{6,14}$/,I_=({isLoggedIn:e})=>au.object().shape({first_name:au.string().required(),last_name:au.string().required(),company:au.string().required(),email:au.string().required().email(),phone:e?au.string():au.string().matches(R_,"Invalid phone number").required(),deliveryAddressStreet:au.string().min(1).required(),deliveryAddressStreetNumber:au.string().min(1).required(),deliveryAddressPostalCode:au.string().min(1).required(),deliveryAddressCity:au.string().min(1).required(),deliveryAddressCountry:au.string().min(1).required(),comment:au.string()});function N_({header:e=null}){var o,a,s;const[l,u]=n.useState(!1),[d,p]=n.useState(!1),{t:h}=i.useTranslation("qualification"),{submitAsNewCustomer:m,submitAsExistingCustomer:g}=T_(),y=Jf({display:"all-answers"}),b=Af("xs"),{state:x}=Mf(),{ref:C,isFloating:L,height:k}=function(){var e,t;const{inView:n,ref:r,entry:i}=f.useInView({threshold:1}),o=(null==(e=null==i?void 0:i.boundingClientRect)?void 0:e.height)||0,a=!i||(null==(t=i.boundingClientRect)?void 0:t.y)>0;return{height:o,isFloating:!n&&a,ref:r}}(),{validateAddress:j}=a_({cacheValidations:F_}),M=b&&L,S="qualification"in x?x.qualification:null,{actions:_}=Mf(),{currentUserAccount:E}=Lf(),O=du(),[D,z]=n.useState(!1),{deliveryAddressStreetAndNumber:A,deliveryAddressPostalCode:T,deliveryAddressCity:P,deliveryAddressCountry:F}=(null==E?void 0:E.owner)||{},[R,I]=n.useState(""),[N,q]=n.useState(""),Z=E?(({street:e,postalCode:t,city:n,country:r})=>[e,t,n,r].filter(Boolean).join(", "))({street:A,postalCode:T,city:P,country:F}):"";n.useEffect(()=>{!async function(){if(!Z)return;const{streetName:e,streetNumber:t}=await j(Z);I(e),q(t)}()},[Z]);const{funnelContextRef:B}=Hp(),W=({isFormValid:e})=>{const n=t.jsxs(w,{id:"request-form__submit-btn",block:"true","data-logged-in":!!E,"data-valid":e,"data-leadsource":"qualification"in x?x.qualification.leadSource:void 0,size:"lg",type:"submit",disabled:D,children:[D&&t.jsx(v,{mr:2,style:{alignItems:"flex-start"},children:t.jsx(r.CircularProgress,{style:{verticalAlign:"sub"},size:20,color:"inherit"})}),h("request.form.submit")]});return b?t.jsx(E_,{height:k,isFloating:M,children:t.jsx(V_,{py:2,px:M&&2,$floating:M,children:n})}):t.jsx(v,{position:"absolute",bottom:"0",left:"0",right:"0",py:2,px:2,bgcolor:"white",children:n})},V={first_name:(null==E?void 0:E.firstName)||"",last_name:(null==E?void 0:E.lastName)||"",company:(null==(o=null==E?void 0:E.owner)?void 0:o.companyName)||"",deliveryAddressStreet:R||"",deliveryAddressStreetNumber:N||"",deliveryAddressPostalCode:T||"",deliveryAddressCity:P||"",deliveryAddressCountry:F||"",email:(null==E?void 0:E.email)||"",phone:(null==(s=null==(a=null==E?void 0:E.owner)?void 0:a.salesforceCustomer)?void 0:s.phoneNumber)||""},U=!!E;return l?t.jsx(k_,{isUkLead:d}):t.jsxs(v_,{children:[e,t.jsx(c.Formik,{initialValues:V,validationSchema:I_({isLoggedIn:U}),onSubmit:async e=>{var t;z(!0);const n=null==(t=null==S?void 0:S.answers)?void 0:t.service_type,r=B.current.service_type;console.log("[Optimeleon Debug] handleSubmit called",{serviceType:n,serviceTypeType:typeof n,serviceTypeLength:null==n?void 0:n.length,serviceTypeFromContext:r,contextServiceTypeType:typeof r,allAnswers:JSON.stringify(null==S?void 0:S.answers),funnelContext:JSON.stringify(B.current)});const i=n||r;console.log("[Optimeleon Debug] About to track funnel_form_submitted with:",i),Zp("funnel_form_submitted",i);const o="regular_employee_catering"===n||"full_service_event"===n,{deliveryAddressCountry:a}=e,s=["United Kingdom","Great Britain","UK"].includes(a);if(o||s){const t=await m(e),{success:n}=t;return n?(p(s),u(!0),Ip(B.current,{is_uk_lead:s}),Np(B.current),console.log("[Optimeleon Debug] Lead-only flow - tracking funnel_completed with:",i),Zp("funnel_completed",i),void Bp("submit_qf_request")):(console.error("[HeyCater Funnel] Lead submission failed. Result:",t),void z(!1))}let l="",c="";if(E)try{const t=await g(e);if(!t||!t.id)return console.error("[HeyCater Funnel] submitAsExistingCustomer returned invalid opportunity:",t),void z(!1);c=t.userId,l=`/account/requests/${t.id}`}catch(d){return d instanceof Error&&i_.notify(d),void z(!1)}else{const t=await m(e),{signInToken:n,opportunity:r}=t||{};if(!r||!r.id)return console.error("[HeyCater Funnel] submitAsNewCustomer returned invalid opportunity:",t),void z(!1);c=r.userId,l=n?`/${O.locale}/account/requests/${r.id}?one_time_sign_in_token=${n}`:`/${O.locale}/account/external/requests/${r.id}`}c&&(function(e){if("undefined"==typeof window)return;const{googleTagId:t}=bu();if(window.gtag&&t)try{window.gtag("config",t,{user_id:e})}catch(n){console.error("[gtag] Failed to identify user:",n)}}(c),function(e){"undefined"!=typeof window&&(window.dataLayer=window.dataLayer||[],window.dataLayer.push({userId:e}))}(c)),Ip(B.current,{is_logged_in:!!E}),Np(B.current),console.log("[Optimeleon Debug] Regular flow - tracking funnel_completed with:",i),Zp("funnel_completed",i),Bp("submit_qf_request"),_.setRequest(e),((e="/")=>{window.location.href=`${bu().customerAppHost}${e}`})(l)},enableReinitialize:!0,children:e=>{var n,r;return t.jsxs(W_,{id:P_,name:P_,children:[t.jsxs(q_,{children:[t.jsx(Z_,{$half:!0,children:t.jsx(c.Field,{required:!0,name:"first_name",label:h("request.form.firstName"),placeholder:h("request.form.firstName"),component:C_})}),t.jsx(Z_,{$half:!0,children:t.jsx(c.Field,{required:!0,name:"last_name",label:h("request.form.lastName"),placeholder:h("request.form.lastName"),component:C_})})]}),t.jsx(q_,{children:t.jsx(Z_,{$half:!0,children:t.jsx(c.Field,{required:!0,name:"company",label:h("request.form.company"),placeholder:h("request.form.company"),component:C_})})}),t.jsx(q_,{children:t.jsx(Z_,{children:t.jsx(c.Field,{required:!0,name:"delivery_address",label:h("request.form.deliveryAddress"),placeholder:h("request.form.deliveryAddress"),helperText:h("request.form.helpText.address"),defaultValue:Z,component:c_})})}),t.jsxs(q_,{children:[!E&&t.jsx(Z_,{$half:!0,children:t.jsx(c.Field,{required:!0,type:"email",name:"email",label:h("request.form.email"),placeholder:h("request.form.email"),helperText:h("request.form.helpText.email"),component:C_})}),!(null==(r=null==(n=null==E?void 0:E.owner)?void 0:n.salesforceCustomer)?void 0:r.phoneNumber)&&t.jsx(Z_,{$half:!0,children:t.jsx(w_,{label:h("request.form.phone"),name:"phone",formik:e,helperText:h("request.form.helpText.phone")})})]}),t.jsx(q_,{children:t.jsx(Z_,{children:t.jsx(c.Field,{name:"comment",label:h("request.form.comment"),placeholder:h("request.form.commentPlaceholder"),component:C_,multiline:!0})})}),t.jsx(c.Field,{type:"hidden",name:"deliveryAddressStreet"}),t.jsx(c.Field,{type:"hidden",name:"deliveryAddressStreetNumber"}),t.jsx(c.Field,{type:"hidden",name:"deliveryAddressPostalCode"}),t.jsx(c.Field,{type:"hidden",name:"deliveryAddressCity"}),t.jsx(c.Field,{type:"hidden",name:"deliveryAddressCountry"}),t.jsxs(v,{mt:2,mb:4,display:"flex",flexDirection:"column",children:[t.jsx($,{variant:"caption",fontWeight:500,fontSize:12,px:1,mr:1.5,mb:1,children:h("selection.yourSelection")}),t.jsx(B_,{children:y.map(e=>t.jsx(Yf,{size:"sm",stepId:e.stepId,text:e.text||""},`${e.stepId}_${e.text}`))})]}),t.jsx(v,{ref:C,children:t.jsx(W,{isFormValid:e.isValid})})]})}})]})}const q_=o.div`
|
|
1350
|
+
`,E_=({children:e,height:n,isFloating:r,...i})=>t.jsxs(t.Fragment,{children:[t.jsx(v,{display:"flex",flexDirection:"column",flexGrow:"1",bottom:"0",left:"0",right:"0",position:r?"fixed":"relative",...i,children:e}),r&&t.jsx("div",{style:{height:`${n}px`}})]});const O_={de:"German",en:"English"};function $_(e){const{billingAddressStreetAndNumber:t,billingAddressCity:n,billingAddressPostalCode:r,email:i,company:o,has_recurring_need:a}=e;return{billingAddressStreetAndNumber:t,billingAddressCity:n,billingAddressPostalCode:r,billingEmail:i,billingName:o,name:o,hasRecurringNeed:a}}function D_(){const{locale:e}=du(),t=a.useClient();return{funnelCheckout:async n=>{var r;try{const i=await((e,{client:t})=>t.mutation(Vb,{attributes:e}).toPromise())({userAttributes:{email:n.email,firstName:n.first_name,lastName:n.last_name,phone:n.phone,language:O_[e]||O_.de},accountAttributes:$_(n),opportunityAttributes:Zb(n)},{client:t});if(!(null==(r=null==i?void 0:i.data)?void 0:r.funnelCheckout)){const e=new Error("funnelCheckout returned no data");throw i_.notify(e,e=>{e.addMetadata("funnelCheckoutArgs",n),e.addMetadata("funnelCheckoutResult",i)}),e}return i.data.funnelCheckout}catch(i){throw i instanceof Error&&i_.notify(i,e=>{e.addMetadata("funnelCheckoutArgs",n)}),i}}}}function z_(){const e=a.useClient();return{createQfLead:async t=>{try{const{company:n,comment:r,deliveryAddressCity:i,deliveryAddressCountry:o,deliveryAddressPostalCode:a,deliveryAddressStreet:s,deliveryAddressStreetNumber:l,email:u,first_name:c,last_name:d,phone:f,catering_categories:p,event_date:h,has_recurring_need:m,is_multi_day:g,number_of_carnivore:y,lead_type:v,number_of_vegans:b,number_of_vegetarians:x,price_per_person:C,service_type:w,team_size:L,delivery_frequency:k,budget_range:j,leadSource:M,conversionUrl:S,entranceUrl:_,referrerUrl:E,landingPageSource:O}=t,$=b+x+y,{data:{createQfLead:D}}=await((e,{client:t})=>t.mutation(Ub,{attributes:e}).toPromise())({email:u,firstName:c,lastName:d,phone:f,company:n,comment:r,address:`${s} ${l}, ${a} ${i}, ${o}`,cateringCategories:p,eventDate:new Date(h).toDateString(),hasRecurringNeed:m,isMultiDay:g,numberOfOmnivores:y,numberOfVegans:b,numberOfVegetarians:x,numberOfPeople:$,totalBudget:$*C,leadType:v,serviceType:w,teamSize:L,deliveryFrequency:k,budgetRange:j,leadSource:M,conversionUrl:S,entranceUrl:_,referrerUrl:E,landingPageSource:O},{client:e});return D}catch(n){n&&i_.notify(n,e=>{e.addMetadata("createQfLead",t)})}}}}const A_=e=>{const t=document.cookie.match(new RegExp("(^| )"+e+"=([^;]+)"));return t?decodeURIComponent(t[2]):void 0};function T_(){const{state:e}=Mf(),t="qualification"in e?e.qualification:null,n=a.useClient(),{currentUserAccount:r}=Lf(),i=du(),{funnelCheckout:o}=D_(),{createQfLead:s}=z_(),l=e=>{var n,o,a,s;const l=`${e.deliveryAddressStreet} ${e.deliveryAddressStreetNumber}`,{street:u,postalCode:c,city:d,country:f}=(null==(o=null==(n=null==r?void 0:r.owner)?void 0:n.salesforceCustomer)?void 0:o.billingAddress)||{street:l,postalCode:e.deliveryAddressPostalCode,city:e.deliveryAddressCity,country:e.deliveryAddressCountry};if(!t)throw new Error("cannot create an opportunity outside of the qualification");const p=(null==(a=t.leadSource)?void 0:a.includes("/events"))?"events-landingpage":"Qualification Funnel",h=t.answers,m=!!h.event_type,g=h.min_order_number||0,y=m?{number_of_carnivore:g,number_of_vegans:0,number_of_vegetarians:0}:{};return{...h,...y,...e,phone:e.phone||"",catererSlug:null==(s=null==t?void 0:t.selectedCaterer)?void 0:s.slug,landingPageSource:t.leadSource,billingAddressStreetAndNumber:u||"",billingAddressPostalCode:c||"",billingAddressCity:d||"",billingCountry:f||"",conversion_url:window.location.href,deliveryAddressStreetAndNumber:l,deliveryCountry:e.deliveryAddressCountry,lead_language:i.locale,leadSource:p,commentByHeycaterForCaterer:e.comment}};return{submitAsNewCustomer:async e=>{var n,r;const i=null==(n=null==t?void 0:t.answers)?void 0:n.service_type,a="regular_employee_catering"===i||"full_service_event"===i,{deliveryAddressCountry:u}=e,c=["United Kingdom","Great Britain","UK"].includes(u);if(a||c)try{const n=(null==(r=null==t?void 0:t.leadSource)?void 0:r.includes("/events"))?"events-landingpage":"Qualification Funnel",i=(null==t?void 0:t.answers)||{},o=await s({...e,...i,leadSource:n,conversionUrl:window.location.href,entranceUrl:A_("entrance_url"),referrerUrl:A_("referrer_url"),landingPageSource:null==t?void 0:t.leadSource});if(!o)return console.error("[HeyCater Funnel] createQfLead returned undefined/null"),{success:!1,isUkLead:c};const{success:a}=o;return void 0===a&&console.error("[HeyCater Funnel] createQfLead response missing success field:",o),{success:a,isUkLead:c}}catch(d){return console.error("[HeyCater Funnel] createQfLead failed:",d),{success:!1,isUkLead:c}}else try{const t=await o(l(e));return{signInToken:t.signInToken,customerAccount:t.customerAccount,opportunity:t.opportunity,isUkLead:!1}}catch(d){throw console.error("[HeyCater Funnel] funnelCheckout failed:",d),d}},submitAsExistingCustomer:async e=>{const t=l(e),{createOpportunity:{opportunity:r}}=await async function(e,{client:t}){const n=Zb(e),{data:r}=await t.mutation(Bb,{attributes:n}).toPromise();return r}(t,{client:n});return r}}}const P_="qualification-request-form",F_={},R_=/^\+?[1-9]\d{6,14}$/,I_=({isLoggedIn:e})=>au.object().shape({first_name:au.string().required(),last_name:au.string().required(),company:au.string().required(),email:au.string().required().email(),phone:e?au.string():au.string().matches(R_,"Invalid phone number").required(),deliveryAddressStreet:au.string().min(1).required(),deliveryAddressStreetNumber:au.string().min(1).required(),deliveryAddressPostalCode:au.string().min(1).required(),deliveryAddressCity:au.string().min(1).required(),deliveryAddressCountry:au.string().min(1).required(),comment:au.string()});function N_({header:e=null}){var o,a,s;const[l,u]=n.useState(!1),[d,p]=n.useState(!1),{t:h}=i.useTranslation("qualification"),{submitAsNewCustomer:m,submitAsExistingCustomer:g}=T_(),y=Jf({display:"all-answers"}),b=Af("xs"),{state:x}=Mf(),{ref:C,isFloating:L,height:k}=function(){var e,t;const{inView:n,ref:r,entry:i}=f.useInView({threshold:1}),o=(null==(e=null==i?void 0:i.boundingClientRect)?void 0:e.height)||0,a=!i||(null==(t=i.boundingClientRect)?void 0:t.y)>0;return{height:o,isFloating:!n&&a,ref:r}}(),{validateAddress:j}=a_({cacheValidations:F_}),M=b&&L,S="qualification"in x?x.qualification:null,{actions:_}=Mf(),{currentUserAccount:E}=Lf(),O=du(),[D,z]=n.useState(!1),{deliveryAddressStreetAndNumber:A,deliveryAddressPostalCode:T,deliveryAddressCity:P,deliveryAddressCountry:F}=(null==E?void 0:E.owner)||{},[R,I]=n.useState(""),[N,q]=n.useState(""),Z=E?(({street:e,postalCode:t,city:n,country:r})=>[e,t,n,r].filter(Boolean).join(", "))({street:A,postalCode:T,city:P,country:F}):"";n.useEffect(()=>{!async function(){if(!Z)return;const{streetName:e,streetNumber:t}=await j(Z);I(e),q(t)}()},[Z]);const{funnelContextRef:B}=Hp(),W=({isFormValid:e})=>{const n=t.jsxs(w,{id:"request-form__submit-btn",block:"true","data-logged-in":!!E,"data-valid":e,"data-leadsource":"qualification"in x?x.qualification.leadSource:void 0,size:"lg",type:"submit",disabled:D,children:[D&&t.jsx(v,{mr:2,style:{alignItems:"flex-start"},children:t.jsx(r.CircularProgress,{style:{verticalAlign:"sub"},size:20,color:"inherit"})}),h("request.form.submit")]});return b?t.jsx(E_,{height:k,isFloating:M,children:t.jsx(V_,{py:2,px:M&&2,$floating:M,children:n})}):t.jsx(v,{position:"absolute",bottom:"0",left:"0",right:"0",py:2,px:2,bgcolor:"white",children:n})},V={first_name:(null==E?void 0:E.firstName)||"",last_name:(null==E?void 0:E.lastName)||"",company:(null==(o=null==E?void 0:E.owner)?void 0:o.companyName)||"",deliveryAddressStreet:R||"",deliveryAddressStreetNumber:N||"",deliveryAddressPostalCode:T||"",deliveryAddressCity:P||"",deliveryAddressCountry:F||"",email:(null==E?void 0:E.email)||"",phone:(null==(s=null==(a=null==E?void 0:E.owner)?void 0:a.salesforceCustomer)?void 0:s.phoneNumber)||""},U=!!E;return l?t.jsx(k_,{isUkLead:d}):t.jsxs(v_,{children:[e,t.jsx(c.Formik,{initialValues:V,validationSchema:I_({isLoggedIn:U}),onSubmit:async e=>{var t;z(!0);const n=null==(t=null==S?void 0:S.answers)?void 0:t.service_type,r=B.current.service_type;console.log("[Optimeleon Debug] handleSubmit called",{serviceType:n,serviceTypeType:typeof n,serviceTypeLength:null==n?void 0:n.length,serviceTypeFromContext:r,contextServiceTypeType:typeof r,allAnswers:JSON.stringify(null==S?void 0:S.answers),funnelContext:JSON.stringify(B.current)});const i=n||r;console.log("[Optimeleon Debug] About to track funnel_form_submitted with:",i),Zp("funnel_form_submitted",i);const o="regular_employee_catering"===n||"full_service_event"===n,{deliveryAddressCountry:a}=e,s=["United Kingdom","Great Britain","UK"].includes(a);if(o||s){const t=await m(e),{success:n}=t;return n?(p(s),u(!0),Ip(B.current,{is_uk_lead:s}),Np(B.current),console.log("[Optimeleon Debug] Lead-only flow - tracking funnel_completed with:",i),Zp("funnel_completed",i),void Bp("submit_qf_request")):(console.error("[HeyCater Funnel] Lead submission failed. Result:",t),void z(!1))}let l="",c="";if(E)try{const t=await g(e);if(!t||!t.id)return console.error("[HeyCater Funnel] submitAsExistingCustomer returned invalid opportunity:",t),void z(!1);c=t.userId,l=`/account/requests/${t.id}`}catch(d){return d instanceof Error&&i_.notify(d),void z(!1)}else{const t=await m(e),{signInToken:n,opportunity:r}=t||{};if(!r||!r.id)return console.error("[HeyCater Funnel] submitAsNewCustomer returned invalid opportunity:",t),void z(!1);c=r.userId,l=n?`/${O.locale}/account/requests/${r.id}?one_time_sign_in_token=${n}`:`/${O.locale}/account/external/requests/${r.id}`}c&&(function(e){if("undefined"==typeof window)return;const{googleTagId:t}=bu();if(window.gtag&&t)try{window.gtag("config",t,{user_id:e})}catch(n){console.error("[gtag] Failed to identify user:",n)}}(c),function(e){"undefined"!=typeof window&&(window.dataLayer=window.dataLayer||[],window.dataLayer.push({userId:e}))}(c)),Ip(B.current,{is_logged_in:!!E}),Np(B.current),console.log("[Optimeleon Debug] Regular flow - tracking funnel_completed with:",i),Zp("funnel_completed",i),Bp("submit_qf_request"),_.setRequest(e),((e="/")=>{window.location.href=`${bu().customerAppHost}${e}`})(l)},enableReinitialize:!0,children:e=>{var n,r;return t.jsxs(W_,{id:P_,name:P_,children:[t.jsxs(q_,{children:[t.jsx(Z_,{$half:!0,children:t.jsx(c.Field,{required:!0,name:"first_name",label:h("request.form.firstName"),placeholder:h("request.form.firstName"),component:C_})}),t.jsx(Z_,{$half:!0,children:t.jsx(c.Field,{required:!0,name:"last_name",label:h("request.form.lastName"),placeholder:h("request.form.lastName"),component:C_})})]}),t.jsx(q_,{children:t.jsx(Z_,{$half:!0,children:t.jsx(c.Field,{required:!0,name:"company",label:h("request.form.company"),placeholder:h("request.form.company"),component:C_})})}),t.jsx(q_,{children:t.jsx(Z_,{children:t.jsx(c.Field,{required:!0,name:"delivery_address",label:h("request.form.deliveryAddress"),placeholder:h("request.form.deliveryAddress"),helperText:h("request.form.helpText.address"),defaultValue:Z,component:c_})})}),t.jsxs(q_,{children:[!E&&t.jsx(Z_,{$half:!0,children:t.jsx(c.Field,{required:!0,type:"email",name:"email",label:h("request.form.email"),placeholder:h("request.form.email"),helperText:h("request.form.helpText.email"),component:C_})}),!(null==(r=null==(n=null==E?void 0:E.owner)?void 0:n.salesforceCustomer)?void 0:r.phoneNumber)&&t.jsx(Z_,{$half:!0,children:t.jsx(w_,{label:h("request.form.phone"),name:"phone",formik:e,helperText:h("request.form.helpText.phone")})})]}),t.jsx(q_,{children:t.jsx(Z_,{children:t.jsx(c.Field,{name:"comment",label:h("request.form.comment"),placeholder:h("request.form.commentPlaceholder"),component:C_,multiline:!0})})}),t.jsx(c.Field,{type:"hidden",name:"deliveryAddressStreet"}),t.jsx(c.Field,{type:"hidden",name:"deliveryAddressStreetNumber"}),t.jsx(c.Field,{type:"hidden",name:"deliveryAddressPostalCode"}),t.jsx(c.Field,{type:"hidden",name:"deliveryAddressCity"}),t.jsx(c.Field,{type:"hidden",name:"deliveryAddressCountry"}),t.jsxs(v,{mt:2,mb:4,display:"flex",flexDirection:"column",children:[t.jsx($,{variant:"caption",fontWeight:500,fontSize:12,px:1,mr:1.5,mb:1,children:h("selection.yourSelection")}),t.jsx(B_,{children:y.map(e=>t.jsx(Yf,{size:"sm",stepId:e.stepId,text:e.text||""},`${e.stepId}_${e.text}`))})]}),t.jsx(v,{ref:C,children:t.jsx(W,{isFormValid:e.isValid})})]})}})]})}const q_=o.div`
|
|
1351
1351
|
display: flex;
|
|
1352
1352
|
flex-wrap: wrap;
|
|
1353
1353
|
margin: 0 -${({theme:e})=>e.spacing(1)}px;
|
|
@@ -2532,19 +2532,17 @@ object-assign
|
|
|
2532
2532
|
from { opacity: 0; transform: translateY(8px); }
|
|
2533
2533
|
to { opacity: 1; transform: none; }
|
|
2534
2534
|
`,zD=o.div`
|
|
2535
|
+
position: fixed;
|
|
2536
|
+
inset: 0;
|
|
2535
2537
|
display: flex;
|
|
2536
|
-
min-height: 100vh;
|
|
2537
|
-
min-height: 100dvh;
|
|
2538
2538
|
background: ${LE};
|
|
2539
|
+
z-index: 1000;
|
|
2539
2540
|
`,AD=o.div`
|
|
2540
2541
|
flex: 1;
|
|
2541
2542
|
display: flex;
|
|
2542
2543
|
flex-direction: column;
|
|
2543
2544
|
min-width: 0;
|
|
2544
|
-
|
|
2545
|
-
height: 100vh;
|
|
2546
|
-
height: 100dvh;
|
|
2547
|
-
overflow: hidden;
|
|
2545
|
+
overflow-y: auto;
|
|
2548
2546
|
${({$fullWidth:e})=>e&&"width: 100%;"}
|
|
2549
2547
|
`,TD=o.div`
|
|
2550
2548
|
flex: none;
|
|
@@ -2612,7 +2610,6 @@ object-assign
|
|
|
2612
2610
|
flex-direction: column;
|
|
2613
2611
|
align-items: center;
|
|
2614
2612
|
justify-content: flex-start;
|
|
2615
|
-
overflow-y: auto;
|
|
2616
2613
|
padding: 14px 18px 20px;
|
|
2617
2614
|
animation: ${DD} 0.34s cubic-bezier(0.2, 0.8, 0.2, 1) both;
|
|
2618
2615
|
|
|
@@ -2659,7 +2656,8 @@ object-assign
|
|
|
2659
2656
|
margin-top: 32px;
|
|
2660
2657
|
}
|
|
2661
2658
|
`,KD=o.div`
|
|
2662
|
-
|
|
2659
|
+
position: sticky;
|
|
2660
|
+
bottom: 0;
|
|
2663
2661
|
padding: 12px 18px 16px;
|
|
2664
2662
|
display: flex;
|
|
2665
2663
|
flex-direction: column;
|
|
@@ -2668,6 +2666,7 @@ object-assign
|
|
|
2668
2666
|
border-top: 1px solid #f0f0f0;
|
|
2669
2667
|
background: ${LE};
|
|
2670
2668
|
z-index: 10;
|
|
2669
|
+
margin-top: auto;
|
|
2671
2670
|
|
|
2672
2671
|
@media (min-width: 960px) {
|
|
2673
2672
|
padding: 16px 44px 22px;
|
package/dist/index.esm.js
CHANGED
|
@@ -26840,10 +26840,9 @@ function useFunnelCheckout() {
|
|
|
26840
26840
|
const { locale: locale2 } = useRouter();
|
|
26841
26841
|
const client = useClient();
|
|
26842
26842
|
const funnelCheckout = async (variables) => {
|
|
26843
|
+
var _a2;
|
|
26843
26844
|
try {
|
|
26844
|
-
const
|
|
26845
|
-
data: { funnelCheckout: response }
|
|
26846
|
-
} = await funnelCheckoutMutation(
|
|
26845
|
+
const result = await funnelCheckoutMutation(
|
|
26847
26846
|
{
|
|
26848
26847
|
userAttributes: {
|
|
26849
26848
|
email: variables.email,
|
|
@@ -26857,13 +26856,22 @@ function useFunnelCheckout() {
|
|
|
26857
26856
|
},
|
|
26858
26857
|
{ client }
|
|
26859
26858
|
);
|
|
26860
|
-
|
|
26859
|
+
if (!((_a2 = result == null ? void 0 : result.data) == null ? void 0 : _a2.funnelCheckout)) {
|
|
26860
|
+
const error = new Error("funnelCheckout returned no data");
|
|
26861
|
+
BugsnagExport.notify(error, (event) => {
|
|
26862
|
+
event.addMetadata("funnelCheckoutArgs", variables);
|
|
26863
|
+
event.addMetadata("funnelCheckoutResult", result);
|
|
26864
|
+
});
|
|
26865
|
+
throw error;
|
|
26866
|
+
}
|
|
26867
|
+
return result.data.funnelCheckout;
|
|
26861
26868
|
} catch (error) {
|
|
26862
26869
|
if (error instanceof Error) {
|
|
26863
26870
|
BugsnagExport.notify(error, (event) => {
|
|
26864
26871
|
event.addMetadata("funnelCheckoutArgs", variables);
|
|
26865
26872
|
});
|
|
26866
26873
|
}
|
|
26874
|
+
throw error;
|
|
26867
26875
|
}
|
|
26868
26876
|
};
|
|
26869
26877
|
return {
|
|
@@ -27051,17 +27059,18 @@ function useRequestForm() {
|
|
|
27051
27059
|
return { success: false, isUkLead };
|
|
27052
27060
|
}
|
|
27053
27061
|
} else {
|
|
27054
|
-
|
|
27055
|
-
|
|
27056
|
-
|
|
27057
|
-
|
|
27058
|
-
|
|
27059
|
-
|
|
27060
|
-
|
|
27061
|
-
|
|
27062
|
-
|
|
27063
|
-
|
|
27064
|
-
|
|
27062
|
+
try {
|
|
27063
|
+
const result = await funnelCheckout(buildOpportunityPayload(values2));
|
|
27064
|
+
return {
|
|
27065
|
+
signInToken: result.signInToken,
|
|
27066
|
+
customerAccount: result.customerAccount,
|
|
27067
|
+
opportunity: result.opportunity,
|
|
27068
|
+
isUkLead: false
|
|
27069
|
+
};
|
|
27070
|
+
} catch (error) {
|
|
27071
|
+
console.error("[HeyCater Funnel] funnelCheckout failed:", error);
|
|
27072
|
+
throw error;
|
|
27073
|
+
}
|
|
27065
27074
|
}
|
|
27066
27075
|
};
|
|
27067
27076
|
return {
|
|
@@ -32609,20 +32618,18 @@ const fadeIn = keyframes`
|
|
|
32609
32618
|
to { opacity: 1; transform: none; }
|
|
32610
32619
|
`;
|
|
32611
32620
|
const FunnelContainer = styled.div`
|
|
32621
|
+
position: fixed;
|
|
32622
|
+
inset: 0;
|
|
32612
32623
|
display: flex;
|
|
32613
|
-
min-height: 100vh;
|
|
32614
|
-
min-height: 100dvh;
|
|
32615
32624
|
background: ${REDESIGN_COLORS.white};
|
|
32625
|
+
z-index: 1000;
|
|
32616
32626
|
`;
|
|
32617
32627
|
const MainContent = styled.div`
|
|
32618
32628
|
flex: 1;
|
|
32619
32629
|
display: flex;
|
|
32620
32630
|
flex-direction: column;
|
|
32621
32631
|
min-width: 0;
|
|
32622
|
-
|
|
32623
|
-
height: 100vh;
|
|
32624
|
-
height: 100dvh;
|
|
32625
|
-
overflow: hidden;
|
|
32632
|
+
overflow-y: auto;
|
|
32626
32633
|
${({ $fullWidth }) => $fullWidth && "width: 100%;"}
|
|
32627
32634
|
`;
|
|
32628
32635
|
const MobileHeader = styled.div`
|
|
@@ -32701,7 +32708,6 @@ const ContentArea = styled.div`
|
|
|
32701
32708
|
flex-direction: column;
|
|
32702
32709
|
align-items: center;
|
|
32703
32710
|
justify-content: flex-start;
|
|
32704
|
-
overflow-y: auto;
|
|
32705
32711
|
padding: 14px 18px 20px;
|
|
32706
32712
|
animation: ${fadeIn} 0.34s cubic-bezier(0.2, 0.8, 0.2, 1) both;
|
|
32707
32713
|
|
|
@@ -32752,7 +32758,8 @@ const StepContent = styled.div`
|
|
|
32752
32758
|
}
|
|
32753
32759
|
`;
|
|
32754
32760
|
const FooterBar = styled.div`
|
|
32755
|
-
|
|
32761
|
+
position: sticky;
|
|
32762
|
+
bottom: 0;
|
|
32756
32763
|
padding: 12px 18px 16px;
|
|
32757
32764
|
display: flex;
|
|
32758
32765
|
flex-direction: column;
|
|
@@ -32761,6 +32768,7 @@ const FooterBar = styled.div`
|
|
|
32761
32768
|
border-top: 1px solid #f0f0f0;
|
|
32762
32769
|
background: ${REDESIGN_COLORS.white};
|
|
32763
32770
|
z-index: 10;
|
|
32771
|
+
margin-top: auto;
|
|
32764
32772
|
|
|
32765
32773
|
@media (min-width: 960px) {
|
|
32766
32774
|
padding: 16px 44px 22px;
|