1import{a as d,j as e}from"./vendor-react-6dZusYjs.js";import{A as q}from"./AdminLayout-BVakGVJG.js";import{T as $,a as B,b as x,c as m,d as R,e as l}from"./table-ClBrmjs6.js";import{B as g}from"./badge-9gqaM3ij.js";import{B as w}from"./button-Pc9UU9Kq.js";import{C as b}from"./checkbox-BIjoK_YI.js";import{S as M,a as U,b as V,c as _,d as S}from"./select-CK5HwC8G.js";import{y as F}from"./api-aIMl2mP_.js";import{b as O}from"./vendor-query-DG6KTijm.js";import{a3 as H,F as Q,a6 as P,a0 as G}from"./vendor-icons-BPjLpime.js";import"./vendor-frIWoMVD.js";import"./vendor-radix-SDBhz8M8.js";import"./index-zmOjOZHb.js";function J(h,n){const o=URL.createObjectURL(h),i=document.createElement("a");i.href=o,i.download=n,i.click(),URL.revokeObjectURL(o)}function oe(){const h=O(),[n,o]=d.useState(new Set),[i,j]=d.useState("all"),{data:c,isLoading:C}=F();async function v(s){if(!window.confirm("Delete this contact submission? This cannot be undone."))return;const a=localStorage.getItem("s2s_admin_token")??"";(await fetch(`/api/admin/contacts/${s}`,{method:"DELETE",headers:{Authorization:`Bearer ${a}`}})).ok&&h.invalidateQueries()}const f=localStorage.getItem("s2s_last_login"),p=f?new Date(f):null,N=s=>p?new Date(s)>p:!1,r=d.useMemo(()=>(c??[]).filter(s=>i==="all"||s.inquiryType===i),[c,i]),y=d.useMemo(()=>(c??[]).filter(s=>N(s.createdAt)).length,[c,p]),T=d.useMemo(()=>n.size>0?r.filter(s=>n.has(s.id)):r,[r,n]),k=d.useMemo(()=>[...new Set((c??[]).map(s=>s.inquiryType))],[c]),u=r.length>0&&r.every(s=>n.has(s.id)),L=r.some(s=>n.has(s.id)),E=()=>{o(u?s=>{const a=new Set(s);return r.forEach(t=>a.delete(t.id)),a}:s=>{const a=new Set(s);return r.forEach(t=>a.add(t.id)),a})},z=s=>o(a=>{const t=new Set(a);return t.has(s)?t.delete(s):t.add(s),t}),A=()=>{const s=["First Name","Last Name","Email","Phone","Company","Inquiry Type","Interests","Message","Date"],a=T.map(t=>[t.firstName,t.lastName,t.email,t.phone||"",t.company||"",t.inquiryType,t.interests||"",t.message,new Date(t.createdAt).toLocaleString()].map(I=>`"${String(I).replace(/"/g,'""')}"`).join(","));J(new Blob([[s.join(","),...a].join(` 2`)],{type:"text/csv"}),`contacts_${new Date().toISOString().slice(0,10)}.csv`)},D=n.size>0?`${n.size} selected`:`${r.length} total`;return e.jsxs(q,{children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-4 mb-6",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-3xl font-bold",children:"Contact Submissions"}),e.jsxs("div",{className:"text-muted-foreground mt-1 flex items-center gap-2",children:[D,y>0&&e.jsxs(g,{className:"bg-primary/10 text-primary border-primary/20 text-xs gap-1",children:[e.jsx(H,{className:"w-3 h-3"})," ",y," new"]})]})]}),e.jsxs(w,{variant:"outline",size:"sm",className:"gap-1.5",onClick:A,children:[e.jsx(Q,{className:"w-4 h-4"})," ",n.size>0?`Export CSV (${n.size})`:"Export CSV"]})]}),e.jsxs("div",{className:"flex gap-3 mb-4",children:[e.jsxs(M,{value:i,onValueChange:j,children:[e.jsx(U,{className:"w-48 h-9",children:e.jsx(V,{placeholder:"All Types"})}),e.jsxs(_,{children:[e.jsx(S,{value:"all",children:"All Inquiry Types"}),k.map(s=>e.jsx(S,{value:s,className:"capitalize",children:s},s))]})]}),(i!=="all"||n.size>0)&&e.jsx(w,{variant:"ghost",size:"sm",className:"text-xs h-9 text-muted-foreground",onClick:()=>{j("all"),o(new Set)},children:"Clear"})]}),e.jsx("div",{className:"bg-card rounded-lg border border-border overflow-hidden",children:e.jsxs($,{children:[e.jsx(B,{children:e.jsxs(x,{children:[e.jsx(m,{className:"w-10 pl-4",children:e.jsx(b,{checked:u,"data-state":L&&!u?"indeterminate":void 0,onCheckedChange:E})}),e.jsx(m,{children:"Name & Email"}),e.jsx(m,{children:"Inquiry Type"}),e.jsx(m,{children:"Company"}),e.jsx(m,{children:"Message"}),e.jsx(m,{className:"text-right",children:"Date"})]})}),e.jsx(R,{children:C?e.jsx(x,{children:e.jsx(l,{colSpan:6,className:"text-center py-8",children:"Loading..."})}):r.length===0?e.jsx(x,{children:e.jsx(l,{colSpan:6,className:"text-center py-8 text-muted-foreground",children:"No contact submissions found."})}):r.map(s=>{const a=n.has(s.id),t=N(s.createdAt);return e.jsxs(x,{className:`${a?"bg-primary/5":""} transition-colors`,children:[e.jsx(l,{className:"pl-4",children:e.jsx(b,{checked:a,onCheckedChange:()=>z(s.id)})}),e.jsxs(l,{className:"font-medium align-top",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[s.firstName," ",s.lastName,t&&e.jsx(g,{className:"text-xs bg-primary/10 text-primary border-primary/20 py-0",children:"New"})]}),e.jsx("div",{className:"text-sm font-normal text-muted-foreground",children:s.email}),s.phone&&e.jsx("div",{className:"text-sm font-normal text-muted-foreground",children:s.phone}),e.jsxs("a",{href:`/admin/people/${encodeURIComponent(s.email)}`,className:"inline-flex items-center gap-1 text-xs text-muted-foreground hover:text-primary transition-colors mt-1",children:[e.jsx(P,{className:"w-3 h-3"})," View profile"]})]}),e.jsx(l,{className:"align-top",children:e.jsx(g,{variant:"outline",className:"capitalize",children:s.inquiryType})}),e.jsx(l,{className:"align-top text-muted-foreground",children:s.company||"â"}),e.jsxs(l,{className:"align-top max-w-md",children:[s.interests&&e.jsxs("p",{className:"text-xs font-medium text-primary mb-1.5",children:["Interest: ",s.interests]}),e.jsx("p",{className:"text-sm whitespace-pre-wrap text-muted-foreground",children:s.message})]}
2),e.jsx(l,{className:"text-right align-top whitespace-nowrap text-sm text-muted-foreground",children:e.jsxs("div",{className:"flex items-center justify-end gap-2",children:[e.jsx("span",{children:new Date(s.createdAt).toLocaleString()}),e.jsx("button",{onClick:()=>v(s.id),className:"p-1 rounded text-muted-foreground hover:text-destructive transition-colors",title:"Delete",children:e.jsx(G,{className:"w-3.5 h-3.5"})})]})})]},s.id)})})]})})]})}export{oe 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.