1"use strict";(self.webpackChunkfrontend=self.webpackChunkfrontend||[]).push([[602],{602(e,s,t){t.r(s),t.d(s,{AdminLeadsPage:()=>L,default:()=>F});var a=t(9379),l=t(5043),n=t(9970),i=t(4980),c=t(1140),d=t(3390),r=t(2264),o=t(9938),x=t(5949),m=t(1654),h=t(3416),p=t(2054),u=t(6245),j=t(2024),v=t(5088),N=t(7104),f=t(5327),b=t(1286),g=t(1360),w=t(8693),A=t(7365),y=t(3165),_=t(9855),C=t(4919),k=t(1884),D=t(7118),S=t(614),E=t(6328),R=t(579);const B=e=>{var s,t;let{config:n,onClose:c,onSave:p}=e;const[u,v]=(0,l.useState)({is_active:null===(s=null===n||void 0===n?void 0:n.is_active)||void 0===s||s,title:(null===n||void 0===n?void 0:n.title)||"Wait! Don't Miss Out",subtitle:(null===n||void 0===n?void 0:n.subtitle)||"Get exclusive access to free dental training resources",description:(null===n||void 0===n?void 0:n.description)||"Join thousands of dental professionals who are elevating their practice.",cta_text:(null===n||void 0===n?void 0:n.cta_text)||"Get Free Access",interests_options:(null===n||void 0===n?void 0:n.interests_options)||["Composite Restorations","Aesthetic Dentistry","Practice Management"],show_phone_field:(null===n||void 0===n?void 0:n.show_phone_field)||!1,lead_magnet_title:(null===n||void 0===n?void 0:n.lead_magnet_title)||"Free Resource",lead_magnet_description:(null===n||void 0===n?void 0:n.lead_magnet_description)||"Download our exclusive guide",delay_seconds:(null===n||void 0===n?void 0:n.delay_seconds)||0,show_on_exit_intent:null===(t=null===n||void 0===n?void 0:n.show_on_exit_intent)||void 0===t||t}),[N,f]=(0,l.useState)(!1),[b,A]=(0,l.useState)(""),y=()=>{b.trim()&&!u.interests_options.includes(b.trim())&&(v((0,a.A)((0,a.A)({},u),{},{interests_options:[...u.interests_options,b.trim()]})),A(""))};return(0,R.jsx)("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:(0,R.jsxs)("div",{className:"bg-white rounded-2xl max-w-2xl w-full shadow-xl max-h-[90vh] overflow-y-auto",children:[(0,R.jsx)("div",{className:"p-6 border-b border-slate-100 sticky top-0 bg-white",children:(0,R.jsxs)("div",{className:"flex items-center justify-between",children:[(0,R.jsx)("h2",{className:"text-xl font-bold text-[#0D1B2A]",children:"Configure Exit Popup"}),(0,R.jsx)("button",{onClick:c,className:"text-slate-400 hover:text-slate-600",children:(0,R.jsx)(S.A,{className:"w-5 h-5"})})]})}),(0,R.jsxs)("div",{className:"p-6 space-y-6",children:[(0,R.jsxs)("div",{className:"flex items-center justify-between p-4 bg-slate-50 rounded-xl",children:[(0,R.jsxs)("div",{children:[(0,R.jsx)("p",{className:"font-medium text-[#0D1B2A]",children:"Enable Popup"}),(0,R.jsx)("p",{className:"text-xs text-slate-500",children:"Show exit-intent popup to visitors"})]}),(0,R.jsx)(m.d,{checked:u.is_active,onCheckedChange:e=>v((0,a.A)((0,a.A)({},u),{},{is_active:e}))})]}),(0,R.jsxs)("div",{className:"space-y-4 p-4 border border-slate-200 rounded-xl",children:[(0,R.jsx)("p",{className:"font-medium text-[#0D1B2A]",children:"Trigger Settings"}),(0,R.jsxs)("div",{className:"flex items-center justify-between",children:[(0,R.jsxs)("div",{children:[(0,R.jsx)("p",{className:"text-sm text-slate-700",children:"Exit Intent"}),(0,R.jsx)("p",{className:"text-xs text-slate-500",children:"Show when mouse leaves viewport"})]}),(0,R.jsx)(m.d,{checked:u.show_on_exit_intent,onCheckedChange:e=>v((0,a.A)((0,a.A)({},u),{},{show_on_exit_intent:e}))})]}),(0,R.jsxs)("div",{className:"space-y-2",children:[(0,R.jsx)(o.J,{children:"Delay (seconds)"}),(0,R.jsx)(r.p,{type:"number",min:"0",value:u.delay_seconds,onChange:e=>v((0,a.A)((0,a.A)({},u),{},{delay_seconds:parseInt(e.target.value)||0})),placeholder:"0 = immediate"}),(0,R.jsx)("p",{className:"text-xs text-slate-500",children:"Time delay before showing (if not using exit intent)"})]})]}),(0,R.jsxs)("div",{className:"space-y-4",children:[(0,R.jsxs)("div",{className:"space-y-2",children:[(0,R.jsx)(o.J,{children:"Title"}),(0,R.jsx)(r.p,{value:u.title,onChange:e=>v((0,a.A)((0,a.A)({},u),{},{title:e.target.value})),placeholder:"Wait! Don't Miss Out"})]}),(0,R.jsxs)("div",{className:"space-y-2",children:[(0,R.jsx)(o.J,{children:"Subtitle"}),(0,R.jsx)(r.p,{value:u.subtitle,onChange:e=>v((0,a.A)((0,a.A)({},u),{},{subtitle:e.target.value})),placeholder:"Get exclusive access..."})]}),(0,R.jsxs)("div",{className:"space-y-2",children:[(0,R.jsx)(o.J,{children:"Description"}),(0,R.jsx)(h.T,{value:u.description,onChange:e=>v((0,a.A)((0,a.A)({},u),{},{description:e.target.value})),rows:3})]}),(0,R.jsxs)("div",{className:"space-y-2",children:[(0,R.jsx)(o.J,{children:"Call-to-Action Text"}),(0,R.jsx)(r.p,{value:u.cta_text,onChange:e=>v((0,a.A)((0,a.A)({},u),{},{cta_text:e.target.value})),placeholder:"Get Free Access"})]})]}),(0,R.jsxs)("div",{className:"space-y-4 p-4 border border-slate-200 rounded-xl",children:[(0,R.jsx)("p",{className:"font-medium text-[#0D1B2A]",children:"Lead Magnet"}),(0,R.jsxs)("div",{className:"space-y-2",children:[(0,R.jsx)(o.J,{children:"Title"}),(0,R.jsx)(r.p,{value:u.lead_magnet_title,onChange:e=>v((0,a.A)((0,a.A)({},u),{},{lead_magnet_title:e.target.value})),placeholder:"Free Resource"})]}),(0,R.jsxs)("div",{className:"space-y-2",children:[(0,R.jsx)(o.J,{children:"Description"}),(0,R.jsx)(r.p,{value:u.lead_magnet_description,onChange:e=>v((0,a.A)((0,a.A)({},u),{},{lead_magnet_description:e.target.value})),placeholder:"Download our exclusive guide"})]})]}),(0,R.jsxs)("div",{className:"space-y-4 p-4 border border-slate-200 rounded-xl",children:[(0,R.jsx)("p",{className:"font-medium text-[#0D1B2A]",children:"Form Fields"}),(0,R.jsxs)("div",{className:"flex items-center justify-between",children:[(0,R.jsxs)("div",{children:[(0,R.jsx)("p",{className:"text-sm text-slate-700",children:"Show Phone Field"}),(0,R.jsx)("p",{className:"text-xs text-slate-500",children:"Request phone number (optional for visitors)"})]}),(0,R.jsx)(m.d,{checked:u.show_phone_field,onCheckedChange:e=>v((0,a.A)((0,a.A)({},u),{},{show_phone_field:e}))})]})]}),(0,R.jsxs)("div",{className:"space-y-4 p-4 border border-slate-200 rounded-xl",children:[(0,R.jsx)("p",{className:"font-medium text-[#0D1B2A]",children:"Interest Options"}),(0,R.jsx)("p",{className:"text-xs text-slate-500",children:"Options visitors can select to indicate their interests"}),(0,R.jsxs)("div",{className:"flex gap-2",children:[(0,R.jsx)(r.p,{value:b,onChange:e=>A(e.target.value),placeholder:"Add new interest...",onKeyPress:e=>"Enter"===e.key&&(e.preventDefault(),y())}),(0,R.jsx)(d.$,{type:"button",onClick:y,size:"icon",variant:"outline",children:(0,R.jsx)(g.A,{className:"w-4 h-4"})})]}),(0,R.jsx)("div",{className:"flex flex-wrap gap-2",children:u.interests_options.map(e=>(0,R.jsxs)(x.E,{variant:"secondary",className:"flex items-center gap-1 px-3 py-1",children:[e,(0,R.jsx)("button",{onClick:()=>(e=>{v((0,a.A)((0,a.A)({},u),{},{interests_options:u.interests_options.filter(s=>s!==e)}))})(e),className:"ml-1 hover:text-red-500",children:(0,R.jsx)(S.A,{className:"w-3 h-3"})})]},e))})]}),(0,R.jsxs)(d.$,{onClick:async()=>{f(!0);try{await i.oj.updatePopupConfig(u),E.oR.success("Popup configuration saved"),p(),c()}catch(e){E.oR.error("Failed to save configuration")}finally{f(!1)}},disabled:N,className:"w-full bg-[#0D1B2A] hover:bg-[#1B3A4B]",children:[N?(0,R.jsx)(j.A,{className:"w-4 h-4 mr-2 animate-spin"}):(0,R.jsx)(w.A,{className:"w-4 h-4 mr-2"}),"Save Configuration"]})]})]})})},L=()=>{const[e,s]=(0,l.useState)(!0),[t,a]=(0,l.useState)([]),[r,o]=(0,l.useState)(null),[m,h]=(0,l.useState)(null),[g,w]=(0,l.useState)(!1),[S,L]=(0,l.useState)("all"),F=async()=>{try{const[e,s]=await Promise.all([i.oj.getAll(),i.oj.getPopupConfig()]);a(e.data.leads||[]),o(e.data.stats||{}),h(s.data)}catch(e){E.oR.error("Failed to load leads data")}finally{s(!1)}};(0,l.useEffect)(()=>{F()},[]);const P=e=>{switch(e){case"new":return(0,R.jsxs)(x.E,{className:"bg-blue-100 text-blue-700",children:[(0,R.jsx)(v.A,{className:"w-3 h-3 mr-1"}),"New"]});case"contacted":return(0,R.jsxs)(x.E,{className:"bg-yellow-100 text-yellow-700",children:[(0,R.jsx)(f.A,{className:"w-3 h-3 mr-1"}),"Contacted"]});case"converted":return(0,R.jsxs)(x.E,{className:"bg-emerald-100 text-emerald-700",children:[(0,R.jsx)(p.A,{className:"w-3 h-3 mr-1"}),"Converted"]});case"lost":return(0,R.jsxs)(x.E,{className:"bg-red-100 text-red-700",children:[(0,R.jsx)(u.A,{className:"w-3 h-3 mr-1"}),"Lost"]});default:return(0,R.jsx)(x.E,{variant:"outline",children:e})}},J="all"===S?t:t.filter(e=>e.status===S);return e?(0,R.jsx)(n.NI,{children:(0,R.jsx)("div",{className:"flex items-center justify-center h-64",children:(0,R.jsx)(j.A,{className:"w-8 h-8 text-[#41EAD4] animate-spin"})})}):(0,R.jsx)(n.NI,{children:(0,R.jsxs)("div",{className:"space-y-6","data-testid":"admin-leads-page",children:[(0,R.jsxs)("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-4",children:[(0,R.jsxs)("div",{children:[(0,R.jsx)("h1",{className:"text-2xl font-bold text-[#0D1B2A] mb-1",children:"Lead Management"}),(0,R.jsx)("p",{className:"text-slate-500",children:"Capture and manage potential customers"})]}),(0,R.jsxs)("div",{className:"flex gap-2",children:[(0,R.jsxs)(d.$,{variant:"outline",onClick:()=>w(!0),children:[(0,R.jsx)(A.A,{className:"w-4 h-4 mr-2"}),"Configure Popup"]}),(0,R.jsxs)(d.$,{variant:"outline",onClick:async()=>{try{const e=await i.oj.exportCSV(),s=new Blob([e.data],{type:"text/csv"}),t=window.URL.createObjectURL(s),a=document.createElement("a");a.href=t,a.download="leads_export.csv",document.body.appendChild(a),a.click(),window.URL.revokeObjectURL(t),document.body.removeChild(a),E.oR.success("Leads exported")}catch(e){E.oR.error("Failed to export leads")}},children:[(0,R.jsx)(N.A,{className:"w-4 h-4 mr-2"}),"Export CSV"]})]})]}),r&&(0,R.jsxs)("div",{className:"grid sm:grid-cols-2 lg:grid-cols-4 gap-4",children:[(0,R.jsx)(c.Zp,{className:"border-slate-100",children:(0,R.jsx)(c.Wu,{className:"p-4",children:(0,R.jsxs)("div",{className:"flex items-center gap-3",children:[(0,R.jsx)("div",{className:"w-10 h-10 bg-blue-100 rounded-xl flex items-center justify-center",children:(0,R.jsx)(D.A,{className:"w-5 h-5 text-blue-600"})}),(0,R.jsxs)("div",{children:[(0,R.jsx)("p",{className:"text-xs text-slate-500",children:"Total Leads"}),(0,R.jsx)("p",{className:"text-xl font-bold text-[#0D1B2A]",children:r.total||0})]})]})})}),(0,R.jsx)(c.Zp,{className:"border-slate-100",children:(0,R.jsx)(c.Wu,{className:"p-4",children:(0,R.jsxs)("div",{className:"flex items-center gap-3",children:[(0,R.jsx)("div",{className:"w-10 h-10 bg-[#41EAD4]/20 rounded-xl flex items-center justify-center",children:(0,R.jsx)(k.A,{className:"w-5 h-5 text-[#41EAD4]"})}),(0,R.jsxs)("div",{children:[(0,R.jsx)("p",{className:"text-xs text-slate-500",children:"New Leads"}),(0,R.jsx)("p",{className:"text-xl font-bold text-[#0D1B2A]",children:r.new||0})]})]})})}),(0,R.jsx)(c.Zp,{className:"border-slate-100",children:(0,R.jsx)(c.Wu,{className:"p-4",children:(0,R.jsxs)("div",{className:"flex items-center gap-3",children:[(0,R.jsx)("div",{className:"w-10 h-10 bg-yellow-100 rounded-xl flex items-center justify-center",children:(0,R.jsx)(y.A,{className:"w-5 h-5 text-yellow-600"})}),(0,R.jsxs)("div",{children:[(0,R.jsx)("p",{className:"text-xs text-slate-500",children:"Contacted"}),(0,R.jsx)("p",{className:"text-xl font-bold text-[#0D1B2A]",children:r.contacted||0})]})]})})}),(0,R.jsx)(c.Zp,{className:"border-slate-100",children:(0,R.jsx)(c.Wu,{className:"p-4",children:(0,R.jsxs)("div",{className:"flex items-center gap-3",children:[(0,R.jsx)("div",{className:"w-10 h-10 bg-emerald-100 rounded-xl flex items-center justify-center",children:(0,R.jsx)(C.A,{className:"w-5 h-5 text-emerald-600"})}),(0,R.jsxs)("div",{children:[(0,R.jsx)("p",{className:"text-xs text-slate-500",children:"Converted"}),(0,R.jsx)("p",{className:"text-xl font-bold text-[#0D1B2A]",children:r.converted||0})]})]})})})]}),(null===r||void 0===r?void 0:r.interest_breakdown)&&Object.keys(r.interest_breakdown).length>0&&(0,R.jsxs)(c.Zp,{className:"border-slate-100",children:[(0,R.jsx)(c.aR,{className:"pb-2",children:(0,R.jsx)(c.ZB,{className:"text-sm font-medium text-slate-700",children:"Interest Breakdown"})}),(0,R.jsx)(c.Wu,{children:(0,R.jsx)("div",{className:"flex flex-wrap gap-2",children:Object.entries(r.interest_breakdown).map(e=>{let[s,t]=e;return(0,R.jsxs)(x.E,{variant:"outline",className:"px-3 py-1",children:[s,": ",(0,R.jsx)("span",{className:"font-bold ml-1",children:t})]},s)})})})]}),(0,R.jsx)("div",{className:"flex gap-2 border-b border-slate-200 overflow-x-auto",children:["all","new","contacted","converted","lost"].map(e=>(0,R.jsx)("button",{onClick:()=>L(e),className:"px-4 py-2 font-medium capitalize whitespace-nowrap transition-colors ".concat(S===e?"text-[#0D1B2A] border-b-2 border-[#41EAD4]":"text-slate-500 hover:text-slate-700"),
1children:e},e))}),(0,R.jsx)(c.Zp,{className:"border-slate-100",children:(0,R.jsx)(c.Wu,{className:"p-0",children:0===J.length?(0,R.jsxs)("div",{className:"text-center py-12 text-slate-500",children:[(0,R.jsx)(D.A,{className:"w-12 h-12 mx-auto mb-2 text-slate-300"}),(0,R.jsx)("p",{children:"No leads found"})]}):(0,R.jsx)("div",{className:"overflow-x-auto",children:(0,R.jsxs)("table",{className:"w-full",children:[(0,R.jsx)("thead",{children:(0,R.jsxs)("tr",{className:"text-left text-xs text-slate-500 border-b bg-slate-50",children:[(0,R.jsx)("th",{className:"p-4 font-medium",children:"Name"}),(0,R.jsx)("th",{className:"p-4 font-medium",children:"Contact"}),(0,R.jsx)("th",{className:"p-4 font-medium",children:"Interests"}),(0,R.jsx)("th",{className:"p-4 font-medium",children:"Source"}),(0,R.jsx)("th",{className:"p-4 font-medium",children:"Status"}),(0,R.jsx)("th",{className:"p-4 font-medium",children:"Date"}),(0,R.jsx)("th",{className:"p-4 font-medium",children:"Actions"})]})}),(0,R.jsx)("tbody",{className:"text-sm",children:J.map(e=>{var s,t,a;return(0,R.jsxs)("tr",{className:"border-b border-slate-50 hover:bg-slate-50",children:[(0,R.jsx)("td",{className:"p-4",children:(0,R.jsx)("p",{className:"font-medium text-[#0D1B2A]",children:e.name})}),(0,R.jsx)("td",{className:"p-4",children:(0,R.jsxs)("div",{className:"space-y-1",children:[(0,R.jsxs)("p",{className:"flex items-center gap-1 text-slate-600",children:[(0,R.jsx)(f.A,{className:"w-3 h-3"})," ",e.email]}),e.phone&&(0,R.jsxs)("p",{className:"flex items-center gap-1 text-slate-500 text-xs",children:[(0,R.jsx)(b.A,{className:"w-3 h-3"})," ",e.phone]})]})}),(0,R.jsx)("td",{className:"p-4",children:(0,R.jsxs)("div",{className:"flex flex-wrap gap-1",children:[null===(s=e.interests)||void 0===s?void 0:s.slice(0,2).map(e=>(0,R.jsx)(x.E,{variant:"outline",className:"text-xs",children:e},e)),(null===(t=e.interests)||void 0===t?void 0:t.length)>2&&(0,R.jsxs)(x.E,{variant:"outline",className:"text-xs",children:["+",e.interests.length-2]})]})}),(0,R.jsx)("td",{className:"p-4 text-slate-500 capitalize",children:null===(a=e.source)||void 0===a?void 0:a.replace("_"," ")}),(0,R.jsx)("td",{className:"p-4",children:P(e.status)}),(0,R.jsx)("td",{className:"p-4 text-slate-500 text-xs",children:new Date(e.created_at).toLocaleDateString()}),(0,R.jsx)("td",{className:"p-4",children:(0,R.jsxs)("div",{className:"flex items-center gap-2",children:[(0,R.jsxs)("select",{value:e.status,onChange:s=>(async(e,s)=>{try{await i.oj.updateStatus(e,{status:s}),E.oR.success("Lead status updated"),F()}catch(t){E.oR.error("Failed to update status")}})(e.lead_id,s.target.value),className:"text-xs border rounded px-2 py-1",children:[(0,R.jsx)("option",{value:"new",children:"New"}),(0,R.jsx)("option",{value:"contacted",children:"Contacted"}),(0,R.jsx)("option",{value:"converted",children:"Converted"}),(0,R.jsx)("option",{value:"lost",children:"Lost"})]}),(0,R.jsx)("button",{onClick:()=>(async e=>{if(window.confirm("Are you sure you want to delete this lead?"))try{await i.oj.deleteLead(e),E.oR.success("Lead deleted"),F()}catch(s){E.oR.error("Failed to delete lead")}})(e.lead_id),className:"text-red-500 hover:text-red-700 p-1",children:(0,R.jsx)(_.A,{className:"w-4 h-4"})})]})})]},e.lead_id)})})]})})})}),g&&(0,R.jsx)(B,{config:m,onClose:()=>w(!1),onSave:F})]})})},F=L},1654(e,s,t){t.d(s,{d:()=>o});var a=t(9379),l=t(3986),n=t(5043),i=t(7943),c=t(9766),d=t(579);const r=["className"],o=n.forwardRef((e,s)=>{let{className:t}=e,n=(0,l.A)(e,r);return(0,d.jsx)(i.bL,(0,a.A)((0,a.A)({className:(0,c.cn)("peer inline-flex h-5 w-9 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent shadow-sm transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input",t)},n),{},{ref:s,children:(0,d.jsx)(i.zi,{className:(0,c.cn)("pointer-events-none block h-4 w-4 rounded-full bg-background shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-4 data-[state=unchecked]:translate-x-0")})}
1))});o.displayName=i.bL.displayName},9938(e,s,t){t.d(s,{J:()=>m});var a=t(9379),l=t(3986),n=t(5043),i=t(5131),c=t(917),d=t(9766),r=t(579);const o=["className"],x=(0,c.F)("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),m=n.forwardRef((e,s)=>{let{className:t}=e,n=(0,l.A)(e,o);return(0,r.jsx)(i.b,(0,a.A)({ref:s,className:(0,d.cn)(x(),t)},n))});m.displayName=i.b.displayName}}]); 2//# sourceMappingURL=602.77876f0d.chunk.js.map
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.