1import{n as H,r as j,T as P,f as B,V as v,j as e,d as E,t as c,S as q,c as o,l as C,K as S,s as p,O as f,J as M}from"./index-hXw6ftrS.js";import{A as K}from"./AdminLayout-wgA6AW0K.js";import{C as I,a as O,b as Q,d as _,c as F}from"./card-DYGdilSS.js";import{I as $}from"./input-CGBE-TqA.js";import{B as d}from"./badge-COjR1-IC.js";import{T as z,a as R,b as k,c as n,d as G,e as i}from"./table-BJLCkYQp.js";import{S as V,a as J,b as U,c as Z,d as W}from"./sheet-CWRc6t5g.js";import{A as X,a as Y,b as ee,c as ae,d as se,e as te,f as re,g as ne}from"./alert-dialog-CT4Ob312.js";import{A as ie}from"./arrow-left-D0Z-_GCd.js";import{T as le}from"./trash-2-BJHzY9mo.js";import{S as ce}from"./send-CGloYoR3.js";import{C as oe}from"./circle-check-DXuu0VXZ.js";import"./layout-dashboard-D2aZjlX_.js";import"./megaphone-BMNY5bbU.js";import"./images--YEsJ6xp.js";import"./image-gPMVwkW6.js";import"./stethoscope-CyZzpUvZ.js";import"./award-C78RWvFt.js";import"./shield-DAj5TFdV.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 de=H("MailOpen",[["path",{d:"M21.2 8.4c.5.38.8.97.8 1.6v10a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V10a2 2 0 0 1 .8-1.6l8-6a2 2 0 0 1 2.4 0l8 6Z",key:"1jhwl8"}],["path",{d:"m22 10-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 10",key:"1qfld7"}]]),Te=()=>{const[l,D]=j.useState(""),[s,m]=j.useState(null),[u,x]=j.useState(null),g=P(),{data:t,isLoading:A}=B({queryKey:["admin-contact-messages"],queryFn:async()=>{const{data:a,error:r}=await p.from("contact_messages").select("*").order("created_at",{ascending:!1});if(r)throw r;return a}}),w=v({mutationFn:async({id:a,status:r})=>{const{error:b}=await p.from("contact_messages").update({status:r}).eq("id",a);if(b)throw b},onSuccess:()=>g.invalidateQueries({queryKey:["admin-contact-messages"]}),onError:()=>f.error("Gagal memperbarui status")}),N=v({mutationFn:async a=>{const{error:r}=await p.from("contact_messages").delete().eq("id",a);if(r)throw r},onSuccess:()=>{g.invalidateQueries({queryKey:["admin-contact-messages"]}),f.success("Pesan berhasil dihapus"),x(null)},onError:()=>f.error("Gagal menghapus pesan")}),T=a=>{m(a),a.status==="unread"&&w.mutate({id:a.id,status:"read"})},h=t==null?void 0:t.filter(a=>a.name.toLowerCase().includes(l.toLowerCase())||a.email.toLowerCase().includes(l.toLowerCase())||a.subject.toLowerCase().includes(l.toLowerCase())),y=(t==null?void 0:t.filter(a=>a.status==="unread").length)||0,L=a=>{switch(a){case"unread":return e.jsx(d,{className:"bg-accent/15 text-accent border-accent/30",children:"Belum Dibaca"});case"resolved":return e.jsx(d,{className:"bg-primary/10 text-primary",children:"Selesai"});default:return e.jsx(d,{variant:"secondary",children:"Sudah Dibaca"})}};return e.jsxs(K,{title:"Pesan Masuk",subtitle:"Pesan dari formulir Kontak di website",children:[e.jsxs("div",{className:"max-w-7xl mx-auto",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-4 mb-6",children:[e.jsx(E,{to:"/admin",children:e.jsxs(c,{variant:"ghost",size:"sm",children:[e.jsx(ie,{className:"w-4 h-4 mr-2"}),"Kembali ke Dashboard"]})}),e.jsxs("div",{className:"relative flex-1 sm:w-72",children:[e.jsx(q,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-muted-foreground"}),e.jsx($,{placeholder:"Cari nama, email, atau subjek...",value:l,onChange:a=>D(a.target.value),className:"pl-9"})]})]}),e.jsxs(I,{children:[e.jsxs(O,{children:[e.jsxs(Q,{className:"flex items-center gap-2",children:[e.jsx(o,{className:"w-5 h-5 text-primary"}),"Kotak Masuk",y>0&&e.jsxs(d,{className:"bg-accent text-accent-foreground",children:[y," baru"]})]}),e.jsxs(_,{children:["Total ",(t==null?void 0:t.length)||0," pesan diterima"]})]}),e.jsx(F,{children:A?e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:e.jsx(C,{className:"w-6 h-6 animate-spin mx-auto"})}):h&&h.length>0?e.jsx("div",{className:"overflow-x-auto",children:e.jsxs(z,{children:[e.jsx(R,{children:e.jsxs(k,{children:[e.jsx(n,{}),e.jsx(n,{children:"Pengirim"}),e.jsx(n,{children:"Subjek"}),e.jsx(n,{children:"Status"}),e.jsx(n,{children:"Tanggal"}),e.jsx(n,{className:"text-right",children:"Aksi"})]})}),e.jsx(G,{children:h.map(a=>
6e.jsxs(k,{className:`cursor-pointer ${a.status==="unread"?"font-medium":""}`,onClick:()=>T(a),children:[e.jsx(i,{className:"w-8",children:a.status==="unread"?e.jsx(o,{className:"w-4 h-4 text-accent"}):e.jsx(de,{className:"w-4 h-4 text-muted-foreground"})}),e.jsxs(i,{className:"max-w-[200px]",children:[e.jsx("div",{className:"truncate",children:a.name}),e.jsx("p",{className:"text-xs text-muted-foreground truncate font-normal",children:a.email})]}),e.jsx(i,{className:"max-w-[220px] truncate",children:a.subject}),e.jsx(i,{children:L(a.status)}),e.jsx(i,{className:"text-sm text-muted-foreground whitespace-nowrap",children:S(new Date(a.created_at),"dd MMM yyyy, HH:mm",{locale:M})}),e.jsx(i,{className:"text-right",children:e.jsx(c,{size:"icon",variant:"ghost",className:"text-destructive hover:text-destructive",onClick:r=>{r.stopPropagation(),x(a.id)},children:e.jsx(le,{className:"w-4 h-4"})})})]},a.id))})]})}):e.jsxs("div",{className:"text-center py-12 text-muted-foreground",children:[e.jsx(o,{className:"w-12 h-12 mx-auto mb-4 opacity-50"}),e.jsx("p",{children:"Belum ada pesan masuk"})]})})]})]}),e.jsx(V,{open:!!s,onOpenChange:a=>{a||m(null)},children:e.jsx(J,{className:"w-full sm:max-w-lg overflow-y-auto",children:s&&e.jsxs(e.Fragment,{children:[e.jsxs(U,{children:[e.jsxs(Z,{className:"flex items-center gap-2",children:[e.jsx(o,{className:"w-5 h-5 text-primary"}),s.subject]}),e.jsx(W,{children:S(new Date(s.created_at),"EEEE, dd MMMM yyyy HH:mm",{locale:M})})]}),e.jsxs("div",{className:"mt-6 space-y-4",children:[e.jsxs("div",{className:"p-4 bg-secondary/30 rounded-xl border border-border",children:[e.jsx("p",{className:"font-medium text-foreground",children:s.name}),e.jsx("a",{href:`mailto:${s.email}`,className:"text-sm text-primary hover:underline",children:s.email})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium text-foreground mb-2",children:"Pesan:"}),e.jsx("p",{className:"text-sm text-muted-foreground whitespace-pre-line leading-relaxed",children:s.message})]}),e.jsxs("div",{className:"flex flex-wrap gap-2 pt-2",children:[e.jsx(c,{size:"sm",variant:"outline",asChild:!0,children:e.jsxs("a",{href:`mailto:${s.email}?subject=${encodeURIComponent(`Re: ${s.subject}`)}`,children:[e.jsx(ce,{className:"w-3.5 h-3.5 mr-1.5"})," Balas via Email"]})}),s.status!=="resolved"&&e.jsxs(c,{size:"sm",variant:"outline",className:"text-primary hover:text-primary",onClick:()=>{w.mutate({id:s.id,status:"resolved"}),m({...s,status:"resolved"})},children:[e.jsx(oe,{className:"w-3.5 h-3.5 mr-1.5"})," Tandai Selesai"]})]})]})]})})}),e.jsx(X,{open:!!u,onOpenChange:()=>x(null),children:e.jsxs(Y,{children:[e.jsxs(ee,{children:[e.jsx(ae,{children:"Hapus Pesan?"}),e.jsx(se,{children:"Pesan ini akan dihapus secara permanen."})]}),e.jsxs(te,{children:[e.jsx(re,{children:"Batal"}),e.jsx(ne,{onClick:()=>u&&N.mutate(u),className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:N.isPending?e.jsx(C,{className:"w-4 h-4 animate-spin"}):"Hapus"})]})]})})]})};export{Te 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.