PageSourceSearch

https://www.w3mct.com/assets/Prospects-CY3tUoeS.js

js w3mct.com collected 2026-10-04 14:31:54 UTC 17,697 bytes, 13 lines download raw bytes

1import{c as se,af as xe,r as g,j as e,B as p,I as h,U as he,m as je,T as ge,v as L,n as A,P as x,s as N}from"./index-B6Gxx4GM.js";import{u as ve}from"./useQuery-C3bj8Vn9.js";import{u as P}from"./useMutation-r1Y5CKuG.js";import{T as pe,a as fe,b as K,c as f,d as ye,e as y}from"./table-Dc0U_w2w.js";import{D as W,e as H,a as $,b as J,c as G}from"./dialog-CppMw5qz.js";import{S as F,a as I,b as T,c as q,d as n}from"./select-C_mcmpeV.js";import{L as u}from"./label-BERruQyk.js";import{T as X,P as we}from"./textarea-BcRGzi4J.js";import{U as be}from"./upload-DwsC-UAv.js";import{D as Ne}from"./download-CgwcAI_J.js";import{U as _e}from"./user-plus-Da1fkvKz.js";import{M as Y}from"./mail-B7eLQSox.js";import{P as Ce}from"./phone-C3u-PMtk.js";import{B as Se}from"./building-2-MQmya7TU.js";import{S as ke}from"./square-pen-L-a7STHH.js";import{T as Le}from"./trash-2-Beq5DyJU.js";import"./index-CThjfcc1.js";import"./chevron-down-CgjgJzcZ.js";import"./check-rlthyrJ0.js";/**
2 * @license lucide-react v0.462.0 - ISC
3 *
4 * This source code is licensed under the ISC license.
5 * See the LICENSE file in the root directory of this source tree.
6 */const Pe=se("Linkedin",[["path",{d:"M16 8a6 6 0 0 1 6 6v7h-4v-7a2 2 0 0 0-2-2 2 2 0 0 0-2 2v7h-4v-7a6 6 0 0 1 6-6z",key:"c2jq9f"}],["rect",{width:"4",height:"12",x:"2",y:"9",key:"mk3on5"}],["circle",{cx:"4",cy:"4",r:"2",key:"bt5ra8"}]]);/**
7 * @license lucide-react v0.462.0 - ISC
8 *
9 * This source code is licensed under the ISC license.
10 * See the LICENSE file in the root directory of this source tree.
11 */const Fe=se("Tag",[["path",{d:"M12.586 2.586A2 2 0 0 0 11.172 2H4a2 2 0 0 0-2 2v7.172a2 2 0 0 0 .586 1.414l8.704 8.704a2.426 2.426 0 0 0 3.42 0l6.58-6.58a2.426 2.426 0 0 0 0-3.42z",key:"vktsd0"}],["circle",{cx:"7.5",cy:"7.5",r:".5",fill:"currentColor",key:"kqv944"}]]),Z={new:"bg-blue-100 text-blue-800",contacted:"bg-yellow-100 text-yellow-800",responded:"bg-green-100 text-green-800",qualified:"bg-purple-100 text-purple-800",unqualified:"bg-gray-100 text-gray-800",converted:"bg-emerald-100 text-emerald-800"},ee={manual:"bg-gray-100 text-gray-800",linkedin:"bg-blue-100 text-blue-800",csv_import:"bg-orange-100 text-orange-800",web_form:"bg-green-100 text-green-800",api:"bg-purple-100 text-purple-800"};function Ge(){const _=xe(),[w,ae]=g.useState(""),[D,te]=g.useState("all"),[M,le]=g.useState("all"),[ne,C]=g.useState(!1),[ie,R]=g.useState(!1),[S,Q]=g.useState(null),[a,o]=g.useState({email:"",first_name:"",last_name:"",company:"",job_title:"",phone:"",linkedin_url:"",website:"",location:"",source:"manual",status:"new",notes:"",tags:""}),[E,B]=g.useState(""),{data:i,isLoading:re}=ve({queryKey:["prospects"],queryFn:async()=>{const{data:s,error:l}=await N.from("prospects").select("*").order("created_at",{ascending:!1});if(l)throw l;return s}}),O=P({mutationFn:async s=>{const{error:l}=await N.from("prospects").insert([s]);if(l)throw l},onSuccess:()=>{_.invalidateQueries({queryKey:["prospects"]}),x({title:"Prospect added successfully"}),U(),C(!1)},onError:s=>{x({title:"Error adding prospect",description:s.message,variant:"destructive"})}}),z=P({mutationFn:async({id:s,...l})=>{const{error:d}=await N.from("prospects").update(l).eq("id",s);if(d)throw d},onSuccess:()=>{_.invalidateQueries({queryKey:["prospects"]}),x({title:"Prospect updated successfully"}),U(),C(!1)},onError:s=>{x({title:"Error updating prospect",description:s.message,variant:"destructive"})}}),ce=P({mutationFn:async s=>{const{error:l}=await N.from("prospects").delete().eq("id",s);if(l)throw l},onSuccess:()=>{_.invalidateQueries({queryKey:["prospects"]}),x({title:"Prospect deleted successfully"})},onError:s=>{x({title:"Error deleting prospect",description:s.message,variant:"destructive"})}}),V=P({mutationFn:async s=>{const{error:l}=await N.from("prospects").upsert(s,{onConflict:"email",ignoreDuplicates:!1});if(l)throw l},onSuccess:()=>{_.invalidateQueries({queryKey:["prospects"]}),x({title:"Prospects imported successfully"}),B(""),R(!1)},onError:s=>{x({title:"Error importing prospects",description:s.message,variant:"destructive"})}}),U=()=>{o({email:"",first_name:"",last_name:"",company:"",job_title:"",phone:"",linkedin_url:"",website:"",location:"",source:"manual",status:"new",notes:"",tags:""}),Q(null)},oe=s=>{var l;Q(s),o({email:s.email,first_name:s.first_name||"",last_name:s.last_name||"",company:s.company||"",job_title:s.job_title||"",phone:s.phone||"",linkedin_url:s.linkedin_url||"",website:s.website||"",location:s.location||"",source:s.source,status:s.status,notes:s.notes||"",tags:((l=s.tags)==null?void 0:l.join(", "))||""}),C(!0)},de=s=>
11{s.preventDefault();const l={email:a.email,first_name:a.first_name||null,last_name:a.last_name||null,company:a.company||null,job_title:a.job_title||null,phone:a.phone||null,linkedin_url:a.linkedin_url||null,website:a.website||null,location:a.location||null,source:a.source,status:a.status,notes:a.notes||null,tags:a.tags?a.tags.split(",").map(d=>d.trim()).filter(Boolean):null};S?z.mutate({id:S.id,...l}):O.mutate(l)},me=()=>{if(!E.trim()){x({title:"Please paste CSV content",variant:"destructive"});return}const s=E.trim().split(`
12`);if(s.length<2){x({title:"CSV must have header and at least one data row",variant:"destructive"});return}const l=s[0].split(",").map(m=>m.trim().toLowerCase()),d=l.findIndex(m=>m.includes("email"));if(d===-1){x({title:"CSV must have an email column",variant:"destructive"});return}const v=[];for(let m=1;m<s.length;m++){const c=s[m].split(",").map(t=>t.trim());if(c[d]){const t={email:c[d],source:"csv_import",status:"new"};l.forEach((r,j)=>{r.includes("first")&&r.includes("name")?t.first_name=c[j]||null:r.includes("last")&&r.includes("name")?t.last_name=c[j]||null:r.includes("company")||r.includes("organization")?t.company=c[j]||null:r.includes("title")||r.includes("position")?t.job_title=c[j]||null:r.includes("phone")?t.phone=c[j]||null:r.includes("linkedin")?t.linkedin_url=c[j]||null:r.includes("website")||r.includes("url")?t.website=c[j]||null:(r.includes("location")||r.includes("city"))&&(t.location=c[j]||null)}),v.push(t)}}if(v.length===0){x({title:"No valid prospects found in CSV",variant:"destructive"});return}V.mutate(v)},ue=()=>{if(!(i!=null&&i.length))return;const s=["Email","First Name","Last Name","Company","Job Title","Phone","LinkedIn","Website","Location","Source","Status","Tags","Created At"],l=i.map(t=>{var r;return[t.email,t.first_name||"",t.last_name||"",t.company||"",t.job_title||"",t.phone||"",t.linkedin_url||"",t.website||"",t.location||"",t.source,t.status,((r=t.tags)==null?void 0:r.join("; "))||"",A(new Date(t.created_at),"yyyy-MM-dd")]}),d=[s.join(","),...l.map(t=>t.map(r=>`"${r}"`).join(","))].join(`
13`),v=new Blob([d],{type:"text/csv"}),m=URL.createObjectURL(v),c=document.createElement("a");c.href=m,c.download=`prospects-${A(new Date,"yyyy-MM-dd")}.csv`,c.click(),URL.revokeObjectURL(m)},b=i==null?void 0:i.filter(s=>{var m,c,t;const l=!w||s.email.toLowerCase().includes(w.toLowerCase())||((m=s.first_name)==null?void 0:m.toLowerCase().includes(w.toLowerCase()))||((c=s.last_name)==null?void 0:c.toLowerCase().includes(w.toLowerCase()))||((t=s.company)==null?void 0:t.toLowerCase().includes(w.toLowerCase())),d=D==="all"||s.status===D,v=M==="all"||s.source===M;return l&&d&&v}),k={total:(i==null?void 0:i.length)||0,new:(i==null?void 0:i.filter(s=>s.status==="new").length)||0,contacted:(i==null?void 0:i.filter(s=>s.status==="contacted").length)||0,responded:(i==null?void 0:i.filter(s=>s.status==="responded").length)||0};return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-3xl font-bold text-gray-900",children:"Prospects"}),e.jsx("p",{className:"text-gray-600",children:"Manage your outreach contacts"})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(W,{open:ie,onOpenChange:R,children:[e.jsx(H,{asChild:!0,children:e.jsxs(p,{variant:"outline",children:[e.jsx(be,{className:"w-4 h-4 mr-2"}),"Import CSV"]})}),e.jsxs($,{className:"max-w-2xl",children:[e.jsx(J,{children:e.jsx(G,{children:"Import Prospects from CSV"})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"text-sm text-gray-600",children:[e.jsx("p",{className:"font-medium mb-2",children:"Supported columns:"}),e.jsx("p",{children:"email (required), first_name, last_name, company, job_title, phone, linkedin_url, website, location"}),e.jsx("p",{className:"mt-2 text-xs",children:"Works with LinkedIn exports and most CRM exports."})]}),e.jsx(X,{placeholder:"Paste your CSV content here...",value:E,onChange:s=>B(s.target.value),rows:10,className:"font-mono text-sm"}),e.jsx(p,{onClick:me,disabled:V.isPending,className:"w-full",children:V.isPending?"Importing...":"Import Prospects"})]})]})]}),e.jsxs(p,{variant:"outline",onClick:ue,disabled:!(i!=null&&i.length),children:[e.jsx(Ne,{className:"w-4 h-4 mr-2"}),"Export"]}),e.jsxs(W,{open:ne,onOpenChange:s=>{C(s),s||U()},children:[e.jsx(H,{asChild:!0,children:e.jsxs(p,{children:[e.jsx(we,{className:"w-4 h-4 mr-2"}),"Add Prospect"]})}),e.jsxs($,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsx(J,{children:e.jsx(G,{children:S?"Edit Prospect":"Add New Prospect"})}),e.jsxs("form",{onSubmit:de,className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(u,{htmlFor:"email",children:"Email *"}),e.jsx(h,{id:"email",type:"email",value:a.email,onChange:s=>o({...a,email:s.target.value}),required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(u,{htmlFor:"phone",children:"Phone"}
13),e.jsx(h,{id:"phone",value:a.phone,onChange:s=>o({...a,phone:s.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(u,{htmlFor:"first_name",children:"First Name"}),e.jsx(h,{id:"first_name",value:a.first_name,onChange:s=>o({...a,first_name:s.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(u,{htmlFor:"last_name",children:"Last Name"}),e.jsx(h,{id:"last_name",value:a.last_name,onChange:s=>o({...a,last_name:s.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(u,{htmlFor:"company",children:"Company"}),e.jsx(h,{id:"company",value:a.company,onChange:s=>o({...a,company:s.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(u,{htmlFor:"job_title",children:"Job Title"}),e.jsx(h,{id:"job_title",value:a.job_title,onChange:s=>o({...a,job_title:s.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(u,{htmlFor:"linkedin_url",children:"LinkedIn URL"}),e.jsx(h,{id:"linkedin_url",value:a.linkedin_url,onChange:s=>o({...a,linkedin_url:s.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(u,{htmlFor:"website",children:"Website"}),e.jsx(h,{id:"website",value:a.website,onChange:s=>o({...a,website:s.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(u,{htmlFor:"location",children:"Location"}),e.jsx(h,{id:"location",value:a.location,onChange:s=>o({...a,location:s.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(u,{htmlFor:"source",children:"Source"}),e.jsxs(F,{value:a.source,onValueChange:s=>o({...a,source:s}),children:[e.jsx(I,{children:e.jsx(T,{})}),e.jsxs(q,{children:[e.jsx(n,{value:"manual",children:"Manual"}),e.jsx(n,{value:"linkedin",children:"LinkedIn"}),e.jsx(n,{value:"csv_import",children:"CSV Import"}),e.jsx(n,{value:"web_form",children:"Web Form"}),e.jsx(n,{value:"api",children:"API"})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(u,{htmlFor:"status",children:"Status"}),e.jsxs(F,{value:a.status,onValueChange:s=>o({...a,status:s}),children:[e.jsx(I,{children:e.jsx(T,{})}),e.jsxs(q,{children:[e.jsx(n,{value:"new",children:"New"}),e.jsx(n,{value:"contacted",children:"Contacted"}),e.jsx(n,{value:"responded",children:"Responded"}),e.jsx(n,{value:"qualified",children:"Qualified"}),e.jsx(n,{value:"unqualified",children:"Unqualified"}),e.jsx(n,{value:"converted",children:"Converted"})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(u,{htmlFor:"tags",children:"Tags (comma-separated)"}),e.jsx(h,{id:"tags",value:a.tags,onChange:s=>o({...a,tags:s.target.value}),placeholder:"local, ai-interested, small-business"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(u,{htmlFor:"notes",children:"Notes"}),e.jsx(X,{id:"notes",value:a.notes,onChange:s=>o({...a,notes:s.target.value}),rows:3})]}),e.jsx(p,{type:"submit",className:"w-full",disabled:O.isPending||z.isPending,children:S?"Update Prospect":"Add Prospect"})]})]})]})]})]}),e.jsxs("div",{className:"grid grid-cols-4 gap-4",children:[e.jsxs("div",{className:"bg-white p-4 rounded-lg border",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(he,{className:"w-5 h-5 text-gray-600"}),e.jsx("span",{className:"text-sm text-gray-600",children:"Total"})]}),e.jsx("p",{className:"text-2xl font-bold mt-1",children:k.total})]}),e.jsxs("div",{className:"bg-white p-4 rounded-lg border",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(_e,{className:"w-5 h-5 text-blue-600"}),e.jsx("span",{className:"text-sm text-gray-600",children:"New"})]}),e.jsx("p",{className:"text-2xl font-bold mt-1",children:k.new})]}),e.jsxs("div",{className:"bg-white p-4 rounded-lg border",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Y,{className:"w-5 h-5 text-yellow-600"}),e.jsx("span",{className:"text-sm text-gray-600",children:"Contacted"})]}),e.jsx("p",{className:"text-2xl font-bold mt-1",children:k.contacted})]}),e.jsxs("div",{className:"bg-white p-4 rounded-lg border",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Fe,{className:"w-5 h-5 text-green-600"}),e.jsx("span",{className:"text-sm text-gray-600",children:"Responded"})]}),e.jsx("p",{className:"text-2xl font-bold mt-1",children:k.responded})]})]}),e.jsxs("div",{className:"flex gap-4 items-center",children:[e.jsxs("div",{className:"relative flex-1 max-w-md",children:[e.jsx(je,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-gray-400"}),e.jsx(h,{placeholder:"Search prospects...",value:w,onChange:s=>ae(s.target.value),className:"pl-10"})]}),e.jsxs(F,{value:D,onValueChange:te,children:[e.jsx(I,{className:"w-40",children:e.jsx(T,{placeholder:"Status"})}),e.jsxs(q,{children:[e.jsx(n,{value:"all",children:"All Statuses"}),e.jsx(n,{value:"new",children:"New"}),e.jsx(n,{value:"contacted",children:"Contacted"}),e.jsx(n,{value:"responded",children:"Responded"}
13),e.jsx(n,{value:"qualified",children:"Qualified"}),e.jsx(n,{value:"unqualified",children:"Unqualified"}),e.jsx(n,{value:"converted",children:"Converted"})]})]}),e.jsxs(F,{value:M,onValueChange:le,children:[e.jsx(I,{className:"w-40",children:e.jsx(T,{placeholder:"Source"})}),e.jsxs(q,{children:[e.jsx(n,{value:"all",children:"All Sources"}),e.jsx(n,{value:"manual",children:"Manual"}),e.jsx(n,{value:"linkedin",children:"LinkedIn"}),e.jsx(n,{value:"csv_import",children:"CSV Import"}),e.jsx(n,{value:"web_form",children:"Web Form"}),e.jsx(n,{value:"api",children:"API"})]})]})]}),e.jsx("div",{className:"bg-white rounded-lg border overflow-hidden",children:re?e.jsx("div",{className:"p-8 text-center text-gray-500",children:"Loading prospects..."}):(b==null?void 0:b.length)===0?e.jsx("div",{className:"p-8 text-center text-gray-500",children:"No prospects found. Add your first prospect or import from CSV."}):e.jsxs(pe,{children:[e.jsx(fe,{children:e.jsxs(K,{children:[e.jsx(f,{children:"Contact"}),e.jsx(f,{children:"Company"}),e.jsx(f,{children:"Source"}),e.jsx(f,{children:"Status"}),e.jsx(f,{children:"Tags"}),e.jsx(f,{children:"Added"}),e.jsx(f,{className:"w-20",children:"Actions"})]})}),e.jsx(ye,{children:b==null?void 0:b.map(s=>{var l;return e.jsxs(K,{children:[e.jsx(y,{children:e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:s.first_name||s.last_name?`${s.first_name||""} ${s.last_name||""}`.trim():"—"}),e.jsxs("div",{className:"flex items-center gap-2 text-sm text-gray-500",children:[e.jsx(Y,{className:"w-3 h-3"}),s.email]}),s.phone&&e.jsxs("div",{className:"flex items-center gap-2 text-sm text-gray-500",children:[e.jsx(Ce,{className:"w-3 h-3"}),s.phone]})]})}),e.jsx(y,{children:e.jsxs("div",{children:[s.company&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Se,{className:"w-3 h-3 text-gray-400"}),s.company]}),s.job_title&&e.jsx("p",{className:"text-sm text-gray-500",children:s.job_title}),s.location&&e.jsxs("div",{className:"flex items-center gap-1 text-sm text-gray-500",children:[e.jsx(ge,{className:"w-3 h-3"}),s.location]})]})}),e.jsx(y,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[s.source==="linkedin"&&e.jsx(Pe,{className:"w-4 h-4 text-blue-600"}),e.jsx(L,{className:ee[s.source]||ee.manual,children:s.source})]})}),e.jsx(y,{children:e.jsx(L,{className:Z[s.status]||Z.new,children:s.status})}),e.jsx(y,{children:e.jsxs("div",{className:"flex flex-wrap gap-1",children:[(l=s.tags)==null?void 0:l.slice(0,3).map(d=>e.jsx(L,{variant:"outline",className:"text-xs",children:d},d)),s.tags&&s.tags.length>3&&e.jsxs(L,{variant:"outline",className:"text-xs",children:["+",s.tags.length-3]})]})}),e.jsx(y,{className:"text-sm text-gray-500",children:A(new Date(s.created_at),"MMM d, yyyy")}),e.jsx(y,{children:e.jsxs("div",{className:"flex gap-1",children:[e.jsx(p,{variant:"ghost",size:"icon",onClick:()=>oe(s),children:e.jsx(ke,{className:"w-4 h-4"})}),e.jsx(p,{variant:"ghost",size:"icon",onClick:()=>{confirm("Delete this prospect?")&&ce.mutate(s.id)},children:e.jsx(Le,{className:"w-4 h-4 text-red-500"})})]})})]},s.id)})})]})})]})}export{Ge 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.