PageSourceSearch

https://portal.zaag.ai/assets/Leads-B9umjtPH.js

js zaag.ai collected 2026-10-05 14:07:07 UTC 8,274 bytes, 1 lines download raw bytes

1var K=Object.defineProperty;var W=(s,i,t)=>i in s?K(s,i,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[i]=t;var w=(s,i,t)=>W(s,typeof i!="symbol"?i+"":i,t);import{aO as N,cO as X,aH as D,cP as H,aQ as k,O as z,b as J,g as V,T as P,j as e,ac as B,P as R,az as O,at as M,bJ as Z,cQ as ee,av as te,ab as j,aw as U,a1 as se,w as ie,a as ne,cJ as ae}from"./index-Buk4QAuB.js";import{b as v,k as c,F as m,K as F,x as _,I as Y,v as le,o as re}from"./antd-C4lq6VWG.js";import{u as T}from"./SettingsLayout-BTRNl0-z.js";import{S as de}from"./SettingFromLayout-D0e0qHfT.js";import{o as oe}from"./PencilSimple.es-HUIMl4Q6.js";import{r as ce}from"./Trash.es-DLWTW2oM.js";import{T as ue}from"./TertiaryBtn-CwmR6v1C.js";import{P as me}from"./PageTitle-SkqGmm8H.js";import{U as ge}from"./UpgradeWarning-BL08bceA.js";import"./CalendarDots.es-CtEjYbnp.js";import"./DeviceMobile.es-ELaQ4COo.js";import"./useKnowledgeCollpase-9gwZiZor.js";import"./PoweredByTxt-D5iBg8bg.js";import"./Copy.es-GHGrfz_o.js";import"./chat-textarea-BXEae57f.js";import"./PaperPlaneRight.es-BsP3Mqx-.js";class L{}w(L,"getLeadSettings",i=>N.get(`${X}/${i}/${D()}`)),w(L,"updateLeadSettings",(i,t)=>N.put(`${H}/${t}/${D()}`,i));const he=()=>{const{chatbotId:s}=k(),i=z(),t=J({mutationFn:r=>L.updateLeadSettings(r,s),onSuccess:()=>{P("success","Setting Changed","Lead settings has been changed successfully."),i.invalidateQueries({queryKey:["lead-settings",s],exact:!0})},onError:r=>{const a=V(r);P("error","Error",a)}});return{updateLeadSettings:t.mutateAsync,updateLeadSettingsLoading:t.isPending}},pe={TEXT:"Text",EMAIL:"Email",NUMBER:"Number"},fe={Text:"TEXT",Email:"EMAIL",Number:"NUMBER"},be=["Name","Email"],xe=s=>{var i;return s?{id:s.id,enabled:s.enabled??!1,formBehavior:((i=s.formBehavior)==null?void 0:i.toLowerCase())??"required",formTitle:s.formTitle??"",fields:(s.fields||[]).map((t,r)=>({id:r+1,label:t.label,fieldType:pe[t.fieldType]||t.fieldType,required:t.required??!1,enabled:t.enabled??!1,isDefault:be.includes(t.label)}))}:null},ye=s=>{var i;return s?{enabled:s.enabled,formBehavior:(i=s.formBehavior)==null?void 0:i.toUpperCase(),formTitle:s.formTitle,fields:(s.fields||[]).map(t=>{var r;return{label:t.label,fieldType:fe[t.fieldType]||((r=t.fieldType)==null?void 0:r.toUpperCase()),required:t.required,enabled:t.enabled}})}:null},je=(s,i)=>{const t=z(),{chatbotId:r}=k(),a=T(l=>l.leadSettings),d=T(l=>l.setLeadSettings),{updateLeadSettings:p,updateLeadSettingsLoading:x}=he(),[S,f]=v.useState(!1),[b,g]=v.useState(null);v.useEffect(()=>{a&&s.setFieldsValue({enabled:a.enabled,formBehavior:a.formBehavior,formTitle:a.formTitle})},[a]);const E=()=>{const l=ye(a);p(l)},C=()=>t.invalidateQueries({queryKey:["lead-settings",r],exact:!0}),y=(l,u)=>{d({...a,[l]:u})},I=(l,u,h)=>{const $=a.fields.map(q=>q.id===l?{...q,[u]:h}:q);d({...a,fields:$})},n=()=>{g(null),i.resetFields(),f(!0)},o=l=>{g(l),i.setFieldsValue({label:l.label,fieldType:l.fieldType,required:l.required}),f(!0)},G=l=>{const u=a.fields.filter(h=>h.id!==l);d({...a,fields:u})},A=()=>{f(!1),g(null),i.resetFields()};return{onFinish:E,handleCancel:C,submitLoading:x,handleSettingChange:y,handleFieldToggle:I,handleAddField:n,handleEditField:o,handleDeleteField:G,closeFieldDrawer:A,handleFieldSubmit:()=>{i.validateFields().then(l=>{if(b){const u=a.fields.map(h=>h.id===b.id?{...h,...l}:h);d({...a,fields:u})}else{const u={id:Date.now(),label:l.label,fieldType:l.fieldType,required:l.required||!1,enabled:!0,isDefault:!1};d({...a,fields:[...a.fields,u]})}A()})},fieldDrawerOpen:S,editingField:b}},Q=5,Fe=[{label:"Text",value:"Text"},{label:"Email",value:"Email"},{label:"Number",value:"Number"}],Te=()=>{const[s]=c.useForm(),[i]=c.useForm(),t=T(n=>n.leadSettings),{onFinish:r,handleCancel:a,submitLoading:d,handleSettingChange:p,handleFieldToggle:x,handleAddField:S,handleEditField:f,handleDeleteField:b,closeFieldDrawer:g,handleFieldSubmit:E,fieldDrawerOpen:C,editingField:y}=je(s,i),I=[{title:"Label",dataIndex:"label",key:"label",render:(n,o)=>e.jsxs("div",{children:[e.jsx("p",{style:{margin:0,color:"#1e293b"},children:n}),e.jsx("p",{style:{margin:0,color:"#6b7280",fontSize:13},children:o.fieldType})]})},{title:"Status",key:"enabled",width:120,align:"center",render:n=>e.jsx(F,{checked:n==null?void 0:n.enabled,onChange:o=>x(n.id,"enabled",o),disabled:n==null?void 0:n.isDefault})},{title:"Required",key:"required",width:120,align:"center",render:n=>e.jsx(F,{checked:n==null?void 0:n.required,onChange:o=>x(n.id,"required",o),disabled:n==null?void 0:n.isDefault})},{title:"Action",key:"action",width:80,align:"center",render:(n,o)=>!o.isDefault&&e.jsxs(m,{gap:12,justify:"center",children:[e.jsx(U,{icon:e.jsx(oe,{}),onClick:()=>f(o)}),e.jsx(U,{icon:e.jsx(ce,{color:se}),onClick:()=>b(o.id)})]})}];return e.jsxs(e.Fragment,{children:[e.jsx(de,{body:e.jsxs(c,{onFinish:r,form:s,layout:"vertical",children:[e.jsxs(m,{justify:"space-between",align:"center",style:{marginBottom:24},children:[e.jsx("div",{children:e.jsx(O,{title:"Configure your chatbot's lead collection feature from here."})}),e.jsxs(m,{align:"center",gap:8,children:[e.jsx("span",{style:{color:t!=null&&t.enabled?M:Z,fontWeight:500,fontSize:14},children:t!=null&&t.enabled?"Enabled":"Disabled"}),e.jsx(c.Item,{name:"enabled",valuePropName:"checked",style:{margin:0},children:e.jsx(F,{onChange:n=>p("enabled",n)})})]})]}),e.jsxs(m,{justify:"space-between",align:"center",style:{marginBottom:24},children:[e.jsx("p",{style:{margin:0,fontWeight:500,fontSize:14,color:"#1e293b"},children:"Leads Collection Form"}),e.jsx(c.Item,{name:"formBehavior",style:{margin:0},children:e.jsxs(_.Group,{onChange:n=>p("formBehavior",n.target.value),children:[e.jsx(_,{value:"skippable",children:"Skippable"}),e.jsx(_,{value:"required",children:"Required"})]})})]}),e.jsx(c.Item,{label:"Form Title",name:"formTitle",rules:[{required:!0,message:"Form title is required."}],children:e.jsx(Y,{showCount:!0,maxLength:ee,placeholder:"Enter form title",onCh
1ange:n=>p("formTitle",n.target.value)})}),e.jsxs("div",{style:{marginTop:12},children:[e.jsx("p",{style:{margin:0},children:"Leads Form Fields"}),e.jsx(O,{title:e.jsxs("p",{style:{margin:0},children:["You can enable & add up to ",e.jsx("strong",{children:Q})," fields in your form."]})})]}),e.jsx(le,{columns:I,dataSource:(t==null?void 0:t.fields)||[],rowKey:"id",pagination:!1,style:{marginTop:16},footer:()=>{var n;return((n=t==null?void 0:t.fields)==null?void 0:n.length)<Q&&e.jsx(ue,{iconPosition:"start",icon:e.jsx(te,{color:M}),btnName:"Add New Field",onClick:S})}})]}),footer:e.jsxs(m,{justify:"end",gap:16,children:[e.jsx(B,{btnName:"Cancel",onClick:()=>a(),loading:d}),e.jsx(R,{btnName:"Save Changes",loading:d,onClick:()=>s.submit()})]})}),e.jsxs(j,{open:C,closeDrawer:g,children:[e.jsx(j.Title,{title:y?"Edit Field":"Add New Field",closeDrawer:g}),e.jsx(j.Body,{children:e.jsxs(c,{form:i,layout:"vertical",onFinish:E,children:[e.jsx(c.Item,{label:"Label",name:"label",rules:[{required:!0,message:"Field label is required."}],children:e.jsx(Y,{placeholder:"Enter your label"})}),e.jsx(c.Item,{label:"Input Type",name:"fieldType",rules:[{required:!0,message:"Input type is required."}],children:e.jsx(re,{placeholder:"Select input type",options:Fe})}),e.jsxs(m,{justify:"space-between",align:"center",children:[e.jsx("p",{style:{margin:0,fontWeight:500,fontSize:14,color:"#1e293b"},children:"Make this Field Required"}),e.jsx(m,{align:"center",gap:8,children:e.jsx(c.Item,{name:"required",valuePropName:"checked",style:{margin:0},children:e.jsx(F,{checkedChildren:"Yes",unCheckedChildren:"No"})})})]})]})}),e.jsx(j.Footer,{children:e.jsxs(m,{gap:8,children:[e.jsx(B,{btnName:"Cancel",onClick:g,style:{width:"50%"}}),e.jsx(R,{btnName:y?"Update Field":"Create New Field",onClick:()=>i.submit(),style:{width:"50%"}})]})})]})]})},Le=()=>{const{chatbotId:s}=k(),i=T(a=>a.setLeadSettings),{data:t,isFetching:r}=ie({queryKey:["lead-settings",s],queryFn:async()=>{const a=await L.getLeadSettings(s),d=xe(a.data);return i(d),d}});return{leadSettings:t,leadSettingsLoading:r}},Ye=()=>{const s=ne(t=>t.currentPlan),{leadSettingsLoading:i}=Le();return e.jsxs("div",{style:{height:"100%"},children:[e.jsx(me,{title:"Lead Settings"}),s!=null&&s.hasLeadCollection?i?e.jsx(ae,{}):e.jsx(Te,{}):e.jsx(ge,{})]})};export{Ye as default};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.