PageSourceSearch

https://jpmarquez.com/assets/Contacts-r2-CfR8s9tX.js

js jpmarquez.com collected 2026-10-03 20:09:08 UTC 27,062 bytes, 6 lines download raw bytes

1import{j as e}from"./vendor-query-r2-B0UDiO8U.js";import{r as d,bl as we,aB as he,X as pe,aA as me,an as xe,y as Ce,a2 as be,aS as Se,U as ue,a0 as ke,D as _e,T as Te,x as Me,bm as De,aP as Ae,ac as Ee,k as ze}from"./vendor-icons2-r2-sw8q4CDx.js";import{u as je,B as o,C as j,v as _,w as T,l as v,L as u,n as E}from"./index-r2-B7qKR5Il.js";import{B as z}from"./badge-r2-6XmqamZK.js";import{I as p}from"./input-r2-DijPJHce.js";import{C as ge}from"./checkbox-r2-a6UNIhyI.js";import{S as P,a as L,b as R,c as F,d as n}from"./select-r2-BygpErD5.js";import{D as ve,a as fe,c as Ne,b as ye,e as Pe}from"./dialog-r2-DQxjxTNe.js";import{T as ee}from"./textarea-r2-DT7SCfdl.js";import{s as c}from"./client-r2-lkUhMl-9.js";import{C as Le}from"./CrmMovedNotice-r2-e4j5-Rqs.js";import{T as Re,a as Fe,b as Y,c as Z}from"./tabs-r2-DFHy5gom.js";import"./vendor-react2-r2-DThrtG6L.js";import"./vendor-charts2-r2-P9hqzVnm.js";import"./index-r2-D17hSi50.js";import"./index-r2-B-mxye2n.js";import"./index-r2-DTfvhMp8.js";import"./index-r2-CY0nVKvZ.js";import"./crm-r2-DF5A0RmD.js";import"./index-r2-DKPSiOWQ.js";function Be({contact:l,open:se,onOpenChange:w,onUpdate:W}
1){const[h,V]=d.useState(!1),[r,N]=d.useState(l),[M,te]=d.useState([]),[A,H]=d.useState(""),[x,k]=d.useState([]),[I,C]=d.useState(""),[$,B]=d.useState([]),[q,J]=d.useState([]),[m,D]=d.useState({title:"",description:"",due_date:"",priority:"medium"}),{toast:i}=je();d.useEffect(()=>{l!=null&&l.id&&(g(),S(),O(),ae(),b())},[l==null?void 0:l.id]);const b=async()=>{l.status==="new"&&await c.from("contact_submissions").update({status:"read"}).eq("id",l.id)},g=async()=>{const{data:t}=await c.from("contact_notes").select("*").eq("contact_id",l.id).order("created_at",{ascending:!1});te(t||[])},S=async()=>{const{data:t}=await c.from("contact_tags").select("*").eq("contact_id",l.id);k(t||[])},O=async()=>{const{data:t}=await c.from("contact_tasks").select("*").eq("contact_id",l.id).order("due_date",{ascending:!0});B(t||[])},ae=async()=>{const{data:t}=await c.from("contact_activities").select("*").eq("contact_id",l.id).order("created_at",{ascending:!1}).limit(20);J(t||[])},ie=async()=>{const{error:t}=await c.from("contact_submissions").update({name:r.name,email:r.email,phone:r.phone,company:r.company,message:r.message,status:r.status,priority:r.priority,lead_score:r.lead_score,source:r.source}).eq("id",l.id);if(t){i({title:"Error updating contact",description:t.message,variant:"destructive"});return}i({title:"Contact updated",description:"Contact information has been saved"}),V(!1),W()},K=async()=>{if(!confirm("Are you sure you want to delete this contact?"))return;const{error:t}=await c.from("contact_submissions").update({deleted_at:new Date().toISOString()}).eq("id",l.id);if(t){i({title:"Error deleting contact",description:t.message,variant:"destructive"});return}i({title:"Contact deleted",description:"Contact has been moved to trash"}),w(!1),W()},X=async()=>{var s;if(!A.trim())return;const{error:t}=await c.from("contact_notes").insert({contact_id:l.id,note:A,user_id:(s=(await c.auth.getUser()).data.user)==null?void 0:s.id});if(t){i({title:"Error adding note",description:t.message,variant:"destructive"});return}H(""),g(),i({title:"Note added"})},re=async t=>{const{error:s}=await c.from("contact_notes").delete().eq("id",t);if(s){i({title:"Error deleting note",description:s.message,variant:"destructive"});return}g(),i({title:"Note deleted"})},G=async()=>{if(!I.trim())return;const t=["#3b82f6","#10b981","#f59e0b","#ef4444","#8b5cf6","#ec4899"],s=t[Math.floor(Math.random()*t.length)],{error:a}=await c.from("contact_tags").insert({contact_id:l.id,tag:I,color:s});if(a){i({title:"Error adding tag",description:a.message,variant:"destructive"});return}C(""),S(),i({title:"Tag added"})},le=async t=>{const{error:s}=await c.from("contact_tags").delete().eq("id",t);if(s){i({title:"Error deleting tag",description:s.message,variant:"destructive"});return}S(),i({title:"Tag removed"})},ne=async()=>{var s;if(!m.title.trim()||!m.due_date){i({title:"Missing information",description:"Please provide task title and due date",variant:"destructive"});return}const{error:t}=await c.from("contact_tasks").insert({contact_id:l.id,title:m.title,description:m.description,due_date:m.due_date,priority:m.priority,assigned_to:(s=(await c.auth.getUser()).data.user)==null?void 0:s.id});if(t){i({title:"Error creating task",description:t.message,variant:"destructive"});return}D({title:"",description:"",due_date:"",priority:"medium"}),O(),i({title:"Task created"})},de=async t=>{const{error:s}=await c.from("contact_tasks").update({status:"completed",completed_at:new Date().toISOString()}).eq("id",t);if(s){i({title:"Error completing task",description:s.message,variant:"destructive"});return}O(),i({title:"Task completed"})},ce=t=>{const s={urgent:{className:"bg-destructive text-destructive-foreground",label:"Urgent"},high:{className:"bg-orange-500 text-white",label:"High"},medium:{className:"bg-primary text-primary-foreground",label:"Medium"},low:{className:"bg-muted text-muted-foreground",label:"Low"}},a=s[t]||s.medium;return e.jsx(z,{className:a.className,children:a.label})};return e.jsx(ve,{open:se,onOpenChange:w,children:e.jsxs(fe,{className:"max-w-4xl max-h-[90vh] overflow-y-auto",children:[e.jsx(Ne,{children:e.jsxs(ye,{className:"flex items-center justify-between",children:[e.jsx("span",{children:"Contact Details"}),e.jsx("div",{className:"flex gap-2",children:h?e.jsxs(e.Fragment,{children:[e.jsxs(o,{onClick:ie,size:"sm",children:[e.jsx(we,{className:"h-4 w-4 mr-1"}),"Save"]}),e.jsx(o,{onClick:()=>{V(!1),N(l)},variant:"outline",size:"sm",children:"Cancel"})]}):e.jsxs(e.Fragment,{children:[e.jsx(o,{onClick:()=>V(!0),size:"sm",children:"Edit"}),e.jsx(o,{onClick:K,variant:"destructive",size:"sm",children:e.jsx(he,{className:"h-4 w-4"})})]})})]})}),e.jsxs(Re,{defaultValue:"details",className:"w-full",children:[e.jsxs(Fe,{className:"grid w-full grid-cols-4",children:[e.jsx(Y,{value:"details",children:"Details"}),e.jsxs(Y,{value:"notes",children:["Notes (",M.length,")"]}),e.jsxs(Y,{value:"tasks",children:["Tasks (",$.filter(t=>t.status!=="completed").length,")"]}),e.jsx(Y,{value:"activity",children:"Activity"})]}),e.jsxs(Z,{value:"details",className:"space-y-4",children:[e.jsxs(j,{children:[e.jsx(_,{children:e.jsx(T,{className:"text-lg",children:"Contact Information"})}),e.jsxs(v,{className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(u,{children:"Name"}),e.jsx(p,{value:r.name,onChange:t=>N({...r,name:t.target.value}),disabled:!h})]}),e.jsxs("div",{children:[e.jsx(u,{children:"Email"}),e.jsx(p,{value:r.email,onChange:t=>N({...r,email:t.target.value}),disabled:!h})]}),e.jsxs("div",{children:[e.jsx(u,{children:"Phone"}),e.jsx(p,{value:r.phone||"",onChange:t=>N({...r,phone:t.target.value}),disabled:!h,placeholder:"Not provided"})]}),e.jsxs("div",{children:[e.jsx(u,{children:"Company"}),e.jsx(p,{value:r.company||"",onChange:t=>N({...r,company:t.target.value}),disabled:!h,placeholder:"Not provided"})]}),e.jsxs("div",{children:[e.jsx(u,{children:"Status"}),e.jsxs(P,{value:r.status,onValueChange:t=>N({...r,status:t}),disabled:!h,children:[e.jsx(L,{children:e.jsx(R,{})}),e.jsxs(F,{children:[e.jsx(n,{value:"new",children:"New"}),e.jsx(n,{value:"read",children:"Read"}),e.jsx(n,{value:"replied",children:"Replied"})]})]})]}),e.jsxs("div",{children:[e.jsx(u,{children:"Priority"}),e.jsxs(P,{value:r.priority||"medium",onValueChange:t=>N({...r,priority:t}),disabled:!h,children:[e.jsx(L,{children:e.jsx(R,{})}),e.jsxs(F,{children:[e.jsx(n,{value:"low",children:"Low"}),e.jsx(n,{value:"medium",children:"Medium"}),e.jsx(n,{value:"high",children:"High"}),e.jsx(n,{value:"urgent",children:"Urgent"})]})]})]}),e.jsxs("div",{children:[e.jsx(u,{children:"Lead Score (0-100)"}),e.jsx(p,{type:"number",min:"0",max:"100",value:r.lead_score||0,onChange:t=>N({...r,lead_score:parseInt(t.target.value)}),disabled:!h})]}),e.jsxs("div",{children:[e.jsx(u,{children:"Source"}),e.jsx(p,{value:r.source||"",onChange:t=>N({...r,source:t.target.value}),disabled:!h,placeholder:"e.g., Website, Referral"})]})]}),e.jsxs("div",{children:[e.jsx(u,{children:"Message"}),e.jsx(ee,{value:r.message,onChange:t=>N({...r,message:t.target.value}),disabled:!h,rows:4})]})]})]}),e.jsxs(j,{children:[e.jsx(_,{children:e.jsx(T,{className:"text-lg",children:"Tags"})}),e.jsxs(v,{children:[e.jsx("div",{className:"flex flex-wrap gap-2 mb-4",children:x.map(t=>e.jsxs(z,{style:{backgroundColor:`${t.color}20`,borderColor:t.color},className:"flex items-center gap-1",children:[t.tag,e.jsx(pe,{className:"h-3 w-3 cursor-pointer",onClick:()=>le(t.id)})]},t.id))}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(p,{placeholder:"Add new tag...",value:I,onChange:t=>C(t.target.value),onKeyDown:t=>t.key==="Enter"&&G()}),e.jsx(o,{onClick:G,size:"sm",children:e.jsx(me,{className:"h-4 w-4"})})]})]})]})]}),e.jsxs(Z,{value:"notes",className:"space-y-4",children:[e.jsxs(j,{children:[e.jsx(_,{children:e.jsx(T,{className:"text-lg",children:"Add Note"})}),e.jsxs(v,{className:"space-y-4",children:[e.jsx(ee,{placeholder:"Write a note about this contact...",value:A,onChange:t=>H(t.target.value),rows:3}),e.jsxs(o,{onClick:X,children:[e.jsx(me,{className:"h-4 w-4 mr-2"}),"Add Note"]})]})]}),e.jsxs("div",{className:"space-y-3",children:[M.map(t=>e.jsx(j,{children:e.jsx(v,{className:"pt-4",children:e.jsxs("div",{className:"flex justify-between items-start",children:[e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"text-sm whitespace-pre-wrap",children:t.note}),e.jsx("p",{className:"text-xs text-muted-foreground mt-2",children:E(new Date(t.created_at),"MMM dd, yyyy 'at' h:mm a")})]}),e.jsx(o,{variant:"ghost",size:"sm",onClick:()=>re(t.id),children:e.jsx(he,{className:"h-4 w-4"})})]})})},t.id)),M.length===0&&e.jsx("p",{className:"text-center text-muted-foreground py-8",children:"No notes yet. Add your first note above."})]})]}),e.jsxs(Z,{value:"tasks",className:"space-y-4",children:[e.jsxs(j,{children:[e.jsx(_,{children:e.jsx(T,{className:"text-lg",children:"Create Task"})}),e.jsxs(v,{className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsx(p,{placeholder:"Task title",value:m.title,onChange:t=>D({...m,title:t.target.value})}),e.jsxs(P,{value:m.priority,onValueChange:t=>D({...m,priority:t}),children:[e.jsx(L,{children:e.jsx(R,{})}),e.jsxs(F,{children:[e.jsx(n,{value:"low",children:"Low Priority"}),e.jsx(n,{value:"medium",children:"Medium Priority"}),e.jsx(n,{value:"high",children:"High Priority"}),e.jsx(n,{value:"urgent",children:"Urgent"})]})]})]}),e.jsx(p,{type:"datetime-local",value:m.due_date,onChange:t=>D({...m,due_date:t.target.value})}),e.jsx(ee,{placeholder:"Task description (optional)",value:m.description,onChange:t=>D({...m,description:t.target.value}),rows:2}),e.jsxs(o,{onClick:ne,children:[e.jsx(me,{className:"h-4 w-4 mr-2"}),"Create Task"]})]})]}),e.jsxs("div",{className:"space-y-3",children:[$.map(t=>e.jsx(j,{children:e.jsx(v,{className:"pt-4",children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx("h4",{className:"font-medium",children:t.title}),ce(t.priority),t.status==="completed"&&e.jsxs(z,{variant:"outline",className:"bg-green-50",children:[e.jsx(xe,{className:"h-3 w-3 mr-1"}),"Completed"]})]}),t.description&&e.jsx("p",{className:"text-sm text-muted-foreground mb-2",children:t.description}),e.jsxs("div",{className:"flex items-center gap-4 text-xs text-muted-foreground",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Ce,{className:"h-3 w-3"}),"Due: ",E(new Date(t.due_date),"MMM dd, yyyy")]}),t.completed_at&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(be,{className:"h-3 w-3"}),"Completed:"," ",E(new Date(t.completed_at),"MMM dd, yyyy")]})]})]}),t.status!=="completed"&&e.jsxs(o,{variant:"outline",size:"sm",onClick:()=>de(t.id),children:[e.jsx(xe,{className:"h-4 w-4 mr-1"}),"Complete"]})]})})},t.id)),$.length===0&&e.jsx("p",{className:"text-center text-muted-foreground py-8",children:"No tasks yet. Create your first task above."})]})]}),e.jsxs(Z,{value:"activity",className:"space-y-3",children:[q.map(t=>e.jsx(j,{children:e.jsx(v,{className:"pt-4",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(Se,{className:"h-4 w-4 mt-1 text-muted-foreground"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"text-sm font-medium",children:t.description}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:E(new Date(t.created_at),"MMM dd, yyyy 'at' h:mm a")})]})]})})},t.id)),q.length===0&&e.jsx("p",{className:"text-center text-muted-foreground py-8",children:"No activity recorded yet."})]})]})]})})}function ls(){return e.jsx(Le,{section:"Contacts",children:e.jsx(Ue,{})})}function Ue(){const[l,se]=d.useState([]),[w,W]=d.useState([]),[h,V]=d.use
1State(""),[r,N]=d.useState("all"),[M,te]=d.useState("all"),[A,H]=d.useState(null),[x,k]=d.useState(new Set),[I,C]=d.useState(!1),[$,B]=d.useState(!1),[q,J]=d.useState(!1),[m,D]=d.useState(!1),[i,b]=d.useState({name:"",email:"",phone:"",company:"",message:"",status:"new",priority:"medium",source:"manual"}),{toast:g}=je();d.useEffect(()=>{S()},[]),d.useEffect(()=>{O()},[l,h,r,M]);const S=async()=>{const{data:s,error:a}=await c.from("contact_submissions").select(`
2        *,
3        tags:contact_tags(id, tag, color),
4        tasks:contact_tasks(id, status, due_date)
5      `).is("deleted_at",null).order("created_at",{ascending:!1});if(a){g({title:"Error fetching contacts",description:a.message,variant:"destructive"});return}se(s||[])},O=()=>{let s=l;h&&(s=s.filter(a=>{var f;return a.name.toLowerCase().includes(h.toLowerCase())||a.email.toLowerCase().includes(h.toLowerCase())||((f=a.company)==null?void 0:f.toLowerCase().includes(h.toLowerCase()))})),r!=="all"&&(s=s.filter(a=>a.status===r)),M!=="all"&&(s=s.filter(a=>a.priority===M)),W(s)},ae=s=>{H(s)},ie=async()=>{if(x.size===0)return;const{error:s}=await c.from("contact_submissions").update({deleted_at:new Date().toISOString()}).in("id",Array.from(x));if(s){g({title:"Error deleting contacts",description:s.message,variant:"destructive"});return}g({title:"Contacts deleted",description:`${x.size} contact(s) moved to trash`}),k(new Set),C(!1),S()},K=async s=>{if(x.size===0)return;const{error:a}=await c.from("contact_submissions").update({status:s}).in("id",Array.from(x));if(a){g({title:"Error updating status",description:a.message,variant:"destructive"});return}g({title:"Status updated",description:`${x.size} contact(s) status changed to ${s}`}),k(new Set),C(!1),S()},X=async s=>{if(x.size===0)return;const{error:a}=await c.from("contact_submissions").update({priority:s}).in("id",Array.from(x));if(a){g({title:"Error updating priority",description:a.message,variant:"destructive"});return}g({title:"Priority updated",description:`${x.size} contact(s) priority changed to ${s}`}),k(new Set),C(!1),S()},re=()=>{const s=["Name","Email","Phone","Company","Status","Priority","Lead Score","Source","Created Date","Message"],a=w.map(y=>[y.name,y.email,y.phone||"",y.company||"",y.status,y.priority||"",y.lead_score||"",y.source||"",E(new Date(y.created_at),"yyyy-MM-dd HH:mm"),`"${y.message.replace(/"/g,'""')}"`]),f=[s,...a].map(y=>y.join(",")).join(`
6`),Q=new Blob([f],{type:"text/csv"}),U=window.URL.createObjectURL(Q),oe=document.createElement("a");oe.href=U,oe.download=`contacts-${E(new Date,"yyyy-MM-dd")}.csv`,oe.click(),g({title:"Export complete",description:`${w.length} contacts exported to CSV`})},G=async()=>{if(!i.name.trim()||!i.email.trim()){g({title:"Name and email are required",variant:"destructive"});return}J(!0);try{const{data:s,error:a}=await c.from("contact_submissions").insert([{name:i.name.trim(),email:i.email.trim().toLowerCase(),phone:i.phone.trim()||null,company:i.company.trim()||null,message:i.message.trim()||"Added manually",status:i.status,priority:i.priority,source:"manual"}]).select().single();if(a)throw a;m&&s&&await c.functions.invoke("send-welcome-email",{body:{subscriberId:s.id,email:s.email}}),g({title:"Contact added",description:`${i.name} has been added${m?" and a welcome email was sent":""}.`}),B(!1),b({name:"",email:"",phone:"",company:"",message:"",status:"new",priority:"medium",source:"manual"}),D(!1),S()}catch(s){g({title:"Failed to add contact",description:s.message,variant:"destructive"})}finally{J(!1)}},le=s=>{const a=new Set(x);a.has(s)?a.delete(s):a.add(s),k(a),C(a.size>0)},ne=()=>{x.size===w.length?(k(new Set),C(!1)):(k(new Set(w.map(s=>s.id))),C(!0))},de=s=>{const f={urgent:{className:"bg-destructive text-destructive-foreground",label:"Urgent"},high:{className:"bg-orange-500 text-white",label:"High"},medium:{className:"bg-primary text-primary-foreground",label:"Medium"},low:{className:"bg-muted text-muted-foreground",label:"Low"}}[s||"medium"];return e.jsx(z,{className:f.className,children:f.label})},ce=s=>{const a={new:{variant:"default",label:"New"},read:{variant:"secondary",label:"Read"},replied:{variant:"outline",label:"Replied"}},f=a[s]||a.new;return e.jsx(z,{variant:f.variant,children:f.label})},t={total:l.length,new:l.filter(s=>s.status==="new").length,read:l.filter(s=>s.status==="read").length,replied:l.filter(s=>s.status==="replied").length,urgent:l.filter(s=>s.priority==="urgent").length};return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-3xl font-bold",children:"Contact Management"}),e.jsx("p",{className:"text-muted-foreground mt-2",children:"Manage and track all contact submissions with CRM capabilities"})]}),e.jsxs(o,{onClick:()=>B(!0),className:"shrink-0",children:[e.jsx(ue,{className:"h-4 w-4 mr-2"}),"New Contact"]})]}
6),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-5 gap-4",children:[e.jsxs(j,{children:[e.jsx(_,{className:"pb-2",children:e.jsx(T,{className:"text-sm font-medium text-muted-foreground",children:"Total Contacts"})}),e.jsx(v,{children:e.jsx("div",{className:"text-2xl font-bold",children:t.total})})]}),e.jsxs(j,{children:[e.jsx(_,{className:"pb-2",children:e.jsx(T,{className:"text-sm font-medium text-muted-foreground",children:"New"})}),e.jsx(v,{children:e.jsx("div",{className:"text-2xl font-bold text-primary",children:t.new})})]}),e.jsxs(j,{children:[e.jsx(_,{className:"pb-2",children:e.jsx(T,{className:"text-sm font-medium text-muted-foreground",children:"Read"})}),e.jsx(v,{children:e.jsx("div",{className:"text-2xl font-bold",children:t.read})})]}),e.jsxs(j,{children:[e.jsx(_,{className:"pb-2",children:e.jsx(T,{className:"text-sm font-medium text-muted-foreground",children:"Replied"})}),e.jsx(v,{children:e.jsx("div",{className:"text-2xl font-bold",children:t.replied})})]}),e.jsxs(j,{children:[e.jsx(_,{className:"pb-2",children:e.jsx(T,{className:"text-sm font-medium text-muted-foreground",children:"Urgent"})}),e.jsx(v,{children:e.jsx("div",{className:"text-2xl font-bold text-destructive",children:t.urgent})})]})]}),e.jsx(j,{children:e.jsxs(v,{className:"pt-6",children:[e.jsxs("div",{className:"flex flex-col lg:flex-row gap-4",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(ke,{className:"absolute left-3 top-3 h-4 w-4 text-muted-foreground"}),e.jsx(p,{placeholder:"Search by name, email, or company...",value:h,onChange:s=>V(s.target.value),className:"pl-9"})]}),e.jsxs(P,{value:r,onValueChange:N,children:[e.jsx(L,{className:"w-full lg:w-[180px]",children:e.jsx(R,{placeholder:"Status"})}),e.jsxs(F,{children:[e.jsx(n,{value:"all",children:"All Status"}),e.jsx(n,{value:"new",children:"New"}),e.jsx(n,{value:"read",children:"Read"}),e.jsx(n,{value:"replied",children:"Replied"})]})]}),e.jsxs(P,{value:M,onValueChange:te,children:[e.jsx(L,{className:"w-full lg:w-[180px]",children:e.jsx(R,{placeholder:"Priority"})}),e.jsxs(F,{children:[e.jsx(n,{value:"all",children:"All Priority"}),e.jsx(n,{value:"urgent",children:"Urgent"}),e.jsx(n,{value:"high",children:"High"}),e.jsx(n,{value:"medium",children:"Medium"}),e.jsx(n,{value:"low",children:"Low"})]})]}),e.jsxs(o,{onClick:re,variant:"outline",children:[e.jsx(_e,{className:"h-4 w-4 mr-2"}),"Export CSV"]})]}),I&&e.jsx("div",{className:"mt-4 p-4 bg-primary/10 rounded-lg border border-primary/20",children:e.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[e.jsxs("span",{className:"text-sm font-medium",children:[x.size," selected"]}),e.jsx(o,{size:"sm",variant:"outline",onClick:()=>K("read"),children:"Mark as Read"}),e.jsx(o,{size:"sm",variant:"outline",onClick:()=>K("replied"),children:"Mark as Replied"}),e.jsxs(o,{size:"sm",variant:"outline",onClick:()=>X("urgent"),children:[e.jsx(Te,{className:"h-4 w-4 mr-1"}),"Set Urgent"]}),e.jsx(o,{size:"sm",variant:"outline",onClick:()=>X("high"),children:"Set High Priority"}),e.jsxs(o,{size:"sm",variant:"destructive",onClick:ie,children:[e.jsx(he,{className:"h-4 w-4 mr-1"}),"Delete"]}),e.jsxs(o,{size:"sm",variant:"ghost",onClick:()=>{k(new Set),C(!1)},children:[e.jsx(pe,{className:"h-4 w-4 mr-1"}),"Cancel"]})]})})]})}),e.jsx(j,{children:e.jsx(v,{className:"pt-6",children:w.length===0?e.jsx("div",{className:"text-center py-12",children:e.jsx("p",{className:"text-muted-foreground",children:"No contacts found"})}):e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-4 pb-3 border-b font-medium text-sm",children:[e.jsx(ge,{checked:x.size===w.length&&w.length>0,onCheckedChange:ne}),e.jsx("div",{className:"flex-1 min-w-[200px]",children:"Contact"}),e.jsx("div",{className:"w-[100px] hidden lg:block",children:"Status"}),e.jsx("div",{className:"w-[100px] hidden lg:block",children:"Priority"}),e.jsx("div",{className:"w-[80px] hidden xl:block text-center",children:"Score"}),e.jsx("div",{className:"w-[120px] hidden xl:block",children:"Tags"}),e.jsx("div",{className:"w-[100px]",children:"Actions"})]}),w.map(s=>{var a,f,Q;return e.jsxs("div",{className:"flex items-center gap-4 py-3 border-b hover:bg-muted/50 transition-colors",children:[e.jsx(ge,{checked:x.has(s.id),onCheckedChange:()=>le(s.id)}),e.jsxs("div",{className:"flex-1 min-w-[200px]",children:[e.jsx("div",{className:"font-medium",children:s.name}),e.jsxs("div",{className:"text-sm text-muted-foreground flex items-center gap-2 mt-1",children:[e.jsx(Me,{className:"h-3 w-3"}),s.email]}),s.phone&&e.jsxs("div",{className:"text-sm text-muted-foreground flex items-center gap-2 mt-1",children:[e.jsx(De,{className:"h-3 w-3"}),s.phone]}),s.company&&e.jsxs("div",{className:"text-sm text-muted-foreground flex items-center gap-2 mt-1",children:[e.jsx(Ae,{className:"h-3 w-3"}),s.company]}),e.jsx("div",{className:"text-xs text-muted-foreground mt-1",children:E(new Date(s.created_at),"MMM dd, yyyy")})]}),e.jsx("div",{className:"w-[100px] hidden lg:block",children:ce(s.status)}),e.jsx("div",{className:"w-[100px] hidden lg:block",children:de(s.priority)}),e.jsx("div",{className:"w-[80px] hidden xl:block text-center",children:e.jsx("div",{className:"text-lg font-bold text-primary",children:s.lead_score||0})}),e.jsxs("div",{className:"w-[120px] hidden xl:flex gap-1 flex-wrap",children:[(a=s.tags)==null?void 0:a.slice(0,2).map(U=>e.jsx(z,{variant:"outline",style:{backgroundColor:`${U.color}20`,borderColor:U.color},className:"text-xs",children:U.tag},U.id)),(((f=s.tags)==null?void 0:f.length)||0)>2&&e.jsxs(z,{variant:"secondary",className:"text-xs",children:["+",(((Q=s.tags)==null?void 0:Q.length)||0)-2]})]}),e.jsx("div",{className:"w-[100px]",children:e.jsxs(o,{variant:"outline",size:"sm",onClick:()=>ae(s),children:[e.jsx(Ee,{className:"h-4 w-4 mr-1"}),"View"]}
6)})]},s.id)})]})})}),A&&e.jsx(Be,{contact:A,open:!!A,onOpenChange:s=>{s||H(null)},onUpdate:S}),e.jsx(ve,{open:$,onOpenChange:B,children:e.jsxs(fe,{className:"max-w-lg",children:[e.jsx(Ne,{children:e.jsxs(ye,{className:"flex items-center gap-2",children:[e.jsx(ue,{className:"h-5 w-5"}),"New Contact"]})}),e.jsxs("div",{className:"space-y-4 py-2",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs(u,{htmlFor:"nc-name",children:["Name ",e.jsx("span",{className:"text-destructive",children:"*"})]}),e.jsx(p,{id:"nc-name",placeholder:"John Doe",value:i.name,onChange:s=>b(a=>({...a,name:s.target.value}))})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsxs(u,{htmlFor:"nc-email",children:["Email ",e.jsx("span",{className:"text-destructive",children:"*"})]}),e.jsx(p,{id:"nc-email",type:"email",placeholder:"[email protected]",value:i.email,onChange:s=>b(a=>({...a,email:s.target.value}))})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(u,{htmlFor:"nc-phone",children:"Phone"}),e.jsx(p,{id:"nc-phone",placeholder:"+34 600 000 000",value:i.phone,onChange:s=>b(a=>({...a,phone:s.target.value}))})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(u,{htmlFor:"nc-company",children:"Company"}),e.jsx(p,{id:"nc-company",placeholder:"Acme Corp",value:i.company,onChange:s=>b(a=>({...a,company:s.target.value}))})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(u,{children:"Status"}),e.jsxs(P,{value:i.status,onValueChange:s=>b(a=>({...a,status:s})),children:[e.jsx(L,{children:e.jsx(R,{})}),e.jsxs(F,{children:[e.jsx(n,{value:"new",children:"New"}),e.jsx(n,{value:"read",children:"Read"}),e.jsx(n,{value:"replied",children:"Replied"})]})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(u,{children:"Priority"}),e.jsxs(P,{value:i.priority,onValueChange:s=>b(a=>({...a,priority:s})),children:[e.jsx(L,{children:e.jsx(R,{})}),e.jsxs(F,{children:[e.jsx(n,{value:"urgent",children:"Urgent"}),e.jsx(n,{value:"high",children:"High"}),e.jsx(n,{value:"medium",children:"Medium"}),e.jsx(n,{value:"low",children:"Low"})]})]})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(u,{htmlFor:"nc-message",children:"Notes / Message"}),e.jsx(ee,{id:"nc-message",placeholder:"How did you meet? What are they interested in?",rows:3,value:i.message,onChange:s=>b(a=>({...a,message:s.target.value}))})]}),e.jsxs("div",{className:"flex items-center gap-3 rounded-lg border border-border bg-muted/30 p-3",children:[e.jsx("input",{type:"checkbox",id:"nc-welcome",checked:m,onChange:s=>D(s.target.checked),className:"h-4 w-4 rounded border-border"}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"nc-welcome",className:"text-sm font-medium cursor-pointer",children:"Send welcome email"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Trigger the welcome email flow via Edge Function"})]}),e.jsx(ze,{className:"h-4 w-4 text-muted-foreground ml-auto"})]})]}),e.jsxs(Pe,{children:[e.jsx(o,{variant:"outline",onClick:()=>B(!1),children:"Cancel"}),e.jsx(o,{onClick:G,disabled:q,children:q?"Adding…":"Add Contact"})]})]})})]})}export{ls 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.