@heycater/qualification-funnel 1.4.1 → 1.4.2

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.
@@ -1407,7 +1407,7 @@
1407
1407
  justify-content: center;
1408
1408
  background-size: cover;
1409
1409
  background-position: bottom center;
1410
- `;var gV=new Map,vV=new WeakMap,yV=0;function bV(e){return Object.keys(e).sort().filter(function(t){return void 0!==e[t]}).map(function(t){return t+"_"+("root"===t?(n=e.root)?(vV.has(n)||(yV+=1,vV.set(n,yV.toString())),vV.get(n)):"0":e[t]);var n}).toString()}function wV(e,t,n,r){if(void 0===n&&(n={}),void 0===r&&(r=undefined),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=bV(e),n=gV.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},gV.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(),gV.delete(a))}}const xV=({children:e,height:t,isFloating:n,...r})=>C.jsxs(C.Fragment,{children:[C.jsx(Fm,{display:"flex",flexDirection:"column",flexGrow:"1",bottom:"0",left:"0",right:"0",position:n?"fixed":"relative",...r,children:e}),n&&C.jsx("div",{style:{height:`${t}px`}})]});function CV(){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=g.useRef(),f=g.useState({inView:!!u}),p=f[0],h=f[1],m=g.useCallback(function(e){void 0!==d.current&&(d.current(),d.current=void 0),l||e&&(d.current=wV(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]);g.useEffect(function(){d.current||!p.entry||s||l||h({inView:!!u})});var v=[m,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 kV={de:"German",en:"English"};function SV(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 EV(){const{locale:e}=_E(),t=Mm();return{funnelCheckout:async n=>{try{const{data:{funnelCheckout:r}}=await((e,{client:t})=>t.mutation(_I,{attributes:e}).toPromise())({userAttributes:{email:n.email,firstName:n.first_name,lastName:n.last_name,phone:n.phone,language:kV[e]||kV.de},accountAttributes:SV(n),opportunityAttributes:kI(n)},{client:t});return r}catch(r){r instanceof Error&&WB.notify(r,e=>{e.addMetadata("funnelCheckoutArgs",n)})}}}}function _V(){const e=Mm();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,_=b+w+v,{data:{createQfLead:L}}=await((e,{client:t})=>t.mutation(LI,{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:_,totalBudget:_*x,leadType:y,serviceType:C,teamSize:k,deliveryFrequency:S,budgetRange:E},{client:e});return L}catch(n){n&&WB.notify(n,e=>{e.addMetadata("createQfLead",t)})}}}}function LV(){const{state:e}=HO(),t="qualification"in e?e.qualification:null,n=Mm(),{currentUserAccount:r}=qO(),o=_E(),{funnelCheckout:i}=EV(),{createQfLead:a}=_V(),s=e=>{var n,i,a,s;const l=`${e.deliveryAddressStreet} ${e.deliveryAddressStreetNumber}`,{street:u,postalCode:c,city:d,country:f}=(null==(i=null==(n=null==r?void 0:r.owner)?void 0:n.salesforceCustomer)?void 0:i.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";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||"",billingAddressPostalCode:c||"",billingAddressCity:d||"",billingCountry:f||"",conversion_url:window.location.href,deliveryAddressStreetAndNumber:l,deliveryCountry:e.deliveryAddressCountry,lead_language:o.locale,leadSource:p,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:u}}{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=kI(e),{data:r}=await t.mutation(SI,{attributes:n}).toPromise();return r}(t,{client:n});return r}}}const OV="qualification-request-form",MV={},jV=/^\+?[1-9]\d{6,14}$/,TV=({isLoggedIn:e})=>US.object().shape({first_name:US.string().required(),last_name:US.string().required(),company:US.string().required(),email:US.string().required().email(),phone:e?US.string():US.string().matches(jV,"Invalid phone number").required(),deliveryAddressStreet:US.string().min(1).required(),deliveryAddressStreetNumber:US.string().min(1).required(),deliveryAddressPostalCode:US.string().min(1).required(),deliveryAddressCity:US.string().min(1).required(),deliveryAddressCountry:US.string().min(1).required(),comment:US.string()});function PV({header:e=null}){var t,n,r;const[o,i]=g.useState(!1),[a,s]=g.useState(!1),{t:l}=qd("qualification"),{submitAsNewCustomer:u,submitAsExistingCustomer:c}=LV(),d=yM({display:"all-answers"}),f=eM("xs"),{state:p}=HO(),{ref:h,isFloating:m,height:v}=CV(),{validateAddress:y}=ZB({cacheValidations:MV}),b=f&&m;"qualification"in p&&p.qualification;const{actions:w}=HO(),{currentUserAccount:x}=qO(),k=_E(),[S,E]=g.useState(!1),{deliveryAddressStreetAndNumber:_,deliveryAddressPostalCode:L,deliveryAddressCity:O,deliveryAddressCountry:M}=(null==x?void 0:x.owner)||{},[j,T]=g.useState(""),[P,N]=g.useState(""),D=x?(({street:e,postalCode:t,city:n,country:r})=>[e,t,n,r].filter(Boolean).join(", "))({street:_,postalCode:L,city:O,country:M}):"";g.useEffect(()=>{!async function(){if(!D)return;const{streetName:e,streetNumber:t}=await y(D);T(e),N(t)}()},[D]);const{mode:R}=MP(),A=({isFormValid:e})=>{const t=C.jsxs(Vm,{id:"request-form__submit-btn",block:"true","data-logged-in":!!x,"data-valid":e,"data-leadsource":"qualification"in p?p.qualification.leadSource:void 0,size:"lg",type:"submit",disabled:S,children:[S&&C.jsx(Fm,{mr:2,style:{alignItems:"flex-start"},children:C.jsx(rl,{style:{verticalAlign:"sub"},size:20,color:"inherit"})}),l("request.form.submit")]});return f?C.jsx(xV,{height:v,isFloating:b,children:C.jsx(IV,{py:2,px:b&&2,$floating:b,children:t})}):C.jsx(Fm,{position:"absolute",bottom:"0",left:"0",right:"0",py:2,px:2,bgcolor:"white",children:t})},I={first_name:(null==x?void 0:x.firstName)||"",last_name:(null==x?void 0:x.lastName)||"",company:(null==(t=null==x?void 0:x.owner)?void 0:t.companyName)||"",deliveryAddressStreet:j||"",deliveryAddressStreetNumber:P||"",deliveryAddressPostalCode:L||"",deliveryAddressCity:O||"",deliveryAddressCountry:M||"",email:(null==x?void 0:x.email)||"",phone:(null==(r=null==(n=null==x?void 0:x.owner)?void 0:n.salesforceCustomer)?void 0:r.phoneNumber)||""},F=!!x;return o?C.jsx(dV,{isUkLead:a}):C.jsxs(iV,{children:[e,C.jsx(aB,{initialValues:I,validationSchema:TV({isLoggedIn:F}),onSubmit:async e=>{E(!0);let t="";if(x)try{t=`/account/requests/${(await c(e)).id}`}catch(r){r instanceof Error&&WB.notify(r)}else{const{signInToken:n,opportunity:r,isUkLead:o,success:a}=await u(e);if(a){s(o),i(!0);const e=CP(p);return EP(R,{is_uk_lead:o,...e}),void _P(R,e)}t=n?`/${k.locale}/account/requests/${r.id}?one_time_sign_in_token=${n}`:`/${k.locale}/account/external/requests/${r.id}`}const n=CP(p);EP(R,{is_logged_in:!!x,...n}),_P(R,n),w.setRequest(e),((e="/")=>{window.location.href=`${DE().customerAppHost}${e}`})(t)},enableReinitialize:!0,children:e=>{var t,n;return C.jsxs(AV,{id:OV,name:OV,children:[C.jsxs(NV,{children:[C.jsx(DV,{$half:!0,children:C.jsx(pB,{required:!0,name:"first_name",label:l("request.form.firstName"),placeholder:l("request.form.firstName"),component:lV})}),C.jsx(DV,{$half:!0,children:C.jsx(pB,{required:!0,name:"last_name",label:l("request.form.lastName"),placeholder:l("request.form.lastName"),component:lV})})]}),C.jsx(NV,{children:C.jsx(DV,{$half:!0,children:C.jsx(pB,{required:!0,name:"company",label:l("request.form.company"),placeholder:l("request.form.company"),component:lV})})}),C.jsx(NV,{children:C.jsx(DV,{children:C.jsx(pB,{required:!0,name:"delivery_address",label:l("request.form.deliveryAddress"),placeholder:l("request.form.deliveryAddress"),helperText:l("request.form.helpText.address"),defaultValue:D,component:QB})})}),C.jsxs(NV,{children:[!x&&C.jsx(DV,{$half:!0,children:C.jsx(pB,{required:!0,type:"email",name:"email",label:l("request.form.email"),placeholder:l("request.form.email"),helperText:l("request.form.helpText.email"),component:lV})}),!(null==(n=null==(t=null==x?void 0:x.owner)?void 0:t.salesforceCustomer)?void 0:n.phoneNumber)&&C.jsx(DV,{$half:!0,children:C.jsx(uV,{label:l("request.form.phone"),name:"phone",formik:e,helperText:l("request.form.helpText.phone")})})]}),C.jsx(NV,{children:C.jsx(DV,{children:C.jsx(pB,{name:"comment",label:l("request.form.comment"),placeholder:l("request.form.commentPlaceholder"),component:lV,multiline:!0})})}),C.jsx(pB,{type:"hidden",name:"deliveryAddressStreet"}),C.jsx(pB,{type:"hidden",name:"deliveryAddressStreetNumber"}),C.jsx(pB,{type:"hidden",name:"deliveryAddressPostalCode"}),C.jsx(pB,{type:"hidden",name:"deliveryAddressCity"}),C.jsx(pB,{type:"hidden",name:"deliveryAddressCountry"}),C.jsxs(Fm,{mt:2,mb:4,display:"flex",flexDirection:"column",children:[C.jsx(Qm,{variant:"caption",fontWeight:500,fontSize:12,px:1,mr:1.5,mb:1,children:l("selection.yourSelection")}),C.jsx(RV,{children:d.map(e=>C.jsx(gM,{size:"sm",stepId:e.stepId,text:e.text||""},`${e.stepId}_${e.text}`))})]}),C.jsx(Fm,{ref:h,children:C.jsx(A,{isFormValid:e.isValid})})]})}})]})}const NV=_p.div`
1410
+ `;var gV=new Map,vV=new WeakMap,yV=0;function bV(e){return Object.keys(e).sort().filter(function(t){return void 0!==e[t]}).map(function(t){return t+"_"+("root"===t?(n=e.root)?(vV.has(n)||(yV+=1,vV.set(n,yV.toString())),vV.get(n)):"0":e[t]);var n}).toString()}function wV(e,t,n,r){if(void 0===n&&(n={}),void 0===r&&(r=undefined),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=bV(e),n=gV.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},gV.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(),gV.delete(a))}}const xV=({children:e,height:t,isFloating:n,...r})=>C.jsxs(C.Fragment,{children:[C.jsx(Fm,{display:"flex",flexDirection:"column",flexGrow:"1",bottom:"0",left:"0",right:"0",position:n?"fixed":"relative",...r,children:e}),n&&C.jsx("div",{style:{height:`${t}px`}})]});function CV(){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=g.useRef(),f=g.useState({inView:!!u}),p=f[0],h=f[1],m=g.useCallback(function(e){void 0!==d.current&&(d.current(),d.current=void 0),l||e&&(d.current=wV(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]);g.useEffect(function(){d.current||!p.entry||s||l||h({inView:!!u})});var v=[m,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 kV={de:"German",en:"English"};function SV(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 EV(){const{locale:e}=_E(),t=Mm();return{funnelCheckout:async n=>{try{const{data:{funnelCheckout:r}}=await((e,{client:t})=>t.mutation(_I,{attributes:e}).toPromise())({userAttributes:{email:n.email,firstName:n.first_name,lastName:n.last_name,phone:n.phone,language:kV[e]||kV.de},accountAttributes:SV(n),opportunityAttributes:kI(n)},{client:t});return r}catch(r){r instanceof Error&&WB.notify(r,e=>{e.addMetadata("funnelCheckoutArgs",n)})}}}}function _V(){const e=Mm();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,_=b+w+v,{data:{createQfLead:L}}=await((e,{client:t})=>t.mutation(LI,{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:_,totalBudget:_*x,leadType:y,serviceType:C,teamSize:k,deliveryFrequency:S,budgetRange:E},{client:e});return L}catch(n){n&&WB.notify(n,e=>{e.addMetadata("createQfLead",t)})}}}}function LV(){const{state:e}=HO(),t="qualification"in e?e.qualification:null,n=Mm(),{currentUserAccount:r}=qO(),o=_E(),{funnelCheckout:i}=EV(),{createQfLead:a}=_V(),s=e=>{var n,i,a,s;const l=`${e.deliveryAddressStreet} ${e.deliveryAddressStreetNumber}`,{street:u,postalCode:c,city:d,country:f}=(null==(i=null==(n=null==r?void 0:r.owner)?void 0:n.salesforceCustomer)?void 0:i.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";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||"",billingAddressPostalCode:c||"",billingAddressCity:d||"",billingCountry:f||"",conversion_url:window.location.href,deliveryAddressStreetAndNumber:l,deliveryCountry:e.deliveryAddressCountry,lead_language:o.locale,leadSource:p,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{signInToken:t,customerAccount:n,opportunity:r}=await i(s(e));return{signInToken:t,customerAccount:n,opportunity:r,isUkLead:!1}}try{const n=await a({...e,...null==t?void 0:t.answers});if(!n)return console.error("[HeyCater Funnel] createQfLead returned undefined/null"),{success:!1,isUkLead:u};const{success:r}=n;return void 0===r&&console.error("[HeyCater Funnel] createQfLead response missing success field:",n),{success:r,isUkLead:u}}catch(c){return console.error("[HeyCater Funnel] createQfLead failed:",c),{success:!1,isUkLead:u}}},submitAsExistingCustomer:async e=>{const t=s(e),{createOpportunity:{opportunity:r}}=await async function(e,{client:t}){const n=kI(e),{data:r}=await t.mutation(SI,{attributes:n}).toPromise();return r}(t,{client:n});return r}}}const OV="qualification-request-form",MV={},jV=/^\+?[1-9]\d{6,14}$/,TV=({isLoggedIn:e})=>US.object().shape({first_name:US.string().required(),last_name:US.string().required(),company:US.string().required(),email:US.string().required().email(),phone:e?US.string():US.string().matches(jV,"Invalid phone number").required(),deliveryAddressStreet:US.string().min(1).required(),deliveryAddressStreetNumber:US.string().min(1).required(),deliveryAddressPostalCode:US.string().min(1).required(),deliveryAddressCity:US.string().min(1).required(),deliveryAddressCountry:US.string().min(1).required(),comment:US.string()});function PV({header:e=null}){var t,n,r;const[o,i]=g.useState(!1),[a,s]=g.useState(!1),{t:l}=qd("qualification"),{submitAsNewCustomer:u,submitAsExistingCustomer:c}=LV(),d=yM({display:"all-answers"}),f=eM("xs"),{state:p}=HO(),{ref:h,isFloating:m,height:v}=CV(),{validateAddress:y}=ZB({cacheValidations:MV}),b=f&&m,w="qualification"in p?p.qualification:null,{actions:x}=HO(),{currentUserAccount:k}=qO(),S=_E(),[E,_]=g.useState(!1),{deliveryAddressStreetAndNumber:L,deliveryAddressPostalCode:O,deliveryAddressCity:M,deliveryAddressCountry:j}=(null==k?void 0:k.owner)||{},[T,P]=g.useState(""),[N,D]=g.useState(""),R=k?(({street:e,postalCode:t,city:n,country:r})=>[e,t,n,r].filter(Boolean).join(", "))({street:L,postalCode:O,city:M,country:j}):"";g.useEffect(()=>{!async function(){if(!R)return;const{streetName:e,streetNumber:t}=await y(R);P(e),D(t)}()},[R]);const{mode:A}=MP(),I=({isFormValid:e})=>{const t=C.jsxs(Vm,{id:"request-form__submit-btn",block:"true","data-logged-in":!!k,"data-valid":e,"data-leadsource":"qualification"in p?p.qualification.leadSource:void 0,size:"lg",type:"submit",disabled:E,children:[E&&C.jsx(Fm,{mr:2,style:{alignItems:"flex-start"},children:C.jsx(rl,{style:{verticalAlign:"sub"},size:20,color:"inherit"})}),l("request.form.submit")]});return f?C.jsx(xV,{height:v,isFloating:b,children:C.jsx(IV,{py:2,px:b&&2,$floating:b,children:t})}):C.jsx(Fm,{position:"absolute",bottom:"0",left:"0",right:"0",py:2,px:2,bgcolor:"white",children:t})},F={first_name:(null==k?void 0:k.firstName)||"",last_name:(null==k?void 0:k.lastName)||"",company:(null==(t=null==k?void 0:k.owner)?void 0:t.companyName)||"",deliveryAddressStreet:T||"",deliveryAddressStreetNumber:N||"",deliveryAddressPostalCode:O||"",deliveryAddressCity:M||"",deliveryAddressCountry:j||"",email:(null==k?void 0:k.email)||"",phone:(null==(r=null==(n=null==k?void 0:k.owner)?void 0:n.salesforceCustomer)?void 0:r.phoneNumber)||""},z=!!k;return o?C.jsx(dV,{isUkLead:a}):C.jsxs(iV,{children:[e,C.jsx(aB,{initialValues:F,validationSchema:TV({isLoggedIn:z}),onSubmit:async e=>{var t,n;_(!0);let r="";if(k)try{r=`/account/requests/${(await c(e)).id}`}catch(a){a instanceof Error&&WB.notify(a)}else{const{signInToken:o,opportunity:a,isUkLead:l,success:c}=await u(e);if(c){s(l),i(!0);const e=CP(p);return EP(A,{is_uk_lead:l,...e}),void _P(A,e)}(l||"regular_employee_catering"===(null==(t=null==w?void 0:w.answers)?void 0:t.service_type)||"full_service_event"===(null==(n=null==w?void 0:w.answers)?void 0:n.service_type))&&console.error("[HeyCater Funnel] Expected success screen but got success=false. Result:",{signInToken:o,opportunity:a,isUkLead:l,success:c}),r=o?`/${S.locale}/account/requests/${a.id}?one_time_sign_in_token=${o}`:`/${S.locale}/account/external/requests/${a.id}`}const o=CP(p);EP(A,{is_logged_in:!!k,...o}),_P(A,o),x.setRequest(e),((e="/")=>{window.location.href=`${DE().customerAppHost}${e}`})(r)},enableReinitialize:!0,children:e=>{var t,n;return C.jsxs(AV,{id:OV,name:OV,children:[C.jsxs(NV,{children:[C.jsx(DV,{$half:!0,children:C.jsx(pB,{required:!0,name:"first_name",label:l("request.form.firstName"),placeholder:l("request.form.firstName"),component:lV})}),C.jsx(DV,{$half:!0,children:C.jsx(pB,{required:!0,name:"last_name",label:l("request.form.lastName"),placeholder:l("request.form.lastName"),component:lV})})]}),C.jsx(NV,{children:C.jsx(DV,{$half:!0,children:C.jsx(pB,{required:!0,name:"company",label:l("request.form.company"),placeholder:l("request.form.company"),component:lV})})}),C.jsx(NV,{children:C.jsx(DV,{children:C.jsx(pB,{required:!0,name:"delivery_address",label:l("request.form.deliveryAddress"),placeholder:l("request.form.deliveryAddress"),helperText:l("request.form.helpText.address"),defaultValue:R,component:QB})})}),C.jsxs(NV,{children:[!k&&C.jsx(DV,{$half:!0,children:C.jsx(pB,{required:!0,type:"email",name:"email",label:l("request.form.email"),placeholder:l("request.form.email"),helperText:l("request.form.helpText.email"),component:lV})}),!(null==(n=null==(t=null==k?void 0:k.owner)?void 0:t.salesforceCustomer)?void 0:n.phoneNumber)&&C.jsx(DV,{$half:!0,children:C.jsx(uV,{label:l("request.form.phone"),name:"phone",formik:e,helperText:l("request.form.helpText.phone")})})]}),C.jsx(NV,{children:C.jsx(DV,{children:C.jsx(pB,{name:"comment",label:l("request.form.comment"),placeholder:l("request.form.commentPlaceholder"),component:lV,multiline:!0})})}),C.jsx(pB,{type:"hidden",name:"deliveryAddressStreet"}),C.jsx(pB,{type:"hidden",name:"deliveryAddressStreetNumber"}),C.jsx(pB,{type:"hidden",name:"deliveryAddressPostalCode"}),C.jsx(pB,{type:"hidden",name:"deliveryAddressCity"}),C.jsx(pB,{type:"hidden",name:"deliveryAddressCountry"}),C.jsxs(Fm,{mt:2,mb:4,display:"flex",flexDirection:"column",children:[C.jsx(Qm,{variant:"caption",fontWeight:500,fontSize:12,px:1,mr:1.5,mb:1,children:l("selection.yourSelection")}),C.jsx(RV,{children:d.map(e=>C.jsx(gM,{size:"sm",stepId:e.stepId,text:e.text||""},`${e.stepId}_${e.text}`))})]}),C.jsx(Fm,{ref:h,children:C.jsx(I,{isFormValid:e.isValid})})]})}})]})}const NV=_p.div`
1411
1411
  display: flex;
1412
1412
  flex-wrap: wrap;
1413
1413
  margin: 0 -${({theme:e})=>e.spacing(1)}px;