PageSourceSearch

https://codir.pro/assets/AdminContactMessages-GwGznSSb.js

js codir.pro collected 2026-10-02 02:06:10 UTC 6,685 bytes, 11 lines download raw bytes

1import{c as v,r,j as e,L as C,b as n,t as i}from"./index-B0sM48fE.js";import{B as R}from"./badge-61pv9H8q.js";import{B as f}from"./button-CXcf0psP.js";import{M as h}from"./mail-Bq5DIA9G.js";import{C as g}from"./circle-check-CxxoOG2b.js";import{f as S,e as L}from"./format-Ds46GObI.js";/**
2 * @license lucide-react v0.475.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 _=[["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"}]],j=v("MailOpen",_);/**
7 * @license lucide-react v0.475.0 - ISC
8 *
9 * This source code is licensed under the ISC license.
10 * See the LICENSE file in the root directory of this source tree.
11 */const $=[["polyline",{points:"9 17 4 12 9 7",key:"hvgpf2"}],["path",{d:"M20 18v-2a4 4 0 0 0-4-4H4",key:"5vmcpk"}]],A=v("Reply",$),N={nouveau:{label:"New",color:"text-orange-400 border-orange-400/50"},lu:{label:"Read",color:"text-blue-400 border-blue-400/50"},répondu:{label:"Replied",color:"text-green-400 border-green-400/50"}};function I(){const[B,y]=r.useState(null),[a,c]=r.useState([]),[w,k]=r.useState(!0),[d,M]=r.useState("all"),[x,m]=r.useState(null);r.useEffect(()=>{async function s(){try{const t=await n.auth.me();if((t==null?void 0:t.role)!=="admin"){window.location.href="/app";return}y(t);const l=await n.entities.ContactMessage.list("-created_date").catch(()=>[]);c(l)}catch(t){console.error("Admin contact load error",t),i.error("Failed to load messages")}finally{k(!1)}}s()},[]);const u=async(s,t)=>{m(s);try{await n.entities.ContactMessage.update(s,{status:t}),c(l=>l.map(o=>o.id===s?{...o,status:t}:o)),i.success("Status updated")}catch{i.error("Update failed")}finally{m(null)}},p=d==="all"?a:a.filter(s=>s.status===d),b=a.filter(s=>s.status==="nouveau").length;return w?e.jsx("div",{className:"flex items-center justify-center h-64",children:e.jsx(C,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):e.jsxs("div",{children:[e.jsxs("div",{className:"mb-6",children:[e.jsx("h1",{className:"font-space font-bold text-2xl sm:text-3xl text-foreground mb-1",children:"Contact Messages"}),e.jsx("p",{className:"text-muted-foreground text-sm",children:"Messages submitted via the public contact form."})]}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-3 sm:gap-4 mb-6",children:[e.jsxs("div",{className:"bg-card border border-border/50 rounded-xl p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground text-xs mb-1",children:[e.jsx(h,{className:"h-3.5 w-3.5"})," Total"]}),e.jsx("div",{className:"text-2xl font-bold text-foreground",children:a.length})]}),e.jsxs("div",{className:"bg-card border border-orange-400/40 rounded-xl p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground text-xs mb-1",children:[e.jsx(h,{className:"h-3.5 w-3.5"})," New"]}),e.jsx("div",{className:"text-2xl font-bold text-orange-400",children:b})]}),e.jsxs("div",{className:"bg-card border border-border/50 rounded-xl p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground text-xs mb-1",children:[e.jsx(j,{className:"h-3.5 w-3.5"})," Read"]}),e.jsx("div",{className:"text-2xl font-bold text-foreground",children:a.filter(s=>s.status==="lu").length})]}),e.jsxs("div",{className:"bg-card border border-border/50 rounded-xl p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground text-xs mb-1",children:[e.jsx(g,{className:"h-3.5 w-3.5"})," Replied"]}),e.jsx("div",{className:"text-2xl font-bold text-green-400",children:a.filter(s=>s.status==="répondu").length})]})]}),e.jsx("div",{className:"flex gap-1 p-1 bg-secondary/50 rounded-xl border border-border/50 mb-6 w-full sm:w-fit overflow-x-auto",children:[{key:"all",label:`All (${a.length})`},{key:"nouveau",label:`New (${b})`},{key:"lu",label:"Read"},{key:"répondu",label:"Replied"}].map(s=>e.jsx("button",{onClick:()=>M(s.key),className:`px-3 sm:px-4 py-2 rounded-lg text-sm font-medium whitespace-nowrap transition-all ${d===s.key?"bg-primary text-primary-foreground":"text-muted-foreground hover:text-foreground"}`,children:s.label},s.key))}),e.jsxs("div",{className:"space-y-3",children:[p.length===0&&e.jsx("div",{className:"text-center py-12 text-muted-foreground bg-card border border-border/50 rounded-xl",children:"No messages"}),p.map(s=>{const t=N[s.status]||N.nouveau;return e.jsxs("div",{className:"bg-card border border-border/50 rounded-xl p-4 sm:p-5",children:[e.jsx("div",{className:"flex flex-col sm:flex-row sm:items-start sm:justify-between gap-3 mb-3",children:e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2 mb-1",children:[e.jsx("span",{className:"font-semibold text-foreground",children:s.name}),e.jsx(R,{variant:"outline",className:t.color,children:t.label})]}),e.jsx("a",{href:`mailto:${s.email}`,className:"text-xs text-primary hover:underline break-all",children:s.email}),s.created_date&&e.jsx("div",{className:"text-xs text-muted-foreground mt-1",children:S(new Date(s.created_date),"dd MMM yyyy 'at' HH:mm",{locale:L})})]})}),e.jsxs("div",{className:"mb-3",children:[e.jsx("div",{className:"text-xs text-muted-foreground uppercase tracking-wider font-semibold mb-1",children:"Subject"}),e.jsx("div",{className:"text-sm text-foreground font-medium",children:s.subject})]}),e.jsxs("div",{className:"mb-4",children:[e.jsx("div",{className:"text-xs text-muted-foreground uppercase tracking-wider font-semibold mb-1",children:"Message"}),e.jsx("div",{className:"text-sm text-muted-foreground whitespace-pre-wrap leading-relaxed bg-secondary/30 rounded-lg p-3 border border-border/30",children:s.message})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsxs("a",{href:`mailto:${s.email}?subject=Re: ${encodeURIComponent(s.subject||"")}`,className:"inline-flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-sm font-medium bg-primary text-primary-foreground hover:bg-primary/90 transition-colors",children:[e.jsx(A,{className:"h-3.5 w-3.5"}),"Reply by email"]}),s.status==="nouveau"&&e.jsxs(f,{size:"sm",variant:"outline",disabled:x===s.id,onClick:()=>u(s.id,"lu"),children:[e.jsx(j,{className:"h-3.5 w-3.5 mr-1"})," Mark as read"]}),s.status!=="répondu"&&e.jsxs(f,{size:"sm",variant:"outline",disabled:x===s.id,onClick:()=>u(s.id,"répondu"),className:"border-green-500/50 text-green-400 hover:bg-green-500/10",children:[e.jsx(g,{className:"h-3.5 w-3.5 mr-1"})," Mark as replied"]})]})]},s.id)})]})]})}export{I 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.