@heycater/qualification-funnel 1.3.16 → 1.3.18

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.
@@ -1455,7 +1455,7 @@
1455
1455
  justify-content: center;
1456
1456
  background-size: cover;
1457
1457
  background-position: bottom center;
1458
- `;var XV=new Map,eB=new WeakMap,tB=0;function nB(e){return Object.keys(e).sort().filter(function(t){return void 0!==e[t]}).map(function(t){return t+"_"+("root"===t?(n=e.root)?(eB.has(n)||(tB+=1,eB.set(n,tB.toString())),eB.get(n)):"0":e[t]);var n}).toString()}function rB(e,t,n,r){if(void 0===n&&(n={}),void 0===r&&(r=void 0),void 0===window.IntersectionObserver&&void 0!==r){var o=e.getBoundingClientRect();return t(r,{isIntersecting:r,target:e,intersectionRatio:"number"==typeof n.threshold?n.threshold:0,time:0,boundingClientRect:o,intersectionRect:o,rootBounds:o}),function(){}}var i=function(e){var t=nB(e),n=XV.get(t);if(!n){var r,o=new Map,i=new IntersectionObserver(function(t){t.forEach(function(t){var n,i=t.isIntersecting&&r.some(function(e){return t.intersectionRatio>=e});e.trackVisibility&&void 0===t.isVisible&&(t.isVisible=i),null==(n=o.get(t.target))||n.forEach(function(e){e(i,t)})})},e);r=i.thresholds||(Array.isArray(e.threshold)?e.threshold:[e.threshold||0]),n={id:t,observer:i,elements:o},XV.set(t,n)}return n}(n),a=i.id,l=i.observer,s=i.elements,u=s.get(e)||[];return s.has(e)||s.set(e,u),u.push(t),l.observe(e),function(){u.splice(u.indexOf(t),1),0===u.length&&(s.delete(e),l.unobserve(e)),0===s.size&&(l.disconnect(),XV.delete(a))}}const oB=({children:e,height:t,isFloating:n,...r})=>x.jsxs(x.Fragment,{children:[x.jsx(pm,{display:"flex",flexDirection:"column",flexGrow:"1",bottom:"0",left:"0",right:"0",position:n?"fixed":"relative",...r,children:e}),n&&x.jsx("div",{style:{height:`${t}px`}})]});function iB(){var e,t;const{inView:n,ref:r,entry:o}=function(e){var t=void 0===e?{}:e,n=t.threshold,r=t.delay,o=t.trackVisibility,i=t.rootMargin,a=t.root,l=t.triggerOnce,s=t.skip,u=t.initialInView,c=t.fallbackInView,d=m.useRef(),f=m.useState({inView:!!u}),p=f[0],h=f[1],g=m.useCallback(function(e){void 0!==d.current&&(d.current(),d.current=void 0),s||e&&(d.current=rB(e,function(e,t){h({inView:e,entry:t}),t.isIntersecting&&l&&d.current&&(d.current(),d.current=void 0)},{root:a,rootMargin:i,threshold:n,trackVisibility:o,delay:r},c))},[Array.isArray(n)?n.toString():n,a,i,l,s,o,c,r]);m.useEffect(function(){d.current||!p.entry||l||s||h({inView:!!u})});var v=[g,p.inView,p.entry];return v.ref=v[0],v.inView=v[1],v.entry=v[2],v}({threshold:1}),i=(null==(e=null==o?void 0:o.boundingClientRect)?void 0:e.height)||0,a=!o||(null==(t=o.boundingClientRect)?void 0:t.y)>0;return{height:i,isFloating:!n&&a,ref:r}}const aB={de:"German",en:"English"};function lB(e){const{billingAddressStreetAndNumber:t,billingAddressCity:n,billingAddressPostalCode:r,email:o,company:i,has_recurring_need:a}=e;return{billingAddressStreetAndNumber:t,billingAddressCity:n,billingAddressPostalCode:r,billingEmail:o,billingName:i,name:i,hasRecurringNeed:a}}function sB(){const{locale:e}=XS(),t=om();return{funnelCheckout:async n=>{try{const{data:{funnelCheckout:r}}=await((e,{client:t})=>t.mutation(pF,{attributes:e}).toPromise())({userAttributes:{email:n.email,firstName:n.first_name,lastName:n.last_name,phone:n.phone,language:aB[e]||aB.de},accountAttributes:lB(n),opportunityAttributes:cF(n)},{client:t});return r}catch(r){r instanceof Error&&MV.notify(r,e=>{e.addMetadata("funnelCheckoutArgs",n)})}}}}function uB(){const e=om();return{createQfLead:async t=>{try{const{company:n,comment:r,deliveryAddressCity:o,deliveryAddressCountry:i,deliveryAddressPostalCode:a,deliveryAddressStreet:l,deliveryAddressStreetNumber:s,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:v,lead_type:y,number_of_vegans:b,number_of_vegetarians:w,price_per_person:x,service_type:C,team_size:k,delivery_frequency:S,budget_range:E,people_count:L}=t,_=null!=b&&null!=w&&null!=v?b+w+v:L||k||null,M=_&&x?_*x:null,{data:{createQfLead:j}}=await((e,{client:t})=>t.mutation(hF,{attributes:e}).toPromise())({email:u,firstName:c,lastName:d,phone:f,company:n,comment:r,address:`${l} ${s}, ${a} ${o}, ${i}`,cateringCategories:p||null,eventDate:h?new Date(h).toDateString():null,hasRecurringNeed:m||null,isMultiDay:g||null,numberOfOmnivores:v||null,numberOfVegans:b||null,numberOfVegetarians:w||null,numberOfPeople:_,totalBudget:M,leadType:y||null,serviceType:C,teamSize:k||null,deliveryFrequency:S||null,budgetRange:E||null},{client:e});return j}catch(n){n&&MV.notify(n,e=>{e.addMetadata("createQfLead",t)})}}}}function cB(){const{state:e}=yM(),t="qualification"in e?e.qualification:null,n=om(),{currentUserAccount:r}=mM(),o=XS(),{funnelCheckout:i}=sB(),{createQfLead:a}=uB(),l=e=>{var n,i,a,l,s;const u=`${e.deliveryAddressStreet} ${e.deliveryAddressStreetNumber}`,{street:c,postalCode:d,city:f,country:p}=(null==(i=null==(n=null==r?void 0:r.owner)?void 0:n.salesforceCustomer)?void 0:i.billingAddress)||{street:u,postalCode:e.deliveryAddressPostalCode,city:e.deliveryAddressCity,country:e.deliveryAddressCountry};if(!t)throw new Error("cannot create an opportunity outside of the qualification");const h=(null==(a=t.leadSource)?void 0:a.includes("/events"))?"events-landingpage":"Qualification Funnel";return{...t.answers,...e,phone:e.phone||"",catererSlug:null==(l=null==t?void 0:t.selectedCaterer)?void 0:l.slug,landingPageSource:t.leadSource,billingAddressStreetAndNumber:c||"",inspiredByMenuId:null==(s=null==t?void 0:t.selectedMenu)?void 0:s.id,billingAddressPostalCode:d||"",billingAddressCity:f||"",billingCountry:p||"",conversion_url:window.location.href,deliveryAddressStreetAndNumber:u,deliveryCountry:e.deliveryAddressCountry,lead_language:o.locale,leadSource:h,commentByHeycaterForCaterer:e.comment}};return{submitAsNewCustomer:async e=>{var n;const r=null==(n=null==t?void 0:t.answers)?void 0:n.service_type,o="regular_employee_catering"===r||"full_service_event"===r,{deliveryAddressCountry:s}=e,u=["United Kingdom","Great Britain","UK"].includes(s);if(o||u){const{success:n}=await a({...e,...null==t?void 0:t.answers});return{success:n,isUkLead:!0}}{const{signInToken:t,customerAccount:n,opportunity:r}=await i(l(e));return{signInToken:t,customerAccount:n,opportunity:r,isUkLead:!1}}},submitAsExistingCustomer:async e=>{const t=l(e),{createOpportunity:{opportunity:r}}=await async function(e,{client:t}){const n=cF(e),{data:r}=await t.mutation(dF,{attributes:n}).toPromise();return r}(t,{client:n});return r}}}const dB="qualification-request-form",fB={},pB=/^\+?[1-9]\d{6,14}$/,hB=({isLoggedIn:e})=>vS.object().shape({first_name:vS.string().required(),last_name:vS.string().required(),company:vS.string().required(),email:vS.string().required().email(),phone:e?vS.string():vS.string().matches(pB,"Invalid phone number").required(),deliveryAddressStreet:vS.string().min(1).required(),deliveryAddressStreetNumber:vS.string().min(1).required(),deliveryAddressPostalCode:vS.string().min(1).required(),deliveryAddressCity:vS.string().min(1).required(),deliveryAddressCountry:vS.string().min(1).required(),comment:vS.string()});function mB({header:e=null}){var t,n,r;const[o,i]=m.useState(!1),{t:a}=Sd("qualification"),{submitAsNewCustomer:l,submitAsExistingCustomer:s}=cB(),u=WM({display:"all-answers"}),c=LM("xs"),{state:d}=yM(),{ref:f,isFloating:p,height:h}=iB(),{validateAddress:g}=OV({cacheValidations:fB}),v=c&&p,y="qualification"in d?d.qualification:null,{actions:b}=yM(),{currentUserAccount:w}=mM(),C=XS(),[k,S]=m.useState(!1),{deliveryAddressStreetAndNumber:E,deliveryAddressPostalCode:L,deliveryAddressCity:_,deliveryAddressCountry:M}=(null==w?void 0:w.owner)||{},[j,O]=m.useState(""),[P,T]=m.useState(""),D=w?(({street:e,postalCode:t,city:n,country:r})=>[e,t,n,r].filter(Boolean).join(", "))({street:E,postalCode:L,city:_,country:M}):"";m.useEffect(()=>{!async function(){if(!D)return;const{streetName:e,streetNumber:t}=await g(D);O(e),T(t)}()},[D]);const R=({isFormValid:e})=>{const t=x.jsxs(vm,{id:"request-form__submit-btn",block:"true","data-logged-in":!!w,"data-valid":e,"data-leadsource":"qualification"in d?d.qualification.leadSource:void 0,size:"lg",type:"submit",disabled:k,children:[k&&x.jsx(pm,{mr:2,style:{alignItems:"flex-start"},children:x.jsx(Il,{style:{verticalAlign:"sub"},size:20,color:"inherit"})}),a("request.form.submit")]});return c?x.jsx(oB,{height:h,isFloating:v,children:x.jsx(wB,{py:2,px:v&&2,$floating:v,children:t})}):x.jsx(pm,{position:"absolute",bottom:"0",left:"0",right:"0",py:2,px:2,bgcolor:"white",children:t})},N={first_name:(null==w?void 0:w.firstName)||"",last_name:(null==w?void 0:w.lastName)||"",company:(null==(t=null==w?void 0:w.owner)?void 0:t.companyName)||"",deliveryAddressStreet:j||"",deliveryAddressStreetNumber:P||"",deliveryAddressPostalCode:L||"",deliveryAddressCity:_||"",deliveryAddressCountry:M||"",email:(null==w?void 0:w.email)||"",phone:(null==(r=null==(n=null==w?void 0:w.owner)?void 0:n.salesforceCustomer)?void 0:r.phoneNumber)||""},A=!!w;return o?x.jsx(YV,{}):x.jsxs(BV,{children:[e,x.jsx(q$,{initialValues:N,validationSchema:hB({isLoggedIn:A}),onSubmit:async e=>{var t,n;S(!0);let r="";if(w)try{r=`/account/requests/${(await s(e)).id}`}catch(o){o instanceof Error&&MV.notify(o)}else{const{signInToken:n,opportunity:o,isUkLead:a,success:s}=await l(e);if(s&&a)return i(!0),window.gtag&&window.gtag("event","submit_qf_request"),void(null==(t=window.dataLayer)||t.push({event:"funnel_form_submit"}));r=n?`/${C.locale}/account/requests/${o.id}?one_time_sign_in_token=${n}`:`/${C.locale}/account/external/requests/${o.id}`}null==y||y.selectedMenu,window.gtag&&window.gtag("event","submit_qf_request"),null==(n=window.dataLayer)||n.push({event:"funnel_form_submit"}),b.setRequest(e),((e="/")=>{window.location.href=`${lE().customerAppHost}${e}`})(r)},enableReinitialize:!0,children:e=>{var t,n;return x.jsxs(bB,{id:dB,name:dB,children:[x.jsxs(gB,{children:[x.jsx(vB,{$half:!0,children:x.jsx(G$,{required:!0,name:"first_name",label:a("request.form.firstName"),placeholder:a("request.form.firstName"),component:UV})}),x.jsx(vB,{$half:!0,children:x.jsx(G$,{required:!0,name:"last_name",label:a("request.form.lastName"),placeholder:a("request.form.lastName"),component:UV})})]}),x.jsx(gB,{children:x.jsx(vB,{$half:!0,children:x.jsx(G$,{required:!0,name:"company",label:a("request.form.company"),placeholder:a("request.form.company"),component:UV})})}),x.jsx(gB,{children:x.jsx(vB,{children:x.jsx(G$,{required:!0,name:"delivery_address",label:a("request.form.deliveryAddress"),placeholder:a("request.form.deliveryAddress"),helperText:a("request.form.helpText.address"),defaultValue:D,component:RV})})}),x.jsxs(gB,{children:[!w&&x.jsx(vB,{$half:!0,children:x.jsx(G$,{required:!0,type:"email",name:"email",label:a("request.form.email"),placeholder:a("request.form.email"),helperText:a("request.form.helpText.email"),component:UV})}),!(null==(n=null==(t=null==w?void 0:w.owner)?void 0:t.salesforceCustomer)?void 0:n.phoneNumber)&&x.jsx(vB,{$half:!0,children:x.jsx(HV,{label:a("request.form.phone"),name:"phone",formik:e,helperText:a("request.form.helpText.phone")})})]}),x.jsx(gB,{children:x.jsx(vB,{children:x.jsx(G$,{name:"comment",label:a("request.form.comment"),placeholder:a("request.form.commentPlaceholder"),component:UV,multiline:!0})})}),x.jsx(G$,{type:"hidden",name:"deliveryAddressStreet"}),x.jsx(G$,{type:"hidden",name:"deliveryAddressStreetNumber"}),x.jsx(G$,{type:"hidden",name:"deliveryAddressPostalCode"}),x.jsx(G$,{type:"hidden",name:"deliveryAddressCity"}),x.jsx(G$,{type:"hidden",name:"deliveryAddressCountry"}),x.jsxs(pm,{mt:2,mb:4,display:"flex",flexDirection:"column",children:[x.jsx(Lm,{variant:"caption",fontWeight:500,fontSize:12,px:1,mr:1.5,mb:1,children:a("selection.yourSelection")}),x.jsx(yB,{children:u.map(e=>x.jsx(BM,{size:"sm",stepId:e.stepId,text:e.text||""},`${e.stepId}_${e.text}`))})]}),x.jsx(pm,{ref:f,children:x.jsx(R,{isFormValid:e.isValid})})]})}})]})}const gB=tp.div`
1458
+ `;var XV=new Map,eB=new WeakMap,tB=0;function nB(e){return Object.keys(e).sort().filter(function(t){return void 0!==e[t]}).map(function(t){return t+"_"+("root"===t?(n=e.root)?(eB.has(n)||(tB+=1,eB.set(n,tB.toString())),eB.get(n)):"0":e[t]);var n}).toString()}function rB(e,t,n,r){if(void 0===n&&(n={}),void 0===r&&(r=void 0),void 0===window.IntersectionObserver&&void 0!==r){var o=e.getBoundingClientRect();return t(r,{isIntersecting:r,target:e,intersectionRatio:"number"==typeof n.threshold?n.threshold:0,time:0,boundingClientRect:o,intersectionRect:o,rootBounds:o}),function(){}}var i=function(e){var t=nB(e),n=XV.get(t);if(!n){var r,o=new Map,i=new IntersectionObserver(function(t){t.forEach(function(t){var n,i=t.isIntersecting&&r.some(function(e){return t.intersectionRatio>=e});e.trackVisibility&&void 0===t.isVisible&&(t.isVisible=i),null==(n=o.get(t.target))||n.forEach(function(e){e(i,t)})})},e);r=i.thresholds||(Array.isArray(e.threshold)?e.threshold:[e.threshold||0]),n={id:t,observer:i,elements:o},XV.set(t,n)}return n}(n),a=i.id,l=i.observer,s=i.elements,u=s.get(e)||[];return s.has(e)||s.set(e,u),u.push(t),l.observe(e),function(){u.splice(u.indexOf(t),1),0===u.length&&(s.delete(e),l.unobserve(e)),0===s.size&&(l.disconnect(),XV.delete(a))}}const oB=({children:e,height:t,isFloating:n,...r})=>x.jsxs(x.Fragment,{children:[x.jsx(pm,{display:"flex",flexDirection:"column",flexGrow:"1",bottom:"0",left:"0",right:"0",position:n?"fixed":"relative",...r,children:e}),n&&x.jsx("div",{style:{height:`${t}px`}})]});function iB(){var e,t;const{inView:n,ref:r,entry:o}=function(e){var t=void 0===e?{}:e,n=t.threshold,r=t.delay,o=t.trackVisibility,i=t.rootMargin,a=t.root,l=t.triggerOnce,s=t.skip,u=t.initialInView,c=t.fallbackInView,d=m.useRef(),f=m.useState({inView:!!u}),p=f[0],h=f[1],g=m.useCallback(function(e){void 0!==d.current&&(d.current(),d.current=void 0),s||e&&(d.current=rB(e,function(e,t){h({inView:e,entry:t}),t.isIntersecting&&l&&d.current&&(d.current(),d.current=void 0)},{root:a,rootMargin:i,threshold:n,trackVisibility:o,delay:r},c))},[Array.isArray(n)?n.toString():n,a,i,l,s,o,c,r]);m.useEffect(function(){d.current||!p.entry||l||s||h({inView:!!u})});var v=[g,p.inView,p.entry];return v.ref=v[0],v.inView=v[1],v.entry=v[2],v}({threshold:1}),i=(null==(e=null==o?void 0:o.boundingClientRect)?void 0:e.height)||0,a=!o||(null==(t=o.boundingClientRect)?void 0:t.y)>0;return{height:i,isFloating:!n&&a,ref:r}}const aB={de:"German",en:"English"};function lB(e){const{billingAddressStreetAndNumber:t,billingAddressCity:n,billingAddressPostalCode:r,email:o,company:i,has_recurring_need:a}=e;return{billingAddressStreetAndNumber:t,billingAddressCity:n,billingAddressPostalCode:r,billingEmail:o,billingName:i,name:i,hasRecurringNeed:a}}function sB(){const{locale:e}=XS(),t=om();return{funnelCheckout:async n=>{try{const{data:{funnelCheckout:r}}=await((e,{client:t})=>t.mutation(pF,{attributes:e}).toPromise())({userAttributes:{email:n.email,firstName:n.first_name,lastName:n.last_name,phone:n.phone,language:aB[e]||aB.de},accountAttributes:lB(n),opportunityAttributes:cF(n)},{client:t});return r}catch(r){r instanceof Error&&MV.notify(r,e=>{e.addMetadata("funnelCheckoutArgs",n)})}}}}function uB(){const e=om();return{createQfLead:async t=>{try{const{company:n,comment:r,deliveryAddressCity:o,deliveryAddressCountry:i,deliveryAddressPostalCode:a,deliveryAddressStreet:l,deliveryAddressStreetNumber:s,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:v,lead_type:y,number_of_vegans:b,number_of_vegetarians:w,price_per_person:x,min_order_number:C,team_size:k}=t,S=null!=b&&null!=w&&null!=v?b+w+v:C||k||void 0,E=S&&x?S*x:void 0,{data:{createQfLead:L}}=await((e,{client:t})=>t.mutation(hF,{attributes:e}).toPromise())({email:u,firstName:c,lastName:d,phone:f,company:n,comment:r,address:`${l} ${s}, ${a} ${o}, ${i}`,cateringCategories:p,eventDate:h?new Date(h).toDateString():void 0,hasRecurringNeed:m,isMultiDay:g,numberOfOmnivores:v,numberOfVegans:b,numberOfVegetarians:w,numberOfPeople:S,totalBudget:E,leadType:y},{client:e});return L}catch(n){return n&&MV.notify(n,e=>{e.addMetadata("createQfLead",t)}),{success:!1}}}}}function cB(){const{state:e}=yM(),t="qualification"in e?e.qualification:null,n=om(),{currentUserAccount:r}=mM(),o=XS(),{funnelCheckout:i}=sB(),{createQfLead:a}=uB(),l=e=>{var n,i,a,l,s;const u=`${e.deliveryAddressStreet} ${e.deliveryAddressStreetNumber}`,{street:c,postalCode:d,city:f,country:p}=(null==(i=null==(n=null==r?void 0:r.owner)?void 0:n.salesforceCustomer)?void 0:i.billingAddress)||{street:u,postalCode:e.deliveryAddressPostalCode,city:e.deliveryAddressCity,country:e.deliveryAddressCountry};if(!t)throw new Error("cannot create an opportunity outside of the qualification");const h=(null==(a=t.leadSource)?void 0:a.includes("/events"))?"events-landingpage":"Qualification Funnel";return{...t.answers,...e,phone:e.phone||"",catererSlug:null==(l=null==t?void 0:t.selectedCaterer)?void 0:l.slug,landingPageSource:t.leadSource,billingAddressStreetAndNumber:c||"",inspiredByMenuId:null==(s=null==t?void 0:t.selectedMenu)?void 0:s.id,billingAddressPostalCode:d||"",billingAddressCity:f||"",billingCountry:p||"",conversion_url:window.location.href,deliveryAddressStreetAndNumber:u,deliveryCountry:e.deliveryAddressCountry,lead_language:o.locale,leadSource:h,commentByHeycaterForCaterer:e.comment}};return{submitAsNewCustomer:async e=>{var n;const r=null==(n=null==t?void 0:t.answers)?void 0:n.service_type,o="regular_employee_catering"===r||"full_service_event"===r,{deliveryAddressCountry:s}=e,u=["United Kingdom","Great Britain","UK"].includes(s);if(o||u){const{success:n}=await a({...e,...null==t?void 0:t.answers});return{success:n,isLeadOnly:!0}}{const{signInToken:t,customerAccount:n,opportunity:r}=await i(l(e));return{signInToken:t,customerAccount:n,opportunity:r,isLeadOnly:!1}}},submitAsExistingCustomer:async e=>{const t=l(e),{createOpportunity:{opportunity:r}}=await async function(e,{client:t}){const n=cF(e),{data:r}=await t.mutation(dF,{attributes:n}).toPromise();return r}(t,{client:n});return r}}}const dB="qualification-request-form",fB={},pB=/^\+?[1-9]\d{6,14}$/,hB=({isLoggedIn:e})=>vS.object().shape({first_name:vS.string().required(),last_name:vS.string().required(),company:vS.string().required(),email:vS.string().required().email(),phone:e?vS.string():vS.string().matches(pB,"Invalid phone number").required(),deliveryAddressStreet:vS.string().min(1).required(),deliveryAddressStreetNumber:vS.string().min(1).required(),deliveryAddressPostalCode:vS.string().min(1).required(),deliveryAddressCity:vS.string().min(1).required(),deliveryAddressCountry:vS.string().min(1).required(),comment:vS.string()});function mB({header:e=null}){var t,n,r;const[o,i]=m.useState(!1),{t:a}=Sd("qualification"),{submitAsNewCustomer:l,submitAsExistingCustomer:s}=cB(),u=WM({display:"all-answers"}),c=LM("xs"),{state:d}=yM(),{ref:f,isFloating:p,height:h}=iB(),{validateAddress:g}=OV({cacheValidations:fB}),v=c&&p,y="qualification"in d?d.qualification:null,{actions:b}=yM(),{currentUserAccount:w}=mM(),C=XS(),[k,S]=m.useState(!1),{deliveryAddressStreetAndNumber:E,deliveryAddressPostalCode:L,deliveryAddressCity:_,deliveryAddressCountry:M}=(null==w?void 0:w.owner)||{},[j,O]=m.useState(""),[P,T]=m.useState(""),D=w?(({street:e,postalCode:t,city:n,country:r})=>[e,t,n,r].filter(Boolean).join(", "))({street:E,postalCode:L,city:_,country:M}):"";m.useEffect(()=>{!async function(){if(!D)return;const{streetName:e,streetNumber:t}=await g(D);O(e),T(t)}()},[D]);const R=({isFormValid:e})=>{const t=x.jsxs(vm,{id:"request-form__submit-btn",block:"true","data-logged-in":!!w,"data-valid":e,"data-leadsource":"qualification"in d?d.qualification.leadSource:void 0,size:"lg",type:"submit",disabled:k,children:[k&&x.jsx(pm,{mr:2,style:{alignItems:"flex-start"},children:x.jsx(Il,{style:{verticalAlign:"sub"},size:20,color:"inherit"})}),a("request.form.submit")]});return c?x.jsx(oB,{height:h,isFloating:v,children:x.jsx(wB,{py:2,px:v&&2,$floating:v,children:t})}):x.jsx(pm,{position:"absolute",bottom:"0",left:"0",right:"0",py:2,px:2,bgcolor:"white",children:t})},N={first_name:(null==w?void 0:w.firstName)||"",last_name:(null==w?void 0:w.lastName)||"",company:(null==(t=null==w?void 0:w.owner)?void 0:t.companyName)||"",deliveryAddressStreet:j||"",deliveryAddressStreetNumber:P||"",deliveryAddressPostalCode:L||"",deliveryAddressCity:_||"",deliveryAddressCountry:M||"",email:(null==w?void 0:w.email)||"",phone:(null==(r=null==(n=null==w?void 0:w.owner)?void 0:n.salesforceCustomer)?void 0:r.phoneNumber)||""},A=!!w;return o?x.jsx(YV,{}):x.jsxs(BV,{children:[e,x.jsx(q$,{initialValues:N,validationSchema:hB({isLoggedIn:A}),onSubmit:async e=>{var t,n;S(!0);let r="";if(w)try{r=`/account/requests/${(await s(e)).id}`}catch(o){o instanceof Error&&MV.notify(o)}else{const{signInToken:n,opportunity:o,isLeadOnly:a,success:s}=await l(e);if(a)return void(s?(i(!0),window.gtag&&window.gtag("event","submit_qf_request"),null==(t=window.dataLayer)||t.push({event:"funnel_form_submit"})):S(!1));r=n?`/${C.locale}/account/requests/${o.id}?one_time_sign_in_token=${n}`:`/${C.locale}/account/external/requests/${o.id}`}null==y||y.selectedMenu,window.gtag&&window.gtag("event","submit_qf_request"),null==(n=window.dataLayer)||n.push({event:"funnel_form_submit"}),b.setRequest(e),((e="/")=>{window.location.href=`${lE().customerAppHost}${e}`})(r)},enableReinitialize:!0,children:e=>{var t,n;return x.jsxs(bB,{id:dB,name:dB,children:[x.jsxs(gB,{children:[x.jsx(vB,{$half:!0,children:x.jsx(G$,{required:!0,name:"first_name",label:a("request.form.firstName"),placeholder:a("request.form.firstName"),component:UV})}),x.jsx(vB,{$half:!0,children:x.jsx(G$,{required:!0,name:"last_name",label:a("request.form.lastName"),placeholder:a("request.form.lastName"),component:UV})})]}),x.jsx(gB,{children:x.jsx(vB,{$half:!0,children:x.jsx(G$,{required:!0,name:"company",label:a("request.form.company"),placeholder:a("request.form.company"),component:UV})})}),x.jsx(gB,{children:x.jsx(vB,{children:x.jsx(G$,{required:!0,name:"delivery_address",label:a("request.form.deliveryAddress"),placeholder:a("request.form.deliveryAddress"),helperText:a("request.form.helpText.address"),defaultValue:D,component:RV})})}),x.jsxs(gB,{children:[!w&&x.jsx(vB,{$half:!0,children:x.jsx(G$,{required:!0,type:"email",name:"email",label:a("request.form.email"),placeholder:a("request.form.email"),helperText:a("request.form.helpText.email"),component:UV})}),!(null==(n=null==(t=null==w?void 0:w.owner)?void 0:t.salesforceCustomer)?void 0:n.phoneNumber)&&x.jsx(vB,{$half:!0,children:x.jsx(HV,{label:a("request.form.phone"),name:"phone",formik:e,helperText:a("request.form.helpText.phone")})})]}),x.jsx(gB,{children:x.jsx(vB,{children:x.jsx(G$,{name:"comment",label:a("request.form.comment"),placeholder:a("request.form.commentPlaceholder"),component:UV,multiline:!0})})}),x.jsx(G$,{type:"hidden",name:"deliveryAddressStreet"}),x.jsx(G$,{type:"hidden",name:"deliveryAddressStreetNumber"}),x.jsx(G$,{type:"hidden",name:"deliveryAddressPostalCode"}),x.jsx(G$,{type:"hidden",name:"deliveryAddressCity"}),x.jsx(G$,{type:"hidden",name:"deliveryAddressCountry"}),x.jsxs(pm,{mt:2,mb:4,display:"flex",flexDirection:"column",children:[x.jsx(Lm,{variant:"caption",fontWeight:500,fontSize:12,px:1,mr:1.5,mb:1,children:a("selection.yourSelection")}),x.jsx(yB,{children:u.map(e=>x.jsx(BM,{size:"sm",stepId:e.stepId,text:e.text||""},`${e.stepId}_${e.text}`))})]}),x.jsx(pm,{ref:f,children:x.jsx(R,{isFormValid:e.isValid})})]})}})]})}const gB=tp.div`
1459
1459
  display: flex;
1460
1460
  flex-wrap: wrap;
1461
1461
  margin: 0 -${({theme:e})=>e.spacing(1)}px;
package/dist/index.cjs.js CHANGED
@@ -1377,7 +1377,7 @@ object-assign
1377
1377
  justify-content: center;
1378
1378
  background-size: cover;
1379
1379
  background-position: bottom center;
1380
- `,s_=({children:e,height:n,isFloating:r,...i})=>t.jsxs(t.Fragment,{children:[t.jsx(y,{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 l_={de:"German",en:"English"};function c_(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 u_(){const{locale:e}=cc(),t=a.useClient();return{funnelCheckout:async n=>{try{const{data:{funnelCheckout:r}}=await((e,{client:t})=>t.mutation(Tb,{attributes:e}).toPromise())({userAttributes:{email:n.email,firstName:n.first_name,lastName:n.last_name,phone:n.phone,language:l_[e]||l_.de},accountAttributes:c_(n),opportunityAttributes:Db(n)},{client:t});return r}catch(r){r instanceof Error&&AS.notify(r,e=>{e.addMetadata("funnelCheckoutArgs",n)})}}}}function d_(){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:c,first_name:u,last_name:d,phone:f,catering_categories:p,event_date:h,has_recurring_need:m,is_multi_day:g,number_of_carnivore:v,lead_type:y,number_of_vegans:b,number_of_vegetarians:x,price_per_person:C,service_type:w,team_size:L,delivery_frequency:M,budget_range:j,people_count:k}=t,S=null!=b&&null!=x&&null!=v?b+x+v:k||L||null,_=S&&C?S*C:null,{data:{createQfLead:E}}=await((e,{client:t})=>t.mutation(Ab,{attributes:e}).toPromise())({email:c,firstName:u,lastName:d,phone:f,company:n,comment:r,address:`${s} ${l}, ${a} ${i}, ${o}`,cateringCategories:p||null,eventDate:h?new Date(h).toDateString():null,hasRecurringNeed:m||null,isMultiDay:g||null,numberOfOmnivores:v||null,numberOfVegans:b||null,numberOfVegetarians:x||null,numberOfPeople:S,totalBudget:_,leadType:y||null,serviceType:w,teamSize:L||null,deliveryFrequency:M||null,budgetRange:j||null},{client:e});return E}catch(n){n&&AS.notify(n,e=>{e.addMetadata("createQfLead",t)})}}}}function f_(){const{state:e}=gf(),t="qualification"in e?e.qualification:null,n=a.useClient(),{currentUserAccount:r}=pf(),i=cc(),{funnelCheckout:o}=u_(),{createQfLead:s}=d_(),l=e=>{var n,o,a,s,l;const c=`${e.deliveryAddressStreet} ${e.deliveryAddressStreetNumber}`,{street:u,postalCode:d,city:f,country:p}=(null==(o=null==(n=null==r?void 0:r.owner)?void 0:n.salesforceCustomer)?void 0:o.billingAddress)||{street:c,postalCode:e.deliveryAddressPostalCode,city:e.deliveryAddressCity,country:e.deliveryAddressCountry};if(!t)throw new Error("cannot create an opportunity outside of the qualification");const h=(null==(a=t.leadSource)?void 0:a.includes("/events"))?"events-landingpage":"Qualification Funnel";return{...t.answers,...e,phone:e.phone||"",catererSlug:null==(s=null==t?void 0:t.selectedCaterer)?void 0:s.slug,landingPageSource:t.leadSource,billingAddressStreetAndNumber:u||"",inspiredByMenuId:null==(l=null==t?void 0:t.selectedMenu)?void 0:l.id,billingAddressPostalCode:d||"",billingAddressCity:f||"",billingCountry:p||"",conversion_url:window.location.href,deliveryAddressStreetAndNumber:c,deliveryCountry:e.deliveryAddressCountry,lead_language:i.locale,leadSource:h,commentByHeycaterForCaterer:e.comment}};return{submitAsNewCustomer:async e=>{var n;const r=null==(n=null==t?void 0:t.answers)?void 0:n.service_type,i="regular_employee_catering"===r||"full_service_event"===r,{deliveryAddressCountry:a}=e,c=["United Kingdom","Great Britain","UK"].includes(a);if(i||c){const{success:n}=await s({...e,...null==t?void 0:t.answers});return{success:n,isUkLead:!0}}{const{signInToken:t,customerAccount:n,opportunity:r}=await o(l(e));return{signInToken:t,customerAccount:n,opportunity:r,isUkLead:!1}}},submitAsExistingCustomer:async e=>{const t=l(e),{createOpportunity:{opportunity:r}}=await async function(e,{client:t}){const n=Db(e),{data:r}=await t.mutation(zb,{attributes:n}).toPromise();return r}(t,{client:n});return r}}}const p_="qualification-request-form",h_={},m_=/^\+?[1-9]\d{6,14}$/,g_=({isLoggedIn:e})=>ic.object().shape({first_name:ic.string().required(),last_name:ic.string().required(),company:ic.string().required(),email:ic.string().required().email(),phone:e?ic.string():ic.string().matches(m_,"Invalid phone number").required(),deliveryAddressStreet:ic.string().min(1).required(),deliveryAddressStreetNumber:ic.string().min(1).required(),deliveryAddressPostalCode:ic.string().min(1).required(),deliveryAddressCity:ic.string().min(1).required(),deliveryAddressCountry:ic.string().min(1).required(),comment:ic.string()});function v_({header:e=null}){var o,a,s;const[l,c]=n.useState(!1),{t:d}=i.useTranslation("qualification"),{submitAsNewCustomer:p,submitAsExistingCustomer:h}=f_(),m=$f({display:"all-answers"}),g=Mf("xs"),{state:v}=gf(),{ref:b,isFloating:x,height:C}=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:L}=IS({cacheValidations:h_}),M=g&&x,j="qualification"in v?v.qualification:null,{actions:k}=gf(),{currentUserAccount:S}=pf(),_=cc(),[E,O]=n.useState(!1),{deliveryAddressStreetAndNumber:D,deliveryAddressPostalCode:z,deliveryAddressCity:F,deliveryAddressCountry:T}=(null==S?void 0:S.owner)||{},[A,R]=n.useState(""),[I,Z]=n.useState(""),q=S?(({street:e,postalCode:t,city:n,country:r})=>[e,t,n,r].filter(Boolean).join(", "))({street:D,postalCode:z,city:F,country:T}):"";n.useEffect(()=>{!async function(){if(!q)return;const{streetName:e,streetNumber:t}=await L(q);R(e),Z(t)}()},[q]);const N=({isFormValid:e})=>{const n=t.jsxs(w,{id:"request-form__submit-btn",block:"true","data-logged-in":!!S,"data-valid":e,"data-leadsource":"qualification"in v?v.qualification.leadSource:void 0,size:"lg",type:"submit",disabled:E,children:[E&&t.jsx(y,{mr:2,style:{alignItems:"flex-start"},children:t.jsx(r.CircularProgress,{style:{verticalAlign:"sub"},size:20,color:"inherit"})}),d("request.form.submit")]});return g?t.jsx(s_,{height:C,isFloating:M,children:t.jsx(w_,{py:2,px:M&&2,$floating:M,children:n})}):t.jsx(y,{position:"absolute",bottom:"0",left:"0",right:"0",py:2,px:2,bgcolor:"white",children:n})},$={first_name:(null==S?void 0:S.firstName)||"",last_name:(null==S?void 0:S.lastName)||"",company:(null==(o=null==S?void 0:S.owner)?void 0:o.companyName)||"",deliveryAddressStreet:A||"",deliveryAddressStreetNumber:I||"",deliveryAddressPostalCode:z||"",deliveryAddressCity:F||"",deliveryAddressCountry:T||"",email:(null==S?void 0:S.email)||"",phone:(null==(s=null==(a=null==S?void 0:S.owner)?void 0:a.salesforceCustomer)?void 0:s.phoneNumber)||""},B=!!S;return l?t.jsx(n_,{}):t.jsxs(YS,{children:[e,t.jsx(u.Formik,{initialValues:$,validationSchema:g_({isLoggedIn:B}),onSubmit:async e=>{var t,n;O(!0);let r="";if(S)try{r=`/account/requests/${(await h(e)).id}`}catch(i){i instanceof Error&&AS.notify(i)}else{const{signInToken:n,opportunity:i,isUkLead:o,success:a}=await p(e);if(a&&o)return c(!0),window.gtag&&window.gtag("event","submit_qf_request"),void(null==(t=window.dataLayer)||t.push({event:"funnel_form_submit"}));r=n?`/${_.locale}/account/requests/${i.id}?one_time_sign_in_token=${n}`:`/${_.locale}/account/external/requests/${i.id}`}null==j||j.selectedMenu,window.gtag&&window.gtag("event","submit_qf_request"),null==(n=window.dataLayer)||n.push({event:"funnel_form_submit"}),k.setRequest(e),((e="/")=>{window.location.href=`${vc().customerAppHost}${e}`})(r)},enableReinitialize:!0,children:e=>{var n,r;return t.jsxs(C_,{id:p_,name:p_,children:[t.jsxs(y_,{children:[t.jsx(b_,{$half:!0,children:t.jsx(u.Field,{required:!0,name:"first_name",label:d("request.form.firstName"),placeholder:d("request.form.firstName"),component:XS})}),t.jsx(b_,{$half:!0,children:t.jsx(u.Field,{required:!0,name:"last_name",label:d("request.form.lastName"),placeholder:d("request.form.lastName"),component:XS})})]}),t.jsx(y_,{children:t.jsx(b_,{$half:!0,children:t.jsx(u.Field,{required:!0,name:"company",label:d("request.form.company"),placeholder:d("request.form.company"),component:XS})})}),t.jsx(y_,{children:t.jsx(b_,{children:t.jsx(u.Field,{required:!0,name:"delivery_address",label:d("request.form.deliveryAddress"),placeholder:d("request.form.deliveryAddress"),helperText:d("request.form.helpText.address"),defaultValue:q,component:$S})})}),t.jsxs(y_,{children:[!S&&t.jsx(b_,{$half:!0,children:t.jsx(u.Field,{required:!0,type:"email",name:"email",label:d("request.form.email"),placeholder:d("request.form.email"),helperText:d("request.form.helpText.email"),component:XS})}),!(null==(r=null==(n=null==S?void 0:S.owner)?void 0:n.salesforceCustomer)?void 0:r.phoneNumber)&&t.jsx(b_,{$half:!0,children:t.jsx(e_,{label:d("request.form.phone"),name:"phone",formik:e,helperText:d("request.form.helpText.phone")})})]}),t.jsx(y_,{children:t.jsx(b_,{children:t.jsx(u.Field,{name:"comment",label:d("request.form.comment"),placeholder:d("request.form.commentPlaceholder"),component:XS,multiline:!0})})}),t.jsx(u.Field,{type:"hidden",name:"deliveryAddressStreet"}),t.jsx(u.Field,{type:"hidden",name:"deliveryAddressStreetNumber"}),t.jsx(u.Field,{type:"hidden",name:"deliveryAddressPostalCode"}),t.jsx(u.Field,{type:"hidden",name:"deliveryAddressCity"}),t.jsx(u.Field,{type:"hidden",name:"deliveryAddressCountry"}),t.jsxs(y,{mt:2,mb:4,display:"flex",flexDirection:"column",children:[t.jsx(P,{variant:"caption",fontWeight:500,fontSize:12,px:1,mr:1.5,mb:1,children:d("selection.yourSelection")}),t.jsx(x_,{children:m.map(e=>t.jsx(qf,{size:"sm",stepId:e.stepId,text:e.text||""},`${e.stepId}_${e.text}`))})]}),t.jsx(y,{ref:b,children:t.jsx(N,{isFormValid:e.isValid})})]})}})]})}const y_=o.div`
1380
+ `,s_=({children:e,height:n,isFloating:r,...i})=>t.jsxs(t.Fragment,{children:[t.jsx(y,{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 l_={de:"German",en:"English"};function c_(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 u_(){const{locale:e}=cc(),t=a.useClient();return{funnelCheckout:async n=>{try{const{data:{funnelCheckout:r}}=await((e,{client:t})=>t.mutation(Tb,{attributes:e}).toPromise())({userAttributes:{email:n.email,firstName:n.first_name,lastName:n.last_name,phone:n.phone,language:l_[e]||l_.de},accountAttributes:c_(n),opportunityAttributes:Db(n)},{client:t});return r}catch(r){r instanceof Error&&AS.notify(r,e=>{e.addMetadata("funnelCheckoutArgs",n)})}}}}function d_(){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:c,first_name:u,last_name:d,phone:f,catering_categories:p,event_date:h,has_recurring_need:m,is_multi_day:g,number_of_carnivore:v,lead_type:y,number_of_vegans:b,number_of_vegetarians:x,price_per_person:C,min_order_number:w,team_size:L}=t,M=null!=b&&null!=x&&null!=v?b+x+v:w||L||void 0,j=M&&C?M*C:void 0,{data:{createQfLead:k}}=await((e,{client:t})=>t.mutation(Ab,{attributes:e}).toPromise())({email:c,firstName:u,lastName:d,phone:f,company:n,comment:r,address:`${s} ${l}, ${a} ${i}, ${o}`,cateringCategories:p,eventDate:h?new Date(h).toDateString():void 0,hasRecurringNeed:m,isMultiDay:g,numberOfOmnivores:v,numberOfVegans:b,numberOfVegetarians:x,numberOfPeople:M,totalBudget:j,leadType:y},{client:e});return k}catch(n){return n&&AS.notify(n,e=>{e.addMetadata("createQfLead",t)}),{success:!1}}}}}function f_(){const{state:e}=gf(),t="qualification"in e?e.qualification:null,n=a.useClient(),{currentUserAccount:r}=pf(),i=cc(),{funnelCheckout:o}=u_(),{createQfLead:s}=d_(),l=e=>{var n,o,a,s,l;const c=`${e.deliveryAddressStreet} ${e.deliveryAddressStreetNumber}`,{street:u,postalCode:d,city:f,country:p}=(null==(o=null==(n=null==r?void 0:r.owner)?void 0:n.salesforceCustomer)?void 0:o.billingAddress)||{street:c,postalCode:e.deliveryAddressPostalCode,city:e.deliveryAddressCity,country:e.deliveryAddressCountry};if(!t)throw new Error("cannot create an opportunity outside of the qualification");const h=(null==(a=t.leadSource)?void 0:a.includes("/events"))?"events-landingpage":"Qualification Funnel";return{...t.answers,...e,phone:e.phone||"",catererSlug:null==(s=null==t?void 0:t.selectedCaterer)?void 0:s.slug,landingPageSource:t.leadSource,billingAddressStreetAndNumber:u||"",inspiredByMenuId:null==(l=null==t?void 0:t.selectedMenu)?void 0:l.id,billingAddressPostalCode:d||"",billingAddressCity:f||"",billingCountry:p||"",conversion_url:window.location.href,deliveryAddressStreetAndNumber:c,deliveryCountry:e.deliveryAddressCountry,lead_language:i.locale,leadSource:h,commentByHeycaterForCaterer:e.comment}};return{submitAsNewCustomer:async e=>{var n;const r=null==(n=null==t?void 0:t.answers)?void 0:n.service_type,i="regular_employee_catering"===r||"full_service_event"===r,{deliveryAddressCountry:a}=e,c=["United Kingdom","Great Britain","UK"].includes(a);if(i||c){const{success:n}=await s({...e,...null==t?void 0:t.answers});return{success:n,isLeadOnly:!0}}{const{signInToken:t,customerAccount:n,opportunity:r}=await o(l(e));return{signInToken:t,customerAccount:n,opportunity:r,isLeadOnly:!1}}},submitAsExistingCustomer:async e=>{const t=l(e),{createOpportunity:{opportunity:r}}=await async function(e,{client:t}){const n=Db(e),{data:r}=await t.mutation(zb,{attributes:n}).toPromise();return r}(t,{client:n});return r}}}const p_="qualification-request-form",h_={},m_=/^\+?[1-9]\d{6,14}$/,g_=({isLoggedIn:e})=>ic.object().shape({first_name:ic.string().required(),last_name:ic.string().required(),company:ic.string().required(),email:ic.string().required().email(),phone:e?ic.string():ic.string().matches(m_,"Invalid phone number").required(),deliveryAddressStreet:ic.string().min(1).required(),deliveryAddressStreetNumber:ic.string().min(1).required(),deliveryAddressPostalCode:ic.string().min(1).required(),deliveryAddressCity:ic.string().min(1).required(),deliveryAddressCountry:ic.string().min(1).required(),comment:ic.string()});function v_({header:e=null}){var o,a,s;const[l,c]=n.useState(!1),{t:d}=i.useTranslation("qualification"),{submitAsNewCustomer:p,submitAsExistingCustomer:h}=f_(),m=$f({display:"all-answers"}),g=Mf("xs"),{state:v}=gf(),{ref:b,isFloating:x,height:C}=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:L}=IS({cacheValidations:h_}),M=g&&x,j="qualification"in v?v.qualification:null,{actions:k}=gf(),{currentUserAccount:S}=pf(),_=cc(),[E,O]=n.useState(!1),{deliveryAddressStreetAndNumber:D,deliveryAddressPostalCode:z,deliveryAddressCity:F,deliveryAddressCountry:T}=(null==S?void 0:S.owner)||{},[A,R]=n.useState(""),[I,Z]=n.useState(""),q=S?(({street:e,postalCode:t,city:n,country:r})=>[e,t,n,r].filter(Boolean).join(", "))({street:D,postalCode:z,city:F,country:T}):"";n.useEffect(()=>{!async function(){if(!q)return;const{streetName:e,streetNumber:t}=await L(q);R(e),Z(t)}()},[q]);const N=({isFormValid:e})=>{const n=t.jsxs(w,{id:"request-form__submit-btn",block:"true","data-logged-in":!!S,"data-valid":e,"data-leadsource":"qualification"in v?v.qualification.leadSource:void 0,size:"lg",type:"submit",disabled:E,children:[E&&t.jsx(y,{mr:2,style:{alignItems:"flex-start"},children:t.jsx(r.CircularProgress,{style:{verticalAlign:"sub"},size:20,color:"inherit"})}),d("request.form.submit")]});return g?t.jsx(s_,{height:C,isFloating:M,children:t.jsx(w_,{py:2,px:M&&2,$floating:M,children:n})}):t.jsx(y,{position:"absolute",bottom:"0",left:"0",right:"0",py:2,px:2,bgcolor:"white",children:n})},$={first_name:(null==S?void 0:S.firstName)||"",last_name:(null==S?void 0:S.lastName)||"",company:(null==(o=null==S?void 0:S.owner)?void 0:o.companyName)||"",deliveryAddressStreet:A||"",deliveryAddressStreetNumber:I||"",deliveryAddressPostalCode:z||"",deliveryAddressCity:F||"",deliveryAddressCountry:T||"",email:(null==S?void 0:S.email)||"",phone:(null==(s=null==(a=null==S?void 0:S.owner)?void 0:a.salesforceCustomer)?void 0:s.phoneNumber)||""},B=!!S;return l?t.jsx(n_,{}):t.jsxs(YS,{children:[e,t.jsx(u.Formik,{initialValues:$,validationSchema:g_({isLoggedIn:B}),onSubmit:async e=>{var t,n;O(!0);let r="";if(S)try{r=`/account/requests/${(await h(e)).id}`}catch(i){i instanceof Error&&AS.notify(i)}else{const{signInToken:n,opportunity:i,isLeadOnly:o,success:a}=await p(e);if(o)return void(a?(c(!0),window.gtag&&window.gtag("event","submit_qf_request"),null==(t=window.dataLayer)||t.push({event:"funnel_form_submit"})):O(!1));r=n?`/${_.locale}/account/requests/${i.id}?one_time_sign_in_token=${n}`:`/${_.locale}/account/external/requests/${i.id}`}null==j||j.selectedMenu,window.gtag&&window.gtag("event","submit_qf_request"),null==(n=window.dataLayer)||n.push({event:"funnel_form_submit"}),k.setRequest(e),((e="/")=>{window.location.href=`${vc().customerAppHost}${e}`})(r)},enableReinitialize:!0,children:e=>{var n,r;return t.jsxs(C_,{id:p_,name:p_,children:[t.jsxs(y_,{children:[t.jsx(b_,{$half:!0,children:t.jsx(u.Field,{required:!0,name:"first_name",label:d("request.form.firstName"),placeholder:d("request.form.firstName"),component:XS})}),t.jsx(b_,{$half:!0,children:t.jsx(u.Field,{required:!0,name:"last_name",label:d("request.form.lastName"),placeholder:d("request.form.lastName"),component:XS})})]}),t.jsx(y_,{children:t.jsx(b_,{$half:!0,children:t.jsx(u.Field,{required:!0,name:"company",label:d("request.form.company"),placeholder:d("request.form.company"),component:XS})})}),t.jsx(y_,{children:t.jsx(b_,{children:t.jsx(u.Field,{required:!0,name:"delivery_address",label:d("request.form.deliveryAddress"),placeholder:d("request.form.deliveryAddress"),helperText:d("request.form.helpText.address"),defaultValue:q,component:$S})})}),t.jsxs(y_,{children:[!S&&t.jsx(b_,{$half:!0,children:t.jsx(u.Field,{required:!0,type:"email",name:"email",label:d("request.form.email"),placeholder:d("request.form.email"),helperText:d("request.form.helpText.email"),component:XS})}),!(null==(r=null==(n=null==S?void 0:S.owner)?void 0:n.salesforceCustomer)?void 0:r.phoneNumber)&&t.jsx(b_,{$half:!0,children:t.jsx(e_,{label:d("request.form.phone"),name:"phone",formik:e,helperText:d("request.form.helpText.phone")})})]}),t.jsx(y_,{children:t.jsx(b_,{children:t.jsx(u.Field,{name:"comment",label:d("request.form.comment"),placeholder:d("request.form.commentPlaceholder"),component:XS,multiline:!0})})}),t.jsx(u.Field,{type:"hidden",name:"deliveryAddressStreet"}),t.jsx(u.Field,{type:"hidden",name:"deliveryAddressStreetNumber"}),t.jsx(u.Field,{type:"hidden",name:"deliveryAddressPostalCode"}),t.jsx(u.Field,{type:"hidden",name:"deliveryAddressCity"}),t.jsx(u.Field,{type:"hidden",name:"deliveryAddressCountry"}),t.jsxs(y,{mt:2,mb:4,display:"flex",flexDirection:"column",children:[t.jsx(P,{variant:"caption",fontWeight:500,fontSize:12,px:1,mr:1.5,mb:1,children:d("selection.yourSelection")}),t.jsx(x_,{children:m.map(e=>t.jsx(qf,{size:"sm",stepId:e.stepId,text:e.text||""},`${e.stepId}_${e.text}`))})]}),t.jsx(y,{ref:b,children:t.jsx(N,{isFormValid:e.isValid})})]})}})]})}const y_=o.div`
1381
1381
  display: flex;
1382
1382
  flex-wrap: wrap;
1383
1383
  margin: 0 -${({theme:e})=>e.spacing(1)}px;