PageSourceSearch

https://delphigrc.org/assets/AdminContactSubmissions-aociYqjQ.js

js delphigrc.org collected 2026-09-25 20:49:00 UTC 6,645 bytes, 1 lines download raw bytes

1import{r as s,j as e}from"./vendor-react-BH6F5oQJ.js";import{s as a,F as t,H as n,f as i}from"./index-C_oSc_qP.js";import{A as r}from"./AdminLayout-DnnQLcVN.js";import{u as o,a as c,b as d}from"./vendor-query-CC4VRGyP.js";import{T as l,a as m,b as u,c as x,d as h,e as j}from"./table-BexhSyg2.js";import{D as p,a as f,b,c as v,d as g}from"./dialog-D-Ed7GOQ.js";import{T as N}from"./textarea-BWP5M5Bk.js";import{S as y,a as w,b as S,c as _,d as C}from"./select-DR0VJVi7.js";import{f as q}from"./format-hXGQLsWs.js";import{k as F,q as E,Z as A}from"./vendor-icons-CaI5__By.js";import"./vendor-ui-B4WC06Sp.js";import"./vendor-supabase-COwyE4EW.js";import"./separator-Cc2qsRsv.js";import"./index-CCdGLatk.js";import"./Combination-DzDAyqvK.js";import"./index-B3FPD4RS.js";import"./en-US-DUAJ-5Wt.js";const M=()=>{const{submissions:M,isLoading:k,updateStatus:D,updateNotes:K,deleteSubmission:L}=(()=>{const e=o(),{data:n,isLoading:i}=c({queryKey:["contact-submissions"],queryFn:async()=>{const{data:s,error:e}=await a.from("contact_submissions").select("*").order("created_at",{ascending:!1});if(e)throw e;return s}});s.useEffect(()=>{const s=a.channel("contact-submissions-db-changes").on("postgres_changes",{event:"*",schema:"public",table:"contact_submissions"},()=>{e.invalidateQueries({queryKey:["contact-submissions"]})}).subscribe();return()=>{a.removeChannel(s)}},[e]);const r=d({mutationFn:async({id:s,status:e})=>{const{error:t}=await a.from("contact_submissions").update({status:e}).eq("id",s);if(t)throw t},onSuccess:()=>{e.invalidateQueries({queryKey:["contact-submissions"]}),t.success("Status updated successfully")},onError:s=>{t.error(s.message||"Failed to update status")}}),l=d({mutationFn:async({id:s,notes:e})=>{const{error:t}=await a.from("contact_submissions").update({notes:e}).eq("id",s);if(t)throw t},onSuccess:()=>{e.invalidateQueries({queryKey:["contact-submissions"]}),t.success("Notes updated successfully")},onError:s=>{t.error(s.message||"Failed to update notes")}}),m=d({mutationFn:async s=>{const{error:e}=await a.from("contact_submissions").delete().eq("id",s);if(e)throw e},onSuccess:()=>{e.invalidateQueries({queryKey:["contact-submissions"]}),t.success("Submission deleted successfully")},onError:s=>{t.error(s.message||"Failed to delete submission")}}),u=(null==n?void 0:n.filter(s=>"unread"===s.status).length)||0;return{submissions:n,isLoading:i,unreadCount:u,updateStatus:r,updateNotes:l,deleteSubmission:m}})(),[Q,$]=s.useState(null),[P,R]=s.useState("");s.useEffect(()=>{const s=a.channel("contact-submissions-changes").on("postgres_changes",{event:"INSERT",schema:"public",table:"contact_submissions"},s=>{const e=s.new;t.success(`New contact form submission from ${e.first_name} ${e.last_name}`,{description:e.email,duration:1e4})}).subscribe();return()=>{a.removeChannel(s)}},[]);return e.jsxs(e.Fragment,{children:[e.jsx(n,{children:e.jsx("title",{children:"Contact Submissions | Admin"})}),e.jsxs(r,{children:[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-2",children:"Manage contact form submissions from users"})]}),k?e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})}):e.jsx("div",{className:"bg-card rounded-lg border border-border overflow-hidden",children:e.jsxs(l,{children:[e.jsx(m,{children:e.jsxs(u,{children:[e.jsx(x,{children:"Date"}),e.jsx(x,{children:"Name"}),e.jsx(x,{children:"Email"}),e.jsx(x,{children:"Message Preview"}),e.jsx(x,{children:"Status"}),e.jsx(x,{className:"text-right",children:"Actions"})]})}),e.jsx(h,{children:M&&M.length>0?M.map(s=>e.jsxs(u,{children:[e.jsx(j,{className:"whitespace-nowrap",children:q(new Date(s.created_at),"MMM dd, yyyy")}),e.jsxs(j,{className:"font-medium",children:[s.first_name," ",s.last_name]}),e.jsx(j,{children:e.jsxs("a",{href:`mailto:${s.email}`,className:"text-primary hover:underline flex items-center gap-1",children:[e.jsx(F,{className:"h-3 w-3"}),s.email]})}),e.jsx(j,{className:"max-w-md truncate",children:s.message}),e.jsx(j,{children:e.jsxs(y,{value:s.status,onValueChange:e=>{return a=s.id,t=e,void D.mutate({id:a,status:t});var a,t},children:[e.jsx(w,{className:"w-32",children:e.jsx(S,{})}),e.jsxs(_,{children:[e.jsx(C,{value:"unread",children:"Unread"}),e.jsx(C,{value:"read",children:"Read"}),e.jsx(C,{value:"replied",children:"Replied"}),e.jsx(C,{value:"archived",children:"Archived"})]})]})}),e.jsx(j,{className:"text-right",children:e.jsxs("div",{className:"flex items-center justify-end gap-2",children:[e.jsx(i,{variant:"ghost",size:"sm",onClick:()=>(s=>{$(s),R(s.notes||"")})(s),children:e.jsx(E,{className:"h-4 w-4"})}),e.jsx(i,{variant:"ghost",size:"sm",onClick:()=>{return e=s.id,void(confirm("Are you sure you want to delete this submission?")&&L.mutate(e));var e},children:e.jsx(A,{className:"h-4 w-4 text-destructive"})})]})})]},s.id)):e.jsx(u,{children:e.jsx(j,{colSpan:6,className:"text-center py-8 text-muted-foreground",children:"No contact submissions yet"})})})]})})]}),e.jsx(p,{open:!!Q,onOpenChange:()=>$(null),children:e.jsxs(f,{className:"max-w-2xl",children:[e.jsxs(b,{children:[e.jsx(v,{children:"Contact Submission Details"}),e.jsxs(g,{children:["From ",null==Q?void 0:Q.first_name," ",null==Q?void 0:Q.last_name]})]}),Q&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium text-muted-foreground",children:"Email"}),e.jsx("p",{className:"text-foreground",children:Q.email})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium text-muted-foreground",children:"Date"}
1),e.jsx("p",{className:"text-foreground",children:q(new Date(Q.created_at),"PPpp")})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium text-muted-foreground",children:"Message"}),e.jsx("p",{className:"text-foreground whitespace-pre-wrap mt-1",children:Q.message})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium text-muted-foreground block mb-2",children:"Internal Notes"}),e.jsx(N,{value:P,onChange:s=>R(s.target.value),placeholder:"Add internal notes...",className:"min-h-[100px]"})]}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(i,{variant:"outline",onClick:()=>$(null),children:"Close"}),e.jsx(i,{onClick:()=>{Q&&(K.mutate({id:Q.id,notes:P}),$(null),R(""))},children:"Save Notes"})]})]})]})})]})]})};export{M 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.