PageSourceSearch

https://www.nands.ai/assets/LeadFormsIndex-BoC6RufP.js

js nands.ai collected 2026-10-05 15:24:22 UTC 17,086 bytes, 1 lines download raw bytes

1import{j as e,r as x}from"./react-vendor-CctNEwR7.js";import{F as b,J as k,K as p,L as j,S as O,M as B,N as M,O as R,Q as N,T as v,aQ as K,G as A,H as $,I as z,U as Q,ag as T,ah as Y,ai as J,aK as Z,aL as ee,aM as U,aN as V,ad as se,b7 as ae,ae as te,ao as le,ap as re,aO as ie,aq as ne}from"./index-_REeuTfa.js";import{eq as L}from"./vendor-CmXu_Ni5.js";import{L as ce}from"./ListSkeleton-CnSNc--w.js";import{b$ as oe,X as G,P as q,y as de,C as he,L as I,ad as ue,a as me,a9 as xe,c0 as pe}from"./icons-vendor-C9VE-SiQ.js";import{a as je}from"./router-vendor-ABiNHJfk.js";import"./editor-vendor-CaMhQ_21.js";import"./remark-rehype-vendor-CGzGRKMX.js";import"./utils-vendor-Dve6yBKa.js";import"./ui-vendor-CS6kyaug.js";import"./state-vendor-DiGQLKrA.js";import"./date-vendor-CHvMIOYV.js";import"./mdx-core-vendor-CszC-BnH.js";const ye=({field:n,index:c,onChange:y,onDelete:f,onMoveUp:i,onMoveDown:u})=>{const d=o=>{y({...n,...o})};return e.jsx(b,{className:"border-border",children:e.jsxs(k,{className:"pt-6",children:[e.jsxs("div",{className:"flex items-start justify-between mb-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(oe,{className:"h-5 w-5 text-muted-foreground cursor-move"}),e.jsxs("span",{className:"text-sm font-medium text-muted-foreground",children:["Field ",c+1]})]}),e.jsx(p,{variant:"ghost",size:"sm",onClick:f,className:"h-8 w-8 p-0 text-destructive hover:text-destructive",children:e.jsx(G,{className:"h-4 w-4"})})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(j,{htmlFor:`field-type-${c}`,children:"Field Type"}),e.jsxs(O,{value:n.type,onValueChange:o=>d({type:o,options:o==="select"?n.options||[]:void 0}),children:[e.jsx(B,{id:`field-type-${c}`,children:e.jsx(M,{})}),e.jsxs(R,{children:[e.jsx(N,{value:"text",children:"Text"}),e.jsx(N,{value:"email",children:"Email"}),e.jsx(N,{value:"phone",children:"Phone"}),e.jsx(N,{value:"select",children:"Dropdown"}),e.jsx(N,{value:"checkbox",children:"Checkbox"})]})]})]}),e.jsxs("div",{children:[e.jsx(j,{htmlFor:`field-label-${c}`,children:"Label *"}),e.jsx(v,{id:`field-label-${c}`,value:n.label,onChange:o=>d({label:o.target.value}),placeholder:"e.g., Full Name"})]}),["text","email","phone"].includes(n.type)&&e.jsxs("div",{children:[e.jsx(j,{htmlFor:`field-placeholder-${c}`,children:"Placeholder"}),e.jsx(v,{id:`field-placeholder-${c}`,value:n.placeholder||"",onChange:o=>d({placeholder:o.target.value}),placeholder:"e.g., Enter your name"})]}),n.type==="select"&&e.jsxs("div",{children:[e.jsx(j,{children:"Options *"}),e.jsxs("div",{className:"space-y-2",children:[(n.options||[]).map((o,l)=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(v,{value:o,onChange:a=>{const h=[...n.options||[]];h[l]=a.target.value,d({options:h})},placeholder:"Option value"}),e.jsx(p,{variant:"ghost",size:"sm",onClick:()=>{var h;const a=((h=n.options)==null?void 0:h.filter((g,S)=>S!==l))||[];d({options:a})},children:e.jsx(G,{className:"h-4 w-4"})})]},l)),e.jsxs(p,{variant:"outline",size:"sm",onClick:()=>{d({options:[...n.options||[],""]})},className:"w-full",children:[e.jsx(q,{className:"h-4 w-4 mr-2"}),"Add Option"]})]})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(K,{id:`field-required-${c}`,checked:n.required,onCheckedChange:o=>d({required:o})}),e.jsx(j,{htmlFor:`field-required-${c}`,className:"text-sm font-normal cursor-pointer",children:"Required field"})]})]})]})})},ve=({headline:n,description:c,fields:y,privacyPolicyURL:f})=>e.jsxs(b,{className:"border-border",children:[e.jsx(A,{children:e.jsx($,{children:"Form Preview"})}),e.jsx(k,{children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-2xl font-bold text-foreground",children:n}),c&&e.jsx("p",{className:"text-sm text-muted-foreground mt-2",children:c})]}),e.jsx("div",{className:"space-y-4",children:y.map((i,u)=>{var d;return e.jsxs("div",{children:[e.jsxs(j,{htmlFor:`preview-${i.id||u}`,children:[i.label,i.required&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),i.type==="text"&&e.jsx(v,{id:`preview-${i.id||u}`,type:"text",placeholder:i.placeholder||"",disabled:!0,className:"mt-1"}),i.type==="email"&&e.jsx(v,{id:`preview-${i.id||u}`,type:"email",placeholder:i.placeholder||"[email protected]",disabled:!0,className:"mt-1"}),i.type==="phone"&&e.jsx(v,{id:`preview-${i.id||u}`,type:"tel",placeholder:i.placeholder||"+1 (555) 000-0000",disabled:!0,className:"mt-1"}),i.type==="select"&&e.jsxs(O,{disabled:!0,children:[e.jsx(B,{className:"mt-1",children:e.jsx(M,{placeholder:"Select an option"})}),e.jsx(R,{children:(d=i.options)==null?void 0:d.map((o,l)=>e.jsx(N,{value:o,children:o},l))})]}),i.type==="checkbox"&&e.jsxs("div",{className:"flex items-center space-x-2 mt-2",children:[e.jsx(K,{id:`preview-${i.id||u}`,disabled:!0}),e.jsx(j,{htmlFor:`preview-${i.id||u}`,className:"text-sm font-normal",children:i.label})]})]},i.id||u)})}),e.jsx("div",{className:"text-sm text-muted-foreground",children:e.jsxs("a",{href:f,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 text-primary hover:underline",children:["Privacy Policy",e.
1jsx(de,{className:"h-3 w-3"})]})}),e.jsx(p,{className:"w-full",disabled:!0,children:"Submit"})]})})]}),fe=({headline:n,description:c,buttonText:y,buttonURL:f,onHeadlineChange:i,onDescriptionChange:u,onButtonTextChange:d,onButtonURLChange:o})=>e.jsxs("div",{className:"space-y-6",children:[e.jsxs(b,{children:[e.jsxs(A,{children:[e.jsx($,{children:"Thank You Page"}),e.jsx(z,{children:"Customize the message users see after submitting the form"})]}),e.jsxs(k,{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(j,{htmlFor:"thank-you-headline",children:"Headline *"}),e.jsx(v,{id:"thank-you-headline",value:n,onChange:l=>i(l.target.value),placeholder:"e.g., Thank you for your interest!"})]}),e.jsxs("div",{children:[e.jsx(j,{htmlFor:"thank-you-description",children:"Description"}),e.jsx(Q,{id:"thank-you-description",value:c||"",onChange:l=>u(l.target.value),placeholder:"e.g., We'll get back to you soon.",rows:3})]}),e.jsxs("div",{children:[e.jsx(j,{htmlFor:"thank-you-button-text",children:"Button Text"}),e.jsx(v,{id:"thank-you-button-text",value:y||"",onChange:l=>d(l.target.value),placeholder:"e.g., Visit Our Website"})]}),y&&e.jsxs("div",{children:[e.jsx(j,{htmlFor:"thank-you-button-url",children:"Button URL"}),e.jsx(v,{id:"thank-you-button-url",type:"url",value:f||"",onChange:l=>o(l.target.value),placeholder:"https://example.com"})]})]})]}),e.jsxs(b,{children:[e.jsx(A,{children:e.jsx($,{children:"Preview"})}),e.jsx(k,{children:e.jsxs("div",{className:"space-y-4 text-center py-8",children:[e.jsx(he,{className:"h-16 w-16 text-primary mx-auto"}),e.jsx("h2",{className:"text-2xl font-bold text-foreground",children:n}),c&&e.jsx("p",{className:"text-muted-foreground",children:c}),y&&f&&e.jsx(Button,{asChild:!0,className:"mt-4",children:e.jsx("a",{href:f,target:"_blank",rel:"noopener noreferrer",children:y})})]})})]})]}),_e=({formId:n,onSave:c,onCancel:y})=>{const[f,i]=x.useState(!1),[u,d]=x.useState(!1),[o,l]=x.useState(null),[a,h]=x.useState({name:"",headline:"",description:"",fields:[],privacy_policy_url:"",thank_you_headline:"",thank_you_description:"",thank_you_button_text:"",thank_you_button_url:""});x.useEffect(()=>{n&&(i(!0),T.getLeadForm(n).then(s=>{h({name:s.name,headline:s.headline,description:s.description,fields:s.fields,privacy_policy_url:s.privacy_policy_url,thank_you_headline:s.thank_you_headline,thank_you_description:s.thank_you_description,thank_you_button_text:s.thank_you_button_text,thank_you_button_url:s.thank_you_button_url})}).catch(s=>{l(s.message||"Failed to load form"),L.error("Failed to load form")}).finally(()=>i(!1)))},[n]);const g=()=>{const s={id:`field-${Date.now()}`,type:"text",label:"",placeholder:"",required:!1};h(t=>({...t,fields:[...t.fields||[],s]}))},S=(s,t)=>{const m=[...a.fields||[]];m[s]=t,h(_=>({..._,fields:m}))},D=s=>{var m;const t=((m=a.fields)==null?void 0:m.filter((_,C)=>C!==s))||[];h(_=>({..._,fields:t}))},P=()=>{var s,t,m,_,C;if(!((s=a.name)!=null&&s.trim()))return l("Form name is required"),!1;if(!((t=a.headline)!=null&&t.trim()))return l("Headline is required"),!1;if(!a.fields||a.fields.length===0)return l("At least one field is required"),!1;if(!((m=a.privacy_policy_url)!=null&&m.trim()))return l("Privacy policy URL is required"),!1;if(!((_=a.thank_you_headline)!=null&&_.trim()))return l("Thank you headline is required"),!1;for(const F of a.fields){if(!((C=F.label)!=null&&C.trim()))return l(`Field ${a.fields.indexOf(F)+1} label is required`),!1;if(F.type==="select"&&(!F.options||F.options.length===0))return l(`Field "${F.label}" must have at least one option`),!1}return!0},E=async()=>{if(l(null),!!P()){d(!0);try{if(n){const s={name:a.name,headline:a.headline,description:a.description,fields:a.fields,privacy_policy_url:a.privacy_policy_url,thank_you_headline:a.thank_you_headline,thank_you_description:a.thank_you_description,thank_you_button_text:a.thank_you_button_text,thank_you_button_url:a.thank_you_button_url},t=await T.updateLeadForm(n,s);L.success("Form updated successfully"),c==null||c(t)}else{const s={name:a.name,headline:a.headline,description:a.description,fields:a.fields,privacy_policy_url:a.privacy_policy_url,thank_you_headline:a.thank_you_headline,thank_you_description:a.thank_you_description,thank_you_button_text:a.thank_you_button_text,thank_you_button_url:a.thank_you_button_url},t=await T.createLeadForm(s);L.success("Form created successfully"),c==null||c(t)}}catch(s){const t=s.message||"Failed to save form";l(t),L.error(t)}finally{d(!1)}}};return f?e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx(I,{className:"h-8 w-8 animate-spin text-primary"})}):e.jsxs("div",{className:"space-y-6",children:[o&&e.jsx(Y,{variant:"destructive",children:e.jsx(J,{children:o})}),e.jsxs(b,{children:[e.jsxs(A,{children:[e.jsx($,{children:"Form Information"}),e.jsx(z,{children:"Basic information about your lead form"})]}),e.jsxs(k,{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(j,{htmlFor:"form-name",children:"Form Name *"}),e.jsx(v,{id:"form-name",value:a.name||"",onChange:s=>h(t=>({...t,name:s.target.value})),placeholder:"e.g., Contact Form"})]}),e.jsxs("div",{children:[e.jsx(j,{htmlFor:"form-headline",children:"Headline *"}),e.jsx(v,{id:"form-headline",value:a.headline||"",onChange:s=>h(t=>({...t,headline:s.target.value})),placeholder:"e.g., Get in Touch"})]}),e.jsxs("div",{children:[e.jsx(j,{htmlFor:"form-description",children:"Description"}),e.jsx(Q,{id:"form-description",value:a.description||"",onChange:s=>h(t=>({...t,description:s.target.value})),placeholder:"Optional description",rows:3})]}),e.jsxs("div",{children:[e.jsx(j,{htmlFor:"privacy-policy-url",children:"Privacy Policy URL *"}),e.jsx(v,{id:"privacy-policy-url",type:"url",value:a.privacy_policy_url||"",onChange:s=>h(t=>({...t,privacy_policy_url:s.target.value})),placeholder:"https://example.com/privacy"})]})]})]}),e.jsxs(Z,{defaultValue:"fields",className:"w-full",children:[e.jsxs(ee,{className:"grid w-full grid-cols-2",children:[e.jsx(U,{value:"fields",children:"Form Fields"}),e.jsx(U,{value:"preview",children:"Preview"})]}),e.jsxs(V,{value:"fields",className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h3",{className:"text-lg font-semibold",children:"Form Fields"}),e.jsxs(p,{onClick:g,size:"sm",children:[e.jsx(q,{className:"h-4 w-4 mr-2"}),"Add Field"]})]}),a.fields&&a.fields.length>0?e.jsx("div",{className:"space-y-4",children:a.fields.map((s,t)=>e.jsx(ye,{field:s,index:t,onChange:m=>S(t,m),onDelete:()=>D(t)},s.id||t))}):e.jsx(b,{children:e.jsxs(k,{className:"py-12 text-center",children:[e.jsx("p",{className:"text-muted-foreground mb-4",children:"No fields yet. Add your first field to get started."}),e.jsxs(p,{onClick:g,children:[e.jsx(q,{className:"h-4 w-4 mr-2"}),"Add Field"]})]})})]}),e.jsx(V,{value:"preview",children:e.jsx(ve,{headline:a.headline||"",description:a.description,fields:a.fields||[],privacyPolicyURL:a.privacy_policy_url||""})})]}),e.jsx(fe,{headline:a.thank_you_headline||"",description:a.thank_you_description,buttonText:a.thank_you_button_text,buttonURL:a.thank_you_button_url,onHeadlineChange:s=>h(t=>({...t,thank_you_headline:s})),onDescriptionChange:s=>h(t=>({...t,thank_you_description:s})),onButtonTextChange:s=>h(t=>({...t,thank_you_button_text:s})),onButtonURLChange:s=>h(t=>({...t,thank_you_button_url:s}))}),e.jsxs("div",{className:"flex items-center justify-end gap-4",children:[y&&e.jsx(p,{variant:"outline",onClick:y,children:"Cancel"}),e.jsx(p,{onClick:E,disabled:u,children:u?e.jsxs(e.Fragment,{children:[e.jsx(I,{className:"h-4 w-4 mr-2 animate-spin"}),"Saving..."]}):e.jsxs(e.Fragment,{children:[e.jsx(ue,{className:"h-4 w-4 mr-2"}),n?"Update Form":"Create Form"]})})]})]})},$e=()=>{je();
1const[n,c]=x.useState([]),[y,f]=x.useState(!0),[i,u]=x.useState(null),[d,o]=x.useState(""),[l,a]=x.useState("all"),[h,g]=x.useState(!1),[S,D]=x.useState(null),[P,E]=x.useState(0),[s,t]=x.useState(1),m=20;x.useEffect(()=>{_()},[l,s]);const _=async()=>{f(!0),u(null);try{const r={page:s,limit:m};l!=="all"&&(r.status=l);const w=await T.listLeadForms(r);c(w.data),E(w.total)}catch(r){u(r.message||"Failed to load forms"),L.error("Failed to load forms")}finally{f(!1)}},C=()=>{D(null),g(!0)},F=r=>{D(r),g(!0)},W=async r=>{if(confirm("Are you sure you want to archive this form?"))try{await T.archiveLeadForm(r),L.success("Form archived successfully"),_()}catch(w){L.error(w.message||"Failed to archive form")}},X=r=>{g(!1),D(null),_()},H=n.filter(r=>{if(d){const w=d.toLowerCase();return r.name.toLowerCase().includes(w)||r.headline.toLowerCase().includes(w)}return!0});return e.jsx(se,{children:e.jsxs("div",{className:"container mx-auto py-8 px-4",children:[e.jsxs("div",{className:"flex items-center justify-between mb-6",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-3xl font-bold",children:"Lead Forms"}),e.jsx("p",{className:"text-muted-foreground mt-1",children:"Create and manage forms for lead generation ads"})]}),e.jsxs(p,{onClick:C,children:[e.jsx(q,{className:"h-4 w-4 mr-2"}),"Create Form"]})]}),e.jsxs("div",{className:"flex items-center gap-4 mb-6",children:[e.jsx("div",{className:"flex-1",children:e.jsxs("div",{className:"relative",children:[e.jsx(me,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(v,{placeholder:"Search forms...",value:d,onChange:r=>o(r.target.value),className:"pl-10"})]})}),e.jsxs(O,{value:l,onValueChange:a,children:[e.jsx(B,{className:"w-[180px]",children:e.jsx(M,{placeholder:"Filter by status"})}),e.jsxs(R,{children:[e.jsx(N,{value:"all",children:"All Status"}),e.jsx(N,{value:"active",children:"Active"}),e.jsx(N,{value:"archived",children:"Archived"})]})]})]}),y?e.jsx(ce,{count:6}):i?e.jsx(b,{children:e.jsxs(k,{className:"py-12 text-center",children:[e.jsx("p",{className:"text-destructive",children:i}),e.jsx(p,{onClick:_,className:"mt-4",children:"Try Again"})]})}):H.length===0?e.jsx(b,{children:e.jsxs(k,{className:"py-12 text-center",children:[e.jsx("p",{className:"text-muted-foreground mb-4",children:d||l!=="all"?"No forms match your filters":"No forms yet. Create your first form to get started."}),!d&&l==="all"&&e.jsxs(p,{onClick:C,children:[e.jsx(q,{className:"h-4 w-4 mr-2"}),"Create Form"]})]})}):e.jsx("div",{className:ae,children:H.map(r=>e.jsxs(b,{className:" transition-shadow",children:[e.jsx(A,{children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"flex-1",children:[e.jsx($,{className:"text-lg",children:r.name}),e.jsx(z,{className:"mt-1",children:r.headline})]}),e.jsx(te,{variant:r.status==="active"?"default":"secondary",children:r.status})]})}),e.jsx(k,{children:e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{children:e.jsxs("p",{className:"text-sm text-muted-foreground",children:[r.fields.length," field",r.fields.length!==1?"s":""]})}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(p,{variant:"outline",size:"sm",onClick:()=>F(r.id),children:[e.jsx(xe,{className:"h-4 w-4 mr-2"}),"Edit"]}),e.jsxs(p,{variant:"outline",size:"sm",onClick:()=>W(r.id),disabled:r.status==="archived",children:[e.jsx(pe,{className:"h-4 w-4 mr-2"}),"Archive"]})]})]})})]},r.id))}),P>m&&e.jsxs("div",{className:"flex items-center justify-center gap-4 mt-6",children:[e.jsx(p,{variant:"outline",onClick:()=>t(r=>Math.max(1,r-1)),disabled:s===1,children:"Previous"}),e.jsxs("span",{className:"text-sm text-muted-foreground",children:["Page ",s," of ",Math.
1ceil(P/m)]}),e.jsx(p,{variant:"outline",onClick:()=>t(r=>r+1),disabled:s>=Math.ceil(P/m),children:"Next"})]}),e.jsx(le,{open:h,onOpenChange:g,children:e.jsxs(re,{className:"max-w-4xl max-h-[90vh] overflow-y-auto",children:[e.jsx(ie,{children:e.jsx(ne,{children:S?"Edit Lead Form":"Create Lead Form"})}),e.jsx(_e,{formId:S||void 0,onSave:X,onCancel:()=>g(!1)})]})})]})})};export{$e 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.