@heycater/qualification-funnel 1.3.14 → 1.3.15

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.
@@ -1461,7 +1461,7 @@
1461
1461
  justify-content: center;
1462
1462
  background-size: cover;
1463
1463
  background-position: bottom center;
1464
- `;var KB=new Map,GB=new WeakMap,QB=0;function JB(e){return Object.keys(e).sort().filter(function(t){return void 0!==e[t]}).map(function(t){return t+"_"+("root"===t?(n=e.root)?(GB.has(n)||(QB+=1,GB.set(n,QB.toString())),GB.get(n)):"0":e[t]);var n}).toString()}function XB(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=JB(e),n=KB.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},KB.set(t,n)}return n}(n),a=i.id,s=i.observer,l=i.elements,u=l.get(e)||[];return l.has(e)||l.set(e,u),u.push(t),s.observe(e),function(){u.splice(u.indexOf(t),1),0===u.length&&(l.delete(e),s.unobserve(e)),0===l.size&&(s.disconnect(),KB.delete(a))}}const eV=({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 tV(){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,s=t.triggerOnce,l=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),l||e&&(d.current=XB(e,function(e,t){h({inView:e,entry:t}),t.isIntersecting&&s&&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,s,l,o,c,r]);m.useEffect(function(){d.current||!p.entry||s||l||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 nV={de:"German",en:"English"};function rV(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 oV(){const{locale:e}=XS(),t=om();return{funnelCheckout:async n=>{try{const{data:{funnelCheckout:r}}=await((e,{client:t})=>t.mutation(uI,{attributes:e}).toPromise())({userAttributes:{email:n.email,firstName:n.first_name,lastName:n.last_name,phone:n.phone,language:nV[e]||nV.de},accountAttributes:rV(n),opportunityAttributes:aI(n)},{client:t});return r}catch(r){r instanceof Error&&SB.notify(r,e=>{e.addMetadata("funnelCheckoutArgs",n)})}}}}function iV(){const e=om();return{createQfLead:async t=>{try{const{company:n,comment:r,deliveryAddressCity:o,deliveryAddressCountry:i,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: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}=t,E=b+w+v,{data:{createQfLead:L}}=await((e,{client:t})=>t.mutation(cI,{attributes:e}).toPromise())({email:u,firstName:c,lastName:d,phone:f,company:n,comment:r,address:`${s} ${l}, ${a} ${o}, ${i}`,cateringCategories:p,eventDate:new Date(h).toDateString(),hasRecurringNeed:m,isMultiDay:g,numberOfOmnivores:v,numberOfVegans:b,numberOfVegetarians:w,numberOfPeople:E,totalBudget:E*x,leadType:y,serviceType:C,teamSize:k,deliveryFrequency:S},{client:e});return L}catch(n){n&&SB.notify(n,e=>{e.addMetadata("createQfLead",t)})}}}}function aV(){const{state:e}=bO(),t="qualification"in e?e.qualification:null,n=om(),{currentUserAccount:r}=gO(),o=XS(),{funnelCheckout:i}=oV(),{createQfLead:a}=iV(),s=e=>{var n,i,a,s,l;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==(s=null==t?void 0:t.selectedCaterer)?void 0:s.slug,landingPageSource:t.leadSource,billingAddressStreetAndNumber:c||"",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:u,deliveryCountry:e.deliveryAddressCountry,lead_language:o.locale,leadSource:h,commentByHeycaterForCaterer:e.comment}};return{submitAsNewCustomer:async e=>{const{deliveryAddressCountry:n}=e;if(["United Kingdom","Great Britain","UK"].includes(n)){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(s(e));return{signInToken:t,customerAccount:n,opportunity:r,isUkLead:!1}}},submitAsExistingCustomer:async e=>{const t=s(e),{createOpportunity:{opportunity:r}}=await async function(e,{client:t}){const n=aI(e),{data:r}=await t.mutation(sI,{attributes:n}).toPromise();return r}(t,{client:n});return r}}}const sV="qualification-request-form",lV={},uV=/^\+?[1-9]\d{6,14}$/,cV=({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(uV,"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 dV({header:e=null}){var t,n,r;const[o,i]=m.useState(!1),{t:a}=Sd("qualification"),{submitAsNewCustomer:s,submitAsExistingCustomer:l}=aV(),u=qO({display:"all-answers"}),c=_O("xs"),{state:d}=bO(),{ref:f,isFloating:p,height:h}=tV(),{validateAddress:g}=LB({cacheValidations:lV}),v=c&&p,y="qualification"in d?d.qualification:null,{actions:b}=bO(),{currentUserAccount:w}=gO(),C=XS(),[k,S]=m.useState(!1),{deliveryAddressStreetAndNumber:E,deliveryAddressPostalCode:L,deliveryAddressCity:_,deliveryAddressCountry:O}=(null==w?void 0:w.owner)||{},[M,j]=m.useState(""),[T,P]=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:O}):"";m.useEffect(()=>{!async function(){if(!D)return;const{streetName:e,streetNumber:t}=await g(D);j(e),P(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(Fs,{style:{verticalAlign:"sub"},size:20,color:"inherit"})}),a("request.form.submit")]});return c?x.jsx(eV,{height:h,isFloating:v,children:x.jsx(gV,{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:M||"",deliveryAddressStreetNumber:T||"",deliveryAddressPostalCode:L||"",deliveryAddressCity:_||"",deliveryAddressCountry:O||"",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(UB,{}):x.jsxs(FB,{children:[e,x.jsx(z$,{initialValues:N,validationSchema:cV({isLoggedIn:A}),onSubmit:async e=>{var t,n;S(!0);let r="";if(w)try{r=`/account/requests/${(await l(e)).id}`}catch(o){o instanceof Error&&SB.notify(o)}else{const{signInToken:n,opportunity:o,isUkLead:a,success:l}=await s(e);if(l&&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=`${sE().customerAppHost}${e}`})(r)},enableReinitialize:!0,children:e=>{var t,n;return x.jsxs(mV,{id:sV,name:sV,children:[x.jsxs(fV,{children:[x.jsx(pV,{$half:!0,children:x.jsx(Z$,{required:!0,name:"first_name",label:a("request.form.firstName"),placeholder:a("request.form.firstName"),component:BB})}),x.jsx(pV,{$half:!0,children:x.jsx(Z$,{required:!0,name:"last_name",label:a("request.form.lastName"),placeholder:a("request.form.lastName"),component:BB})})]}),x.jsx(fV,{children:x.jsx(pV,{$half:!0,children:x.jsx(Z$,{required:!0,name:"company",label:a("request.form.company"),placeholder:a("request.form.company"),component:BB})})}),x.jsx(fV,{children:x.jsx(pV,{children:x.jsx(Z$,{required:!0,name:"delivery_address",label:a("request.form.deliveryAddress"),placeholder:a("request.form.deliveryAddress"),helperText:a("request.form.helpText.address"),defaultValue:D,component:jB})})}),x.jsxs(fV,{children:[!w&&x.jsx(pV,{$half:!0,children:x.jsx(Z$,{required:!0,type:"email",name:"email",label:a("request.form.email"),placeholder:a("request.form.email"),helperText:a("request.form.helpText.email"),component:BB})}),!(null==(n=null==(t=null==w?void 0:w.owner)?void 0:t.salesforceCustomer)?void 0:n.phoneNumber)&&x.jsx(pV,{$half:!0,children:x.jsx(VB,{label:a("request.form.phone"),name:"phone",formik:e,helperText:a("request.form.helpText.phone")})})]}),x.jsx(fV,{children:x.jsx(pV,{children:x.jsx(Z$,{name:"comment",label:a("request.form.comment"),placeholder:a("request.form.commentPlaceholder"),component:BB,multiline:!0})})}),x.jsx(Z$,{type:"hidden",name:"deliveryAddressStreet"}),x.jsx(Z$,{type:"hidden",name:"deliveryAddressStreetNumber"}),x.jsx(Z$,{type:"hidden",name:"deliveryAddressPostalCode"}),x.jsx(Z$,{type:"hidden",name:"deliveryAddressCity"}),x.jsx(Z$,{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(hV,{children:u.map(e=>x.jsx(WO,{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 fV=tp.div`
1464
+ `;var KB=new Map,GB=new WeakMap,QB=0;function JB(e){return Object.keys(e).sort().filter(function(t){return void 0!==e[t]}).map(function(t){return t+"_"+("root"===t?(n=e.root)?(GB.has(n)||(QB+=1,GB.set(n,QB.toString())),GB.get(n)):"0":e[t]);var n}).toString()}function XB(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=JB(e),n=KB.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},KB.set(t,n)}return n}(n),a=i.id,s=i.observer,l=i.elements,u=l.get(e)||[];return l.has(e)||l.set(e,u),u.push(t),s.observe(e),function(){u.splice(u.indexOf(t),1),0===u.length&&(l.delete(e),s.unobserve(e)),0===l.size&&(s.disconnect(),KB.delete(a))}}const eV=({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 tV(){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,s=t.triggerOnce,l=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),l||e&&(d.current=XB(e,function(e,t){h({inView:e,entry:t}),t.isIntersecting&&s&&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,s,l,o,c,r]);m.useEffect(function(){d.current||!p.entry||s||l||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 nV={de:"German",en:"English"};function rV(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 oV(){const{locale:e}=XS(),t=om();return{funnelCheckout:async n=>{try{const{data:{funnelCheckout:r}}=await((e,{client:t})=>t.mutation(uI,{attributes:e}).toPromise())({userAttributes:{email:n.email,firstName:n.first_name,lastName:n.last_name,phone:n.phone,language:nV[e]||nV.de},accountAttributes:rV(n),opportunityAttributes:aI(n)},{client:t});return r}catch(r){r instanceof Error&&SB.notify(r,e=>{e.addMetadata("funnelCheckoutArgs",n)})}}}}function iV(){const e=om();return{createQfLead:async t=>{try{const{company:n,comment:r,deliveryAddressCity:o,deliveryAddressCountry:i,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: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}=t,L=b+w+v,{data:{createQfLead:_}}=await((e,{client:t})=>t.mutation(cI,{attributes:e}).toPromise())({email:u,firstName:c,lastName:d,phone:f,company:n,comment:r,address:`${s} ${l}, ${a} ${o}, ${i}`,cateringCategories:p,eventDate:new Date(h).toDateString(),hasRecurringNeed:m,isMultiDay:g,numberOfOmnivores:v,numberOfVegans:b,numberOfVegetarians:w,numberOfPeople:L,totalBudget:L*x,leadType:y,serviceType:C,teamSize:k,deliveryFrequency:S,budgetRange:E},{client:e});return _}catch(n){n&&SB.notify(n,e=>{e.addMetadata("createQfLead",t)})}}}}function aV(){const{state:e}=bO(),t="qualification"in e?e.qualification:null,n=om(),{currentUserAccount:r}=gO(),o=XS(),{funnelCheckout:i}=oV(),{createQfLead:a}=iV(),s=e=>{var n,i,a,s,l;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==(s=null==t?void 0:t.selectedCaterer)?void 0:s.slug,landingPageSource:t.leadSource,billingAddressStreetAndNumber:c||"",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: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:l}=e,u=["United Kingdom","Great Britain","UK"].includes(l);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(s(e));return{signInToken:t,customerAccount:n,opportunity:r,isUkLead:!1}}},submitAsExistingCustomer:async e=>{const t=s(e),{createOpportunity:{opportunity:r}}=await async function(e,{client:t}){const n=aI(e),{data:r}=await t.mutation(sI,{attributes:n}).toPromise();return r}(t,{client:n});return r}}}const sV="qualification-request-form",lV={},uV=/^\+?[1-9]\d{6,14}$/,cV=({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(uV,"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 dV({header:e=null}){var t,n,r;const[o,i]=m.useState(!1),{t:a}=Sd("qualification"),{submitAsNewCustomer:s,submitAsExistingCustomer:l}=aV(),u=qO({display:"all-answers"}),c=_O("xs"),{state:d}=bO(),{ref:f,isFloating:p,height:h}=tV(),{validateAddress:g}=LB({cacheValidations:lV}),v=c&&p,y="qualification"in d?d.qualification:null,{actions:b}=bO(),{currentUserAccount:w}=gO(),C=XS(),[k,S]=m.useState(!1),{deliveryAddressStreetAndNumber:E,deliveryAddressPostalCode:L,deliveryAddressCity:_,deliveryAddressCountry:O}=(null==w?void 0:w.owner)||{},[M,j]=m.useState(""),[T,P]=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:O}):"";m.useEffect(()=>{!async function(){if(!D)return;const{streetName:e,streetNumber:t}=await g(D);j(e),P(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(Fs,{style:{verticalAlign:"sub"},size:20,color:"inherit"})}),a("request.form.submit")]});return c?x.jsx(eV,{height:h,isFloating:v,children:x.jsx(gV,{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:M||"",deliveryAddressStreetNumber:T||"",deliveryAddressPostalCode:L||"",deliveryAddressCity:_||"",deliveryAddressCountry:O||"",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(UB,{}):x.jsxs(FB,{children:[e,x.jsx(z$,{initialValues:N,validationSchema:cV({isLoggedIn:A}),onSubmit:async e=>{var t,n;S(!0);let r="";if(w)try{r=`/account/requests/${(await l(e)).id}`}catch(o){o instanceof Error&&SB.notify(o)}else{const{signInToken:n,opportunity:o,isUkLead:a,success:l}=await s(e);if(l&&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=`${sE().customerAppHost}${e}`})(r)},enableReinitialize:!0,children:e=>{var t,n;return x.jsxs(mV,{id:sV,name:sV,children:[x.jsxs(fV,{children:[x.jsx(pV,{$half:!0,children:x.jsx(Z$,{required:!0,name:"first_name",label:a("request.form.firstName"),placeholder:a("request.form.firstName"),component:BB})}),x.jsx(pV,{$half:!0,children:x.jsx(Z$,{required:!0,name:"last_name",label:a("request.form.lastName"),placeholder:a("request.form.lastName"),component:BB})})]}),x.jsx(fV,{children:x.jsx(pV,{$half:!0,children:x.jsx(Z$,{required:!0,name:"company",label:a("request.form.company"),placeholder:a("request.form.company"),component:BB})})}),x.jsx(fV,{children:x.jsx(pV,{children:x.jsx(Z$,{required:!0,name:"delivery_address",label:a("request.form.deliveryAddress"),placeholder:a("request.form.deliveryAddress"),helperText:a("request.form.helpText.address"),defaultValue:D,component:jB})})}),x.jsxs(fV,{children:[!w&&x.jsx(pV,{$half:!0,children:x.jsx(Z$,{required:!0,type:"email",name:"email",label:a("request.form.email"),placeholder:a("request.form.email"),helperText:a("request.form.helpText.email"),component:BB})}),!(null==(n=null==(t=null==w?void 0:w.owner)?void 0:t.salesforceCustomer)?void 0:n.phoneNumber)&&x.jsx(pV,{$half:!0,children:x.jsx(VB,{label:a("request.form.phone"),name:"phone",formik:e,helperText:a("request.form.helpText.phone")})})]}),x.jsx(fV,{children:x.jsx(pV,{children:x.jsx(Z$,{name:"comment",label:a("request.form.comment"),placeholder:a("request.form.commentPlaceholder"),component:BB,multiline:!0})})}),x.jsx(Z$,{type:"hidden",name:"deliveryAddressStreet"}),x.jsx(Z$,{type:"hidden",name:"deliveryAddressStreetNumber"}),x.jsx(Z$,{type:"hidden",name:"deliveryAddressPostalCode"}),x.jsx(Z$,{type:"hidden",name:"deliveryAddressCity"}),x.jsx(Z$,{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(hV,{children:u.map(e=>x.jsx(WO,{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 fV=tp.div`
1465
1465
  display: flex;
1466
1466
  flex-wrap: wrap;
1467
1467
  margin: 0 -${({theme:e})=>e.spacing(1)}px;
package/dist/index.cjs.js CHANGED
@@ -1383,7 +1383,7 @@ object-assign
1383
1383
  justify-content: center;
1384
1384
  background-size: cover;
1385
1385
  background-position: bottom center;
1386
- `,r_=({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 i_={de:"German",en:"English"};function o_(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 a_(){const{locale:e}=uu(),t=a.useClient();return{funnelCheckout:async n=>{try{const{data:{funnelCheckout:r}}=await((e,{client:t})=>t.mutation(Db,{attributes:e}).toPromise())({userAttributes:{email:n.email,firstName:n.first_name,lastName:n.last_name,phone:n.phone,language:i_[e]||i_.de},accountAttributes:o_(n),opportunityAttributes:_b(n)},{client:t});return r}catch(r){r instanceof Error&&zS.notify(r,e=>{e.addMetadata("funnelCheckoutArgs",n)})}}}}function s_(){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:g,is_multi_day:m,number_of_carnivore:y,lead_type:v,number_of_vegans:b,number_of_vegetarians:C,price_per_person:x,service_type:w,team_size:L,delivery_frequency:M}=t,k=b+C+y,{data:{createQfLead:j}}=await((e,{client:t})=>t.mutation(zb,{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:g,isMultiDay:m,numberOfOmnivores:y,numberOfVegans:b,numberOfVegetarians:C,numberOfPeople:k,totalBudget:k*x,leadType:v,serviceType:w,teamSize:L,deliveryFrequency:M},{client:e});return j}catch(n){n&&zS.notify(n,e=>{e.addMetadata("createQfLead",t)})}}}}function l_(){const{state:e}=yf(),t="qualification"in e?e.qualification:null,n=a.useClient(),{currentUserAccount:r}=hf(),i=uu(),{funnelCheckout:o}=a_(),{createQfLead:s}=s_(),l=e=>{var n,o,a,s,l;const u=`${e.deliveryAddressStreet} ${e.deliveryAddressStreetNumber}`,{street:c,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: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==(s=null==t?void 0:t.selectedCaterer)?void 0:s.slug,landingPageSource:t.leadSource,billingAddressStreetAndNumber:c||"",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:u,deliveryCountry:e.deliveryAddressCountry,lead_language:i.locale,leadSource:h,commentByHeycaterForCaterer:e.comment}};return{submitAsNewCustomer:async e=>{const{deliveryAddressCountry:n}=e;if(["United Kingdom","Great Britain","UK"].includes(n)){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=_b(e),{data:r}=await t.mutation(Eb,{attributes:n}).toPromise();return r}(t,{client:n});return r}}}const u_="qualification-request-form",c_={},d_=/^\+?[1-9]\d{6,14}$/,f_=({isLoggedIn:e})=>iu.object().shape({first_name:iu.string().required(),last_name:iu.string().required(),company:iu.string().required(),email:iu.string().required().email(),phone:e?iu.string():iu.string().matches(d_,"Invalid phone number").required(),deliveryAddressStreet:iu.string().min(1).required(),deliveryAddressStreetNumber:iu.string().min(1).required(),deliveryAddressPostalCode:iu.string().min(1).required(),deliveryAddressCity:iu.string().min(1).required(),deliveryAddressCountry:iu.string().min(1).required(),comment:iu.string()});function p_({header:e=null}){var o,a,s;const[l,u]=n.useState(!1),{t:d}=i.useTranslation("qualification"),{submitAsNewCustomer:p,submitAsExistingCustomer:h}=l_(),g=Bf({display:"all-answers"}),m=kf("xs"),{state:y}=yf(),{ref:b,isFloating:C,height:x}=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}=PS({cacheValidations:c_}),M=m&&C,k="qualification"in y?y.qualification:null,{actions:j}=yf(),{currentUserAccount:S}=hf(),_=uu(),[E,O]=n.useState(!1),{deliveryAddressStreetAndNumber:z,deliveryAddressPostalCode:T,deliveryAddressCity:P,deliveryAddressCountry:A}=(null==S?void 0:S.owner)||{},[F,R]=n.useState(""),[I,N]=n.useState(""),$=S?(({street:e,postalCode:t,city:n,country:r})=>[e,t,n,r].filter(Boolean).join(", "))({street:z,postalCode:T,city:P,country:A}):"";n.useEffect(()=>{!async function(){if(!$)return;const{streetName:e,streetNumber:t}=await L($);R(e),N(t)}()},[$]);const q=({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 y?y.qualification.leadSource:void 0,size:"lg",type:"submit",disabled:E,children:[E&&t.jsx(v,{mr:2,style:{alignItems:"flex-start"},children:t.jsx(r.CircularProgress,{style:{verticalAlign:"sub"},size:20,color:"inherit"})}),d("request.form.submit")]});return m?t.jsx(r_,{height:x,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})},Z={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:F||"",deliveryAddressStreetNumber:I||"",deliveryAddressPostalCode:T||"",deliveryAddressCity:P||"",deliveryAddressCountry:A||"",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(JS,{}):t.jsxs(US,{children:[e,t.jsx(c.Formik,{initialValues:Z,validationSchema:f_({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&&zS.notify(i)}else{const{signInToken:n,opportunity:i,isUkLead:o,success:a}=await p(e);if(a&&o)return u(!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==k||k.selectedMenu,window.gtag&&window.gtag("event","submit_qf_request"),null==(n=window.dataLayer)||n.push({event:"funnel_form_submit"}),j.setRequest(e),((e="/")=>{window.location.href=`${yu().customerAppHost}${e}`})(r)},enableReinitialize:!0,children:e=>{var n,r;return t.jsxs(y_,{id:u_,name:u_,children:[t.jsxs(h_,{children:[t.jsx(g_,{$half:!0,children:t.jsx(c.Field,{required:!0,name:"first_name",label:d("request.form.firstName"),placeholder:d("request.form.firstName"),component:KS})}),t.jsx(g_,{$half:!0,children:t.jsx(c.Field,{required:!0,name:"last_name",label:d("request.form.lastName"),placeholder:d("request.form.lastName"),component:KS})})]}),t.jsx(h_,{children:t.jsx(g_,{$half:!0,children:t.jsx(c.Field,{required:!0,name:"company",label:d("request.form.company"),placeholder:d("request.form.company"),component:KS})})}),t.jsx(h_,{children:t.jsx(g_,{children:t.jsx(c.Field,{required:!0,name:"delivery_address",label:d("request.form.deliveryAddress"),placeholder:d("request.form.deliveryAddress"),helperText:d("request.form.helpText.address"),defaultValue:$,component:IS})})}),t.jsxs(h_,{children:[!S&&t.jsx(g_,{$half:!0,children:t.jsx(c.Field,{required:!0,type:"email",name:"email",label:d("request.form.email"),placeholder:d("request.form.email"),helperText:d("request.form.helpText.email"),component:KS})}),!(null==(r=null==(n=null==S?void 0:S.owner)?void 0:n.salesforceCustomer)?void 0:r.phoneNumber)&&t.jsx(g_,{$half:!0,children:t.jsx(YS,{label:d("request.form.phone"),name:"phone",formik:e,helperText:d("request.form.helpText.phone")})})]}),t.jsx(h_,{children:t.jsx(g_,{children:t.jsx(c.Field,{name:"comment",label:d("request.form.comment"),placeholder:d("request.form.commentPlaceholder"),component:KS,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(D,{variant:"caption",fontWeight:500,fontSize:12,px:1,mr:1.5,mb:1,children:d("selection.yourSelection")}),t.jsx(m_,{children:g.map(e=>t.jsx(qf,{size:"sm",stepId:e.stepId,text:e.text||""},`${e.stepId}_${e.text}`))})]}),t.jsx(v,{ref:b,children:t.jsx(q,{isFormValid:e.isValid})})]})}})]})}const h_=o.div`
1386
+ `,r_=({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 i_={de:"German",en:"English"};function o_(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 a_(){const{locale:e}=uu(),t=a.useClient();return{funnelCheckout:async n=>{try{const{data:{funnelCheckout:r}}=await((e,{client:t})=>t.mutation(Db,{attributes:e}).toPromise())({userAttributes:{email:n.email,firstName:n.first_name,lastName:n.last_name,phone:n.phone,language:i_[e]||i_.de},accountAttributes:o_(n),opportunityAttributes:_b(n)},{client:t});return r}catch(r){r instanceof Error&&zS.notify(r,e=>{e.addMetadata("funnelCheckoutArgs",n)})}}}}function s_(){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:g,is_multi_day:m,number_of_carnivore:y,lead_type:v,number_of_vegans:b,number_of_vegetarians:C,price_per_person:x,service_type:w,team_size:L,delivery_frequency:M,budget_range:k}=t,j=b+C+y,{data:{createQfLead:S}}=await((e,{client:t})=>t.mutation(zb,{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:g,isMultiDay:m,numberOfOmnivores:y,numberOfVegans:b,numberOfVegetarians:C,numberOfPeople:j,totalBudget:j*x,leadType:v,serviceType:w,teamSize:L,deliveryFrequency:M,budgetRange:k},{client:e});return S}catch(n){n&&zS.notify(n,e=>{e.addMetadata("createQfLead",t)})}}}}function l_(){const{state:e}=yf(),t="qualification"in e?e.qualification:null,n=a.useClient(),{currentUserAccount:r}=hf(),i=uu(),{funnelCheckout:o}=a_(),{createQfLead:s}=s_(),l=e=>{var n,o,a,s,l;const u=`${e.deliveryAddressStreet} ${e.deliveryAddressStreetNumber}`,{street:c,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: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==(s=null==t?void 0:t.selectedCaterer)?void 0:s.slug,landingPageSource:t.leadSource,billingAddressStreetAndNumber:c||"",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:u,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,u=["United Kingdom","Great Britain","UK"].includes(a);if(i||u){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=_b(e),{data:r}=await t.mutation(Eb,{attributes:n}).toPromise();return r}(t,{client:n});return r}}}const u_="qualification-request-form",c_={},d_=/^\+?[1-9]\d{6,14}$/,f_=({isLoggedIn:e})=>iu.object().shape({first_name:iu.string().required(),last_name:iu.string().required(),company:iu.string().required(),email:iu.string().required().email(),phone:e?iu.string():iu.string().matches(d_,"Invalid phone number").required(),deliveryAddressStreet:iu.string().min(1).required(),deliveryAddressStreetNumber:iu.string().min(1).required(),deliveryAddressPostalCode:iu.string().min(1).required(),deliveryAddressCity:iu.string().min(1).required(),deliveryAddressCountry:iu.string().min(1).required(),comment:iu.string()});function p_({header:e=null}){var o,a,s;const[l,u]=n.useState(!1),{t:d}=i.useTranslation("qualification"),{submitAsNewCustomer:p,submitAsExistingCustomer:h}=l_(),g=Bf({display:"all-answers"}),m=kf("xs"),{state:y}=yf(),{ref:b,isFloating:C,height:x}=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}=PS({cacheValidations:c_}),M=m&&C,k="qualification"in y?y.qualification:null,{actions:j}=yf(),{currentUserAccount:S}=hf(),_=uu(),[E,O]=n.useState(!1),{deliveryAddressStreetAndNumber:z,deliveryAddressPostalCode:T,deliveryAddressCity:P,deliveryAddressCountry:A}=(null==S?void 0:S.owner)||{},[F,R]=n.useState(""),[I,N]=n.useState(""),$=S?(({street:e,postalCode:t,city:n,country:r})=>[e,t,n,r].filter(Boolean).join(", "))({street:z,postalCode:T,city:P,country:A}):"";n.useEffect(()=>{!async function(){if(!$)return;const{streetName:e,streetNumber:t}=await L($);R(e),N(t)}()},[$]);const q=({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 y?y.qualification.leadSource:void 0,size:"lg",type:"submit",disabled:E,children:[E&&t.jsx(v,{mr:2,style:{alignItems:"flex-start"},children:t.jsx(r.CircularProgress,{style:{verticalAlign:"sub"},size:20,color:"inherit"})}),d("request.form.submit")]});return m?t.jsx(r_,{height:x,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})},Z={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:F||"",deliveryAddressStreetNumber:I||"",deliveryAddressPostalCode:T||"",deliveryAddressCity:P||"",deliveryAddressCountry:A||"",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(JS,{}):t.jsxs(US,{children:[e,t.jsx(c.Formik,{initialValues:Z,validationSchema:f_({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&&zS.notify(i)}else{const{signInToken:n,opportunity:i,isUkLead:o,success:a}=await p(e);if(a&&o)return u(!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==k||k.selectedMenu,window.gtag&&window.gtag("event","submit_qf_request"),null==(n=window.dataLayer)||n.push({event:"funnel_form_submit"}),j.setRequest(e),((e="/")=>{window.location.href=`${yu().customerAppHost}${e}`})(r)},enableReinitialize:!0,children:e=>{var n,r;return t.jsxs(y_,{id:u_,name:u_,children:[t.jsxs(h_,{children:[t.jsx(g_,{$half:!0,children:t.jsx(c.Field,{required:!0,name:"first_name",label:d("request.form.firstName"),placeholder:d("request.form.firstName"),component:KS})}),t.jsx(g_,{$half:!0,children:t.jsx(c.Field,{required:!0,name:"last_name",label:d("request.form.lastName"),placeholder:d("request.form.lastName"),component:KS})})]}),t.jsx(h_,{children:t.jsx(g_,{$half:!0,children:t.jsx(c.Field,{required:!0,name:"company",label:d("request.form.company"),placeholder:d("request.form.company"),component:KS})})}),t.jsx(h_,{children:t.jsx(g_,{children:t.jsx(c.Field,{required:!0,name:"delivery_address",label:d("request.form.deliveryAddress"),placeholder:d("request.form.deliveryAddress"),helperText:d("request.form.helpText.address"),defaultValue:$,component:IS})})}),t.jsxs(h_,{children:[!S&&t.jsx(g_,{$half:!0,children:t.jsx(c.Field,{required:!0,type:"email",name:"email",label:d("request.form.email"),placeholder:d("request.form.email"),helperText:d("request.form.helpText.email"),component:KS})}),!(null==(r=null==(n=null==S?void 0:S.owner)?void 0:n.salesforceCustomer)?void 0:r.phoneNumber)&&t.jsx(g_,{$half:!0,children:t.jsx(YS,{label:d("request.form.phone"),name:"phone",formik:e,helperText:d("request.form.helpText.phone")})})]}),t.jsx(h_,{children:t.jsx(g_,{children:t.jsx(c.Field,{name:"comment",label:d("request.form.comment"),placeholder:d("request.form.commentPlaceholder"),component:KS,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(D,{variant:"caption",fontWeight:500,fontSize:12,px:1,mr:1.5,mb:1,children:d("selection.yourSelection")}),t.jsx(m_,{children:g.map(e=>t.jsx(qf,{size:"sm",stepId:e.stepId,text:e.text||""},`${e.stepId}_${e.text}`))})]}),t.jsx(v,{ref:b,children:t.jsx(q,{isFormValid:e.isValid})})]})}})]})}const h_=o.div`
1387
1387
  display: flex;
1388
1388
  flex-wrap: wrap;
1389
1389
  margin: 0 -${({theme:e})=>e.spacing(1)}px;