1import{r as d,j as e,M as b,B as l,g as R,s as f,c as o}from"./index-ByvD1IAR-muv56m7z.js";import{C as m,a as x,b as h,d as u,c as _}from"./card-KGe14HLs-muv56m7z.js";import{T as k,a as B,b as y,c as r,d as A,e as n}from"./table-B8ywo-iv-muv56m7z.js";import{B as p}from"./badge-DKaxTyBt-muv56m7z.js";import{D as H,b as L,c as O,d as F,e as I}from"./dialog-CUt0qxMp-muv56m7z.js";import{A as $}from"./AttributionCell-CkWQQfzE-muv56m7z.js";import{L as q}from"./loader-circle-BtfdHYSM-muv56m7z.js";import{E as z}from"./eye-4li-ztvV-muv56m7z.js";import{T as V}from"./trash-2-NDf0wQIb-muv56m7z.js";import{f as g}from"./format-1L9mQgs2-muv56m7z.js";import"./index-as-r2l-E-muv56m7z.js";const se=()=>{const[i,w]=d.useState([]),[v,C]=d.useState(!0),[t,S]=d.useState(null),[D,c]=d.useState(!1),j=async()=>{try{const{data:s,error:a}=await f.from("contact_submissions").select("*").order("created_at",{ascending:!1});if(a)throw a;w(s||[])}catch(s){console.error("Error fetching submissions:",s),o.error("Failed to load contact submissions")}finally{C(!1)}};d.useEffect(()=>{j()},[]);const M=s=>{S(s),c(!0)},T=async s=>{try{const{error:a}=await f.from("contact_submissions").update({status:"responded",responded_at:new Date().toISOString()}).eq("id",s);if(a)throw a;o.success("Marked as responded"),j(),c(!1)}catch(a){console.error("Error updating submission:",a),o.error("Failed to update submission")}},E=async s=>{if(confirm("Are you sure you want to delete this submission?"))try{const{error:a}=await f.from("contact_submissions").delete().eq("id",s);if(a)throw a;o.success("Submission deleted"),j(),c(!1)}catch(a){console.error("Error deleting submission:",a),o.error("Failed to delete submission")}},N=s=>{switch(s){case"new":return e.jsx(p,{variant:"default",className:"bg-accent text-accent-foreground",children:"New"});case"responded":return e.jsx(p,{variant:"secondary",children:"Responded"});default:return e.jsx(p,{variant:"outline",children:s})}};return v?e.jsx("div",{className:"flex items-center justify-center h-64",children:e.jsx(q,{className:"h-8 w-8 animate-spin text-muted-foreground"})}):e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-3xl font-bold text-foreground",children:"Contact Submissions"}),e.jsx("p",{className:"text-muted-foreground mt-1",children:"View and manage contact form submissions"})]}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-3",children:[e.jsxs(m,{children:[e.jsx(x,{className:"pb-2",children:e.jsx(h,{className:"text-sm font-medium text-muted-foreground",children:"Total Submissions"})}),e.jsx(u,{children:e.jsx("p",{className:"text-2xl font-bold",children:i.length})})]}),e.jsxs(m,{children:[e.jsx(x,{className:"pb-2",children:e.jsx(h,{className:"text-sm font-medium text-muted-foreground",children:"New"})}),e.jsx(u,{children:e.jsx("p",{className:"text-2xl font-bold text-accent",children:i.filter(s=>s.status==="new").length})})]}),e.jsxs(m,{children:[e.jsx(x,{className:"pb-2",children:e.jsx(h,{className:"text-sm font-medium text-muted-foreground",children:"Responded"})}),e.jsx(u,{children:e.jsx("p",{className:"text-2xl font-bold text-muted-foreground",children:i.filter(s=>s.status==="responded").length})})]})]}),e.jsxs(m,{children:[e.jsxs(x,{children:[e.jsx(h,{children:"All Submissions"}),e.jsx(_,{children:"Click on a submission to view the full message"})]}),e.jsx(u,{children:i.length===0?e.jsxs("div",{className:"text-center py-12 text-muted-foreground",children:[e.jsx(b,{className:"h-12 w-12 mx-auto mb-4 opacity-50"}),e.jsx("p",{children:"No contact submissions yet"})]}):e.jsxs(k,{children:[e.jsx(B,{children:e.jsxs(y,{children:[e.jsx(r,{children:"Status"}),e.jsx(r,{children:"Name"}),e.jsx(r,{children:"Email"}),e.jsx(r,{children:"Country"}),e.jsx(r,{children:"Source"}),e.jsx(r,{children:"Date"}),e.jsx(r,{children:"Actions"})]})}),e.jsx(A,{children:i.map(s=>e.jsxs(y,{children:[e.jsx(n,{children:N(s.status)}),e.jsx(n,{className:"font-medium",children:s.name}),e.jsx(n,{children:s.email}),e.jsx(n,{children:s.country||e.jsx("span",{className:"text-muted-foreground",children:"â"})}),e.jsx(n,{children:e.jsx($,{data:s})}),e.jsx(n,{children:g(new Date(s.created_at),"MMM d, yyyy h:mm a")}),e.jsx(n,{children:e.jsxs("div",{className:"flex gap-2",children:[e.jsx(l,{variant:"ghost",size:"sm",onClick:()=>M(s),children:e.jsx(z,{className:"h-4 w-4"})}),e.jsx(l,{variant:"ghost",size:"sm",onClick:()=>E(s.id),className:"text-destructive hover:text-destructive",children:e.jsx(V,{className:"h-4 w-4"})})]})})]},s.id))})]})})]}),e.jsx(H,{open:D,onOpenChange:c,children:e.jsxs(L,{className:"max-w-lg",children:[e.jsxs(O,{children:[e.jsx(F,{children:"Contact Submission"}),e.jsxs(I,{children:["Received ",t&&g(new Date(t.created_at),"MMMM d, yyyy 'at' h:mm a")]})]}),t&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium text-muted-foreground",children:"Name"}),e.jsx("p",{className:"text-foreground",children:t.name})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium text-muted-foreground",children:"Email"}),e.jsx("a",{href:`mailto:${t.email}`,className:"text-accent hover:underline",children:t.email})]}),t.phone&&e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium text-muted-foreground",children:"Phone"}),e.jsx("a",{href:`tel:${t.phone}`,className:"text-accent hover:underline",children:t.phone})]}),t.country&&e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium text-muted-foreground",children:"Country"}),e.jsx("p",{className:"text-foreground",children:t.country})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium text-muted-foreground",children:"Message"}),e.jsx("p",{className:"text-foreground whitespace-pre-wrap",children:t.message})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium text-muted-foreground",children:"Status"}),N(t.status),t.responded_at&&e.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:["Responded on ",g(new Date(t.responded_at),"MMM d, yyyy")]})]}),e.jsxs("div",{className:"flex gap-2 pt-4",children:[t.status==="new"&&e.jsxs(l,{onClick:()=>T(t.id),className:"gap-2",children:[e.jsx(R,{className:"h-4 w-4"}),"Mark as Responded"]}),e.jsx(l,{variant:"outline",asChild:!0,children:e.jsxs("a",{href:`mailto:${t.email}`,children:[e.jsx(b,{className:"h-4 w-4 mr-2"}),"Reply via Email"]})})]})]})]})})]})};export{se 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.