1import{K as m,t as x,j as e,v as r,q as u}from"./index-42OYDF60.js";import{u as n}from"./useMutation-TEeOEsok.js";import{B as c}from"./button-EfpS49lo.js";import{L as p}from"./loader-circle-C9c4MVet.js";import{M as h}from"./mail-T8cR2-w0.js";import{C as f}from"./check-CJKIezrx.js";import{T as j}from"./trash-2-B3_ksNI2.js";const q=()=>{const i=m(),{data:t=[],isLoading:d}=x({queryKey:["admin_messages"],queryFn:async()=>{const{data:s,error:a}=await r.from("contact_messages").select("*").order("created_at",{ascending:!1});if(a)throw a;return s}}),l=n({mutationFn:async s=>{const{error:a}=await r.from("contact_messages").update({is_read:!0}).eq("id",s);if(a)throw a},onSuccess:()=>i.invalidateQueries({queryKey:["admin_messages"]})}),o=n({mutationFn:async s=>{const{error:a}=await r.from("contact_messages").delete().eq("id",s);if(a)throw a},onSuccess:()=>{u.success("মà§à¦à§ ফà§à¦²à¦¾ হয়à§à¦à§"),i.invalidateQueries({queryKey:["admin_messages"]})}});return e.jsxs("div",{className:"space-y-5",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-3xl font-extrabold tracking-tight",children:"à¦à¦¨à§à¦à¦¾à¦à§à¦ বারà§à¦¤à¦¾"}),e.jsxs("p",{className:"text-sm text-muted-foreground mt-1",children:[t.length,"à¦à¦¿ বারà§à¦¤à¦¾"]})]}),d?e.jsx("div",{className:"flex h-64 items-center justify-center",children:e.jsx(p,{className:"h-8 w-8 animate-spin text-primary"})}):e.jsxs("div",{className:"space-y-3",children:[t.map(s=>e.jsx("div",{className:`rounded-2xl glass-card p-4 ${!s.is_read&&"ring-1 ring-primary/30"}`,children:e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("div",{className:"font-bold",children:s.name}),!s.is_read&&e.jsx("span",{className:"rounded-full bg-primary/20 px-2 py-0.5 text-[10px] font-bold text-primary uppercase tracking-wider",children:"New"})]}),e.jsxs("div",{className:"text-xs text-muted-foreground",children:[s.email," ",s.phone&&`⢠${s.phone}`]}),s.subject&&e.jsx("div",{className:"mt-2 font-semibold text-sm",children:s.subject}),e.jsx("p",{className:"mt-2 text-sm whitespace-pre-wrap",children:s.message}),e.jsx("div",{className:"mt-2 text-[10px] text-muted-foreground uppercase tracking-wider",children:new Date(s.created_at).toLocaleString()})]}),e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx("a",{href:`mailto:${s.email}`,className:"rounded-md border border-input p-2 hover:bg-secondary/50",children:e.jsx(h,{className:"h-3.5 w-3.5"})}),!s.is_read&&e.jsx(c,{size:"sm",variant:"outline",onClick:()=>l.mutate(s.id),children:e.jsx(f,{className:"h-3.5 w-3.5"})}),e.jsx(c,{size:"sm",variant:"outline",onClick:()=>{confirm("মà§à¦à¦¬à§à¦¨?")&&o.mutate(s.id)},children:e.jsx(j,{className:"h-3.5 w-3.5"})})]})]})},s.id)),t.length===0&&e.jsx("div",{className:"rounded-2xl glass-card p-8 text-center text-muted-foreground",children:"à¦à§à¦¨à§ বারà§à¦¤à¦¾ নà§à¦"})]})]})};export{q 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.