PageSourceSearch

https://utsniper.com/assets/Messages-C9pAD-e3.js

js utsniper.com collected 2026-09-24 14:57:32 UTC 4,715 bytes, 1 lines download raw bytes

1import{r as n,j as e}from"./react-DmmmXvkf.js";import{e as E,D as C}from"./DateRangePicker-Gmnh6dyo.js";import{C as D}from"./card-BcT-hHLI.js";import{T as I}from"./TableToolbar-Cr77tLaf.js";import{u as R,a as F}from"./query-BEXY55w7.js";import{$ as P,f as y,B as l,br as L,E as $,g as S}from"./index-C1oWTp1R.js";import{T as z,a as O,b as m,c as h,d as H,e as r}from"./table-J6rnOMWM.js";import{S as A}from"./skeleton-B3U8IGPm.js";import{Q as B}from"./QueryError-Cs1v4noy.js";import{u as Q}from"./i18n-DQg7CiDt.js";import{s as U}from"./startOfDay-BRYZsaos.js";import{f as _}from"./format-DQEjml6R.js";import{T as q}from"./trash-2-W1ofATpH.js";import"./chevron-left-fSIKIPdO.js";import"./popover-D5T_GLpx.js";import"./refresh-cw-BrhrdZjd.js";import"./motion-BB-_2whf.js";import"./triangle-alert-DBrVopfV.js";function le(){const{t:a}=Q(),{toast:j}=P(),b=20,[i,x]=n.useState(1),[p,M]=n.useState(null),[o,T]=n.useState(void 0),c=o?.from?U(o.from).toISOString():void 0,d=o?.to?E(o.to).toISOString():void 0;n.useEffect(()=>{x(1)},[c,d]);const{data:g,isLoading:v,isError:w,isFetching:k,refetch:u}=R({queryKey:["admin-contact-messages",i,c??"",d??""],queryFn:async()=>{const s=new URLSearchParams({page:String(i),pageSize:String(b)});c&&s.set("from",c),d&&s.set("to",d);const t=await y(S(`/api/admin/contact-messages?${s}`));if(!t.ok)throw new Error("messages_fetch_failed");return t.json()}}),N=F({mutationFn:async s=>{if(!(await y(S(`/api/admin/contact-messages/${s}`),{method:"DELETE"})).ok)throw new Error("delete_failed")},onSuccess:()=>{j({title:a("adminMessages.deleted")}),u()},onError:()=>j({title:a("common.error"),variant:"destructive"})}),f=Math.max(1,Math.ceil((g?.total??0)/b));return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-3xl font-bold tracking-tight",children:a("adminMessages.title")}),e.jsx("p",{className:"text-muted-foreground",children:a("adminMessages.subtitle")})]}),e.jsxs(D,{className:"bg-card/40 border-white/[0.07] overflow-hidden",children:[e.jsx(I,{onRefresh:()=>u(),refreshing:k,refreshLabel:a("dashSnipes.refresh"),actions:e.jsx(C,{value:o,onChange:T,align:"end",placeholder:`${a("dashSnipes.dateFrom")} – ${a("dashSnipes.dateTo")}`,clearLabel:a("dashSnipes.clearDates")})}),w?e.jsx("div",{className:"p-6",children:e.jsx(B,{onRetry:()=>u()})}):v?e.jsx("div",{className:"space-y-2 p-4",children:[1,2,3,4,5].map(s=>e.jsx(A,{className:"h-16 w-full bg-card rounded-md"},s))}):e.jsx("div",{className:"overflow-x-auto",children:e.jsxs(z,{children:[e.jsx(O,{className:"bg-white/[0.03]",children:e.jsxs(m,{className:"border-white/[0.07] hover:bg-transparent",children:[e.jsx(h,{children:a("adminMessages.colFrom")}),e.jsx(h,{children:a("adminMessages.colSubject")}),e.jsx(h,{children:a("adminMessages.colDate")}),e.jsx(h,{className:"text-right",children:a("adminMessages.colActions")})]})}
1),e.jsxs(H,{children:[g?.items.map(s=>e.jsxs(n.Fragment,{children:[e.jsxs(m,{className:"border-white/5 hover:bg-white/5 cursor-pointer",onClick:()=>M(p===s.id?null:s.id),children:[e.jsxs(r,{children:[e.jsx("div",{className:"font-medium text-foreground",children:s.name}),e.jsx("a",{href:`mailto:${s.email}`,onClick:t=>t.stopPropagation(),className:"text-xs text-primary hover:underline",children:s.email})]}),e.jsx(r,{className:"max-w-[280px]",children:e.jsx("span",{className:"block truncate",children:s.subject})}),e.jsx(r,{className:"text-muted-foreground text-xs whitespace-nowrap",children:_(new Date(s.createdAt),"MMM d, yyyy HH:mm")}),e.jsxs(r,{className:"text-right",children:[e.jsx(l,{variant:"ghost",size:"icon",className:"text-muted-foreground",children:p===s.id?e.jsx(L,{className:"w-4 h-4"}):e.jsx($,{className:"w-4 h-4"})}),e.jsx(l,{variant:"ghost",size:"icon",className:"text-destructive hover:bg-destructive/10",disabled:N.isPending,onClick:t=>{t.stopPropagation(),N.mutate(s.id)},children:e.jsx(q,{className:"w-4 h-4"})})]})]}),p===s.id&&e.jsx(m,{className:"border-white/5 bg-background/40",children:e.jsx(r,{colSpan:4,className:"whitespace-pre-wrap text-sm text-foreground/90 px-6 py-4",children:s.message})})]},s.id)),g?.items.length===0&&e.jsx(m,{children:e.jsx(r,{colSpan:4,className:"text-center py-10 text-muted-foreground",children:a("adminMessages.empty")})})]})]})})]}),!v&&!w&&f>1&&e.jsxs("div",{className:"flex items-center justify-end gap-3 text-sm text-muted-foreground",children:[e.jsx(l,{variant:"outline",size:"sm",disabled:i<=1,onClick:()=>x(s=>Math.max(1,s-1)),children:a("adminMessages.previous")}),e.jsx("span",{children:a("adminMessages.page",{page:i,totalPages:f})}),e.jsx(l,{variant:"outline",size:"sm",disabled:i>=f,onClick:()=>x(s=>s+1),children:a("adminMessages.next")})]})]})}export{le as AdminMessages};

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.