@heycater/qualification-funnel 1.19.31 → 1.19.32
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/heycater-funnel.iife.js +1 -1
- package/dist/index.cjs.js +473 -473
- package/dist/index.esm.js +123 -94
- package/package.json +1 -1
|
@@ -2675,7 +2675,7 @@
|
|
|
2675
2675
|
opacity: 0.9;
|
|
2676
2676
|
transform: translateY(-1px);
|
|
2677
2677
|
}
|
|
2678
|
-
`,AH=({ratings:e,onCancel:t,funnelContextRef:n,updateContext:r})=>{var o;const{i18n:i}=Vd(),a=null==(o=i.language)?void 0:o.startsWith("de"),s=LE(),{state:l,actions:u,answerOf:c}=tj(),d=v.useMemo(()=>{if(!("qualification"in l))return!1;const e=l.qualification.steps.find(e=>"city"===e.id);return!0===(null==e?void 0:e.disabled)},["qualification"in l?l.qualification.steps:null]),f=v.useMemo(()=>d?dU.filter(e=>e!==aU):dU,[d]),[p,h]=g.useState(0),[m,y]=g.useState("questions"),[b,w]=g.useState(20),[x,k]=g.useState(!1),[S,E]=g.useState(null),[_,L]=g.useState(null),O=g.useRef(!1),{submitAsNewCustomer:j}=Wq(),M=f[p],T=t||(()=>window.history.back());g.useEffect(()=>{if("redesign_people_count"===M){void 0===c("min_order_number")&&u.answerQuestion("min_order_number",100);const e=c("event_type"),t=c("price_per_person");if(void 0===t&&e){const t=lO[e].catering_category,n=IE[t].defaultPricePerPerson;w(n),u.answerQuestion("price_per_person",n)}else void 0===t&&u.answerQuestion("price_per_person",b)}},[M,u,c,b]),g.useEffect(()=>{!O.current&&n.current.session_id&&(O.current=!0,gM(n.current,M))},[n.current.session_id,M]);const P=g.useCallback((e,t)=>{let r=t;t instanceof Date&&(r=DL(t,"yyyy-MM-dd")),pM(n.current,{step_id:M,step_index:p,question_id:e,answer_value:r,is_last_question:!0})},[n,p,M]),D=g.useCallback(()=>{const e=p+1;e>=f.length?y("loading"):h(e)},[p,f.length]),N=g.useCallback(()=>{p>0&&h(p-1)},[p]),R=g.useCallback(e=>{const t=f.indexOf(e);t>=0&&("contact"===m&&y("questions"),h(t))},[m,f]),A=g.useCallback(e=>{u.answerQuestion("city",e),P("city",e),r({city:e}),D()},[u,P,r,D]),I=g.useCallback(e=>{const t=function(e){return lO[e]}(e);u.answerQuestion("event_type",e),u.answerQuestion("service_type",t.service_type),u.answerQuestion("catering_categories",[t.catering_category]),P("event_type",e),r({service_type:t.service_type,total_steps:f.length+1}),D()},[u,P,r,D,f.length]),F=g.useCallback(e=>{e&&(u.answerQuestion("event_date",e),P("event_date",e))},[u,P]),z=g.useCallback(e=>{u.answerQuestion("is_multi_day",e),P("is_multi_day",e)},[u,P]),$=g.useCallback(e=>{u.answerQuestion("min_order_number",e),P("min_order_number",e)},[u,P]),B=g.useCallback(e=>{w(e),u.answerQuestion("price_per_person",e),P("price_per_person",e)},[u,P]),q=g.useCallback(()=>{y("contact")},[]),V=g.useCallback(async e=>{k(!0);try{const
|
|
2678
|
+
`,AH=({ratings:e,onCancel:t,funnelContextRef:n,updateContext:r})=>{var o;const{i18n:i}=Vd(),a=null==(o=i.language)?void 0:o.startsWith("de"),s=LE(),{state:l,actions:u,answerOf:c}=tj(),d=v.useMemo(()=>{if(!("qualification"in l))return!1;const e=l.qualification.steps.find(e=>"city"===e.id);return!0===(null==e?void 0:e.disabled)},["qualification"in l?l.qualification.steps:null]),f=v.useMemo(()=>d?dU.filter(e=>e!==aU):dU,[d]),[p,h]=g.useState(0),[m,y]=g.useState("questions"),[b,w]=g.useState(20),[x,k]=g.useState(!1),[S,E]=g.useState(null),[_,L]=g.useState(null),O=g.useRef(!1),{submitAsNewCustomer:j}=Wq(),M=f[p],T=t||(()=>window.history.back());g.useEffect(()=>{if("redesign_people_count"===M){void 0===c("min_order_number")&&u.answerQuestion("min_order_number",100);const e=c("event_type"),t=c("price_per_person");if(void 0===t&&e){const t=lO[e].catering_category,n=IE[t].defaultPricePerPerson;w(n),u.answerQuestion("price_per_person",n)}else void 0===t&&u.answerQuestion("price_per_person",b)}},[M,u,c,b]),g.useEffect(()=>{!O.current&&n.current.session_id&&(O.current=!0,gM(n.current,M))},[n.current.session_id,M]);const P=g.useCallback((e,t)=>{let r=t;t instanceof Date&&(r=DL(t,"yyyy-MM-dd")),pM(n.current,{step_id:M,step_index:p,question_id:e,answer_value:r,is_last_question:!0})},[n,p,M]),D=g.useCallback(()=>{const e=p+1;e>=f.length?y("loading"):h(e)},[p,f.length]),N=g.useCallback(()=>{p>0&&h(p-1)},[p]),R=g.useCallback(e=>{const t=f.indexOf(e);t>=0&&("contact"===m&&y("questions"),h(t))},[m,f]),A=g.useCallback(e=>{u.answerQuestion("city",e),P("city",e),r({city:e}),D()},[u,P,r,D]),I=g.useCallback(e=>{const t=function(e){return lO[e]}(e);u.answerQuestion("event_type",e),u.answerQuestion("service_type",t.service_type),u.answerQuestion("catering_categories",[t.catering_category]),P("event_type",e),r({service_type:t.service_type,total_steps:f.length+1}),D()},[u,P,r,D,f.length]),F=g.useCallback(e=>{e&&(u.answerQuestion("event_date",e),P("event_date",e))},[u,P]),z=g.useCallback(e=>{u.answerQuestion("is_multi_day",e),P("is_multi_day",e)},[u,P]),$=g.useCallback(e=>{u.answerQuestion("min_order_number",e),P("min_order_number",e)},[u,P]),B=g.useCallback(e=>{w(e),u.answerQuestion("price_per_person",e),P("price_per_person",e)},[u,P]),q=g.useCallback(()=>{y("contact")},[]),V=g.useCallback(async e=>{k(!0);const t="london"===c("city")?"United Kingdom":"Germany";try{const r={first_name:e.vorname,last_name:e.nachname,company:e.firma,email:e.email,phone:e.telefon,deliveryAddressStreet:e.deliveryAddressStreet,deliveryAddressStreetNumber:e.deliveryAddressStreetNumber,deliveryAddressPostalCode:e.deliveryAddressPostalCode,deliveryAddressCity:e.deliveryAddressCity,deliveryAddressCountry:e.deliveryAddressCountry||t,comment:e.kommentar},o=await j(r),{signInToken:i,opportunity:a,isUkLead:l}=o||{};if(l)return mM(n.current),E(e),void y("done");if(!a||!a.id)return console.error("[HeyCater Funnel] submitAsNewCustomer returned invalid opportunity:",o),void k(!1);const u=i?`/${s.locale}/account/requests/${a.id}?one_time_sign_in_token=${i}`:`/${s.locale}/account/external/requests/${a.id}`;L(u),mM(n.current),E(e),y("done")}catch(r){console.error("Failed to submit request:",r),k(!1)}},[j,n,s.locale,c]),W=g.useCallback(()=>{y("questions"),h(f.length-1)},[f.length]),U=g.useCallback(()=>{switch(M){case"redesign_city":return!!c("city");case"redesign_event_type":return!!c("event_type");case"redesign_date":return!!c("event_date");case"redesign_people_count":const e=c("min_order_number");return"number"==typeof e&&e>0;default:return!1}},[M,c]),H=()=>({city:c("city"),eventType:c("event_type"),eventDate:c("event_date"),peopleCount:c("min_order_number")});if("loading"===m)return C.jsx(FH,{children:C.jsx(zH,{$fullWidth:!0,children:C.jsx(DU,{onComplete:q})})});if("contact"===m){const e=fU[cU],t=a?e.titleDe:e.titleEn,n=a?e.subtitleDe:e.subtitleEn;return C.jsxs(FH,{children:[C.jsx(pU,{currentStepId:cU,onStepClick:R,answers:H()}),C.jsxs(zH,{children:[C.jsxs($H,{children:[C.jsx(BH,{children:C.jsx(xD,{height:20})}),C.jsx(qH,{children:C.jsx(VH,{children:a?"Schritt 5 von 5":"Step 5 of 5"})}),C.jsx(UH,{children:C.jsx(HH,{$progress:100})})]}),C.jsxs(ZH,{children:[C.jsx(YH,{onClick:T,children:a?"Abbrechen":"Cancel"}),C.jsx(KH,{children:a?"Schritt 5 von 5":"Step 5 of 5"})]}),C.jsxs(lZ,{children:[C.jsx(QH,{children:t}),C.jsx(JH,{children:n}),C.jsx(YU,{onSubmit:V,onBack:W,isSubmitting:x})]})]})]})}if("done"===m){const e=(null==S?void 0:S.vorname)||"",t=(null==S?void 0:S.email)||"",n=a?[{n:"1",title:"Wir prüfen deine Anfrage",desc:"Unser Team schaut sich deine Anfrage an."},{n:"2",title:"Du erhältst Angebote",desc:"Innerhalb weniger Stunden bekommst du bis zu 3 passende Angebote."},{n:"3",title:"Buche deinen Favoriten",desc:"Vergleiche die Angebote und buche, wenn du bereit bist."}]:[{n:"1",title:"We review your request",desc:"Our team will look at your request."},{n:"2",title:"You receive offers",desc:"Within a few hours you'll receive up to 3 matching offers."},{n:"3",title:"Book your favorite",desc:"Compare the offers and book when you're ready."}];return C.jsx(FH,{children:C.jsx(zH,{$fullWidth:!0,children:C.jsxs(uZ,{children:[C.jsx(cZ,{children:C.jsx(xD,{height:24})}),C.jsxs(dZ,{children:[C.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round",children:C.jsx("path",{d:"M20 6L9 17l-5-5"})}),a?"Anfrage gesendet":"Request sent"]}),C.jsx(fZ,{children:a?`Danke, ${e}!`:`Thank you, ${e}!`}),C.jsx(pZ,{children:a?"Wir haben deine Anfrage erhalten und stellen jetzt passende Angebote für dich zusammen.":"We have received your request and are now putting together matching offers for you."}),C.jsxs(hZ,{children:[C.jsx(mZ,{children:a?"So geht es weiter":"What happens next"}),C.jsx(gZ,{children:n.map(e=>C.jsxs(vZ,{children:[C.jsx(yZ,{children:e.n}),C.jsxs(bZ,{children:[C.jsx(wZ,{children:e.title}),C.jsx(xZ,{children:e.desc})]})]},e.n))})]}),C.jsx(CZ,{children:a?C.jsxs(C.Fragment,{children:["Eine Bestätigung ist unterwegs an ",C.jsx("strong",{children:t}),"."]}):C.jsxs(C.Fragment,{children:["A confirmation is on its way to ",C.jsx("strong",{children:t}),"."]})}),_&&C.jsx(kZ,{onClick:()=>window.location.href=_,children:a?"Zu meiner Anfrage":"View my request"})]})})})}const Z=fU[M],Y=a?Z.titleDe:Z.titleEn,K=a?Z.subtitleDe:Z.subtitleEn,G=f.length+1,Q=(()=>{const e=[],t=c("city"),n=c("event_type"),r=c("event_date");if(t&&e.push(eW[t]||t),n&&p>=2){const t=a?tW:nW;e.push(t[n]||n)}return p>=3&&r&&e.push(DL(r,"dd.MM.yy")),e})(),J=p>0,X=p>=1&&Q.length>0;return C.jsxs(FH,{children:[C.jsx(pU,{currentStepId:M,onStepClick:R,answers:H()}),C.jsxs(zH,{children:[C.jsxs($H,{children:[C.jsx(BH,{children:C.jsx(xD,{height:20})}),C.jsxs(qH,{children:[C.jsx(VH,{children:a?`Schritt ${p+1} von ${G}`:`Step ${p+1} of ${G}`}),C.jsx(WH,{onClick:T,children:a?"Abbrechen":"Cancel"})]}),C.jsx(UH,{children:C.jsx(HH,{$progress:(p+1)/G*100})})]}),C.jsxs(ZH,{children:[C.jsx(YH,{onClick:T,children:a?"Abbrechen":"Cancel"}),C.jsx(KH,{children:a?`Schritt ${p+1} von ${G}`:`Step ${p+1} of ${G}`})]}),C.jsxs(GH,{children:[C.jsx(QH,{children:Y}),K&&C.jsx(JH,{children:K}),C.jsx(XH,{children:(()=>{switch(M){case"redesign_city":return C.jsx(aW,{selected:c("city"),onSelect:A});case"redesign_event_type":return C.jsx(gW,{selected:c("event_type"),onSelect:I,variant:"primary"});case"redesign_date":return C.jsx(_W,{value:c("event_date"),onChange:F,isMultiDay:!!c("is_multi_day"),onMultiDayChange:z});case"redesign_people_count":return C.jsx(VW,{peopleCount:c("min_order_number")||100,budgetPerPerson:b,onPeopleCountChange:$,onBudgetPerPersonChange:B});default:return null}})()})]}),C.jsxs(eZ,{children:[X&&C.jsxs(tZ,{children:[C.jsx(nZ,{children:a?"Deine Auswahl:":"Your selection:"}),Q.map((e,t)=>C.jsx(oZ,{children:e},t))]}),C.jsxs(rZ,{children:[C.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round",children:C.jsx("path",{d:"M20 6L9 17l-5-5"})}),a?"Deine Anfrage ist kostenlos & unverbindlich":"Your request is free & non-binding"]}),C.jsxs(iZ,{children:[J&&C.jsx(aZ,{type:"button",onClick:N,children:a?"Zurück":"Back"}),C.jsx(sZ,{type:"button",onClick:D,disabled:!U(),children:a?"Weiter":"Continue"})]})]})]})]})},IH=Op`
|
|
2679
2679
|
from { opacity: 0; transform: translateY(8px); }
|
|
2680
2680
|
to { opacity: 1; transform: none; }
|
|
2681
2681
|
`,FH=_p.div`
|