@heycater/qualification-funnel 1.3.18 → 1.3.20

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs.js CHANGED
@@ -1348,7 +1348,7 @@ object-assign
1348
1348
  }
1349
1349
  `;function XS({field:e,form:n,helperText:r,label:o="",placeholder:a="",required:s=!1,type:l="text",autocomplete:c="off",multiline:d=!1,inputRef:f}){const{formHelperText:p,showError:h}=function({field:e,form:{errors:t,touched:n},helperText:r}){const{t:o}=i.useTranslation(),a=u.getIn(t,e.name),s=u.getIn(n,e.name)&&!!a;return{showError:s,formHelperText:s&&o(a)||r}}({field:e,form:n,helperText:r});return t.jsxs(D,{error:h,required:s,children:[o&&t.jsx(T,{htmlFor:e.name,children:o}),d?t.jsx(QS,{...e,autoComplete:c,placeholder:a,ref:f}):t.jsx(F,{...e,type:l,autoComplete:c,placeholder:a,ref:f}),t.jsx(A,{children:p})]})}function e_({label:e,name:n,formik:r,helperText:i}){const o=r.errors.phone,a=r.values.phone,s=r.touched.phone;return t.jsxs(t.Fragment,{children:[t.jsx(T,{required:!0,htmlFor:n,children:e}),t.jsx(t_,{name:n,type:"tel",value:a,onChange:e=>{let t=e.target.value;t=t.replace(/[^\d+\s-]/g,""),t.startsWith("+")||(t="+49"+t.replace(/^\+/,"")),r.setFieldValue("phone",t,!0)},onBlur:()=>r.setFieldTouched("phone",!0),placeholder:"+49 30 56837200",$hasError:Boolean(s&&o)}),o&&s&&t.jsx(A,{error:o,children:(l=o,l?l.charAt(0).toUpperCase()+l.slice(1):"")}),i&&t.jsx(A,{children:i})]});var l}const t_=o(F)`
1350
1350
  border-color: ${e=>e.$hasError?e.theme.palette.error.main:"transparent"};
1351
- `;function n_(){const{actions:e}=gf(),n=cc(),{t:o}=i.useTranslation("qualification");return t.jsxs(t.Fragment,{children:[t.jsx(y,{display:"flex",justifyContent:"end",children:t.jsx(y,{px:2,children:t.jsx(r.IconButton,{onClick:()=>{e.initialize(),n.push("/en/catering-london")},"aria-label":"back",component:"span",children:t.jsx(ep,{})})})}),t.jsx(a_,{children:t.jsx(y,{width:"100%",children:t.jsxs(o_,{children:[t.jsx(y,{textAlign:"center",children:t.jsx("img",{src:mc("/artifacts/images/confetti.gif"),width:120,height:120,alt:""})}),t.jsx(r_,{children:o("embeddedFunnel.success.title")}),t.jsx(y,{mt:4,children:t.jsx(i_,{children:o("embeddedFunnel.success.subtitle")})})]})})})]})}const r_=o(P)`
1351
+ `;function n_(){const{actions:e}=gf(),{t:n}=i.useTranslation("qualification");return t.jsxs(t.Fragment,{children:[t.jsx(y,{display:"flex",justifyContent:"end",children:t.jsx(y,{px:2,children:t.jsx(r.IconButton,{onClick:()=>{e.initialize()},"aria-label":"back",component:"span",children:t.jsx(ep,{})})})}),t.jsx(a_,{children:t.jsx(y,{width:"100%",children:t.jsxs(o_,{children:[t.jsx(y,{textAlign:"center",children:t.jsx("img",{src:mc("/artifacts/images/confetti.gif"),width:120,height:120,alt:""})}),t.jsx(r_,{children:n("embeddedFunnel.success.title")}),t.jsx(y,{mt:4,children:t.jsx(i_,{children:n("embeddedFunnel.success.subtitle")})})]})})})]})}const r_=o(P)`
1352
1352
  font-size: 20px;
1353
1353
  font-weight: 700;
1354
1354
  text-align: center;
@@ -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,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`
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=>{var n;try{const{company:r,comment:i,deliveryAddressCity:o,deliveryAddressCountry:a,deliveryAddressPostalCode:s,deliveryAddressStreet:l,deliveryAddressStreetNumber:c,email:u,first_name:d,last_name:f,phone:p,catering_categories:h,event_date:m,has_recurring_need:g,is_multi_day:v,number_of_carnivore:y,lead_type:b,number_of_vegans:x,number_of_vegetarians:C,price_per_person:w,min_order_number:L,team_size:M,service_type:j,delivery_frequency:k,budget_range:S,city:_}=t,E=null!=x&&null!=C&&null!=y?x+C+y:L||M||void 0,O=E&&w?E*w:void 0,P=[j&&`Service Type: ${j}`,_&&`City: ${_}`,M&&`Team Size: ${M}`,k&&`Delivery Frequency: ${k}`,S&&`Budget Range: ${S}`].filter(Boolean).join("\n"),D={email:u,firstName:d,lastName:f,phone:p,company:r,comment:[i,P].filter(Boolean).join("\n\n---\n"),address:`${l} ${c}, ${s} ${o}, ${a}`,cateringCategories:h,eventDate:m?new Date(m).toDateString():void 0,hasRecurringNeed:g,isMultiDay:v,numberOfOmnivores:y,numberOfVegans:x,numberOfVegetarians:C,numberOfPeople:E,totalBudget:O,leadType:b},z=await((e,{client:t})=>t.mutation(Ab,{attributes:e}).toPromise())(D,{client:e});return(null==(n=null==z?void 0:z.data)?void 0:n.createQfLead)||{success:!1}}catch(r){return r&&AS.notify(r,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 n=await s({...e,...null==t?void 0:t.answers});return{success:null==n?void 0:n.success,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,r,i;O(!0);const o=null==(t=null==j?void 0:j.answers)?void 0:t.service_type;if("regular_employee_catering"===o||"full_service_event"===o){const t=await p(e);return void((null==t?void 0:t.success)?(c(!0),window.gtag&&window.gtag("event","submit_qf_request"),null==(n=window.dataLayer)||n.push({event:"funnel_form_submit"})):O(!1))}let a="";if(S)try{a=`/account/requests/${(await h(e)).id}`}catch(s){s instanceof Error&&AS.notify(s)}else{const t=await p(e),{signInToken:n,opportunity:i,isLeadOnly:o,success:s}=t;if(o)return void(s?(c(!0),window.gtag&&window.gtag("event","submit_qf_request"),null==(r=window.dataLayer)||r.push({event:"funnel_form_submit"})):O(!1));a=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==(i=window.dataLayer)||i.push({event:"funnel_form_submit"}),k.setRequest(e),((e="/")=>{window.location.href=`${vc().customerAppHost}${e}`})(a)},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;