1import{f as $,a as z,r as F,b as I,j as e,k as l,m as p,n as u,l as i,h as O,L as q,N as E,U as K,B as h,C as A,X as k}from"./index-DvhEnGG3.js";import{u as v}from"./useMutation-5Qt1sQt-.js";import{A as L}from"./AdminLayout-Zrrm2zl0.js";import{T as P,a as R,b as j,c as g}from"./tabs-BQ2O5CL_.js";import{S as H,a as Q,b as V,c as D,d as b}from"./select-vcTZAPV9.js";import{a as y}from"./adminAuth-DLSKqndo.js";import{M as a}from"./message-square-Dgp5wLTg.js";import{C as U}from"./clock-Dl5uYcaP.js";import{C as X}from"./circle-x-9qVjH4V7.js";import{T as G}from"./trash-2-DvlTil9x.js";import{f as J}from"./format-CxxDD1Zd.js";import"./chart-column-DZJB8hAl.js";import"./file-text-DsmeFF5q.js";import"./folder-open-Dfep7Pji.js";import"./video-Cp2pAFso.js";import"./book-open-BX1a14hQ.js";import"./trending-up-CmFiU1GD.js";import"./anchor-DHgUDgz1.js";import"./calendar-days-BeDpXHdp.js";import"./building-2-DUT4rmqF.js";import"./users-BdUbaTLb.js";import"./vote-oaa0C-Bt.js";import"./chevron-up-bCZKjDmd.js";import"./en-US-BF8dUB01.js";function ve(){const{toast:f}=$(),N=z(),[r,S]=F.useState("all"),{data:n=[],isLoading:B}=I({queryKey:["/api/admin/comments"],queryFn:async()=>{const T=await(await y("/api/admin/comments")).json();return Array.isArray(T)?T:[]}}),C=v({mutationFn:s=>y(`/api/admin/comments/${s}/approve`,{method:"POST"}),onSuccess:()=>{N.invalidateQueries({queryKey:["/api/admin/comments"]}),f({title:"Yorum onaylandı"})}}),d=v({mutationFn:s=>y(`/api/admin/comments/${s}/reject`,{method:"POST"}),onSuccess:()=>{N.invalidateQueries({queryKey:["/api/admin/comments"]}),f({title:"Yorum onayı kaldırıldı"})}}),w=v({mutationFn:s=>y(`/api/admin/comments/${s}`,{method:"DELETE"}),onSuccess:()=>{N.invalidateQueries({queryKey:["/api/admin/comments"]}),f({title:"Yorum silindi"})}}),t=n.filter(s=>r==="all"?!0:r==="article"?s.articleId!==null:r==="opinion"?s.opinionId!==null:!0),c=t.filter(s=>s.status==="pending"),o=t.filter(s=>s.status==="approved"),m=t.filter(s=>s.status==="rejected"),M=n.filter(s=>s.articleId!==null),Y=n.filter(s=>s.opinionId!==null),x=({comment:s})=>e.jsx(l,{className:"mb-4","data-testid":`comment-card-${s.id}`,children:e.jsx(i,{className:"pt-4",children:e.jsxs("div",{className:"flex justify-between items-start gap-4",children:[e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx("span",{className:"font-semibold",children:s.authorName}),s.authorEmail&&e.jsxs("span",{className:"text-sm text-muted-foreground",children:["(",s.authorEmail,")"]}),s.parentId&&e.jsx("span",{className:"text-xs bg-blue-100 text-blue-700 px-2 py-0.5 rounded",children:"Yanıt"})]}),e.jsx("p",{className:"text-sm text-foreground mb-3",children:s.content}),e.jsxs("div",{className:"flex items-center gap-4 text-xs text-muted-foreground",children:[e.jsx("span",{children:J(new Date(s.createdAt),"dd MMM yyyy HH:mm")}),e.jsx("span",{className:`px-2 py-0.5 rounded font-medium ${s.status==="pending"?"bg-yellow-100 text-yellow-700":s.status==="approved"?"bg-green-100 text-green-700":"bg-red-100 text-red-700"}`,children:s.status==="pending"?"Bekliyor":s.status==="approved"?"Onaylı":"Reddedildi"}),s.articleId&&e.jsxs("span",{className:"flex items-center gap-1 bg-blue-50 text-blue-700 px-2 py-0.5 rounded",children:[e.jsx(E,{className:"h-3 w-3"}),"Haber"]}),s.opinionId&&e.jsxs("span",{className:"flex items-center gap-1 bg-purple-50 text-purple-700 px-2 py-0.5 rounded",children:[e.jsx(K,{className:"h-3 w-3"}),"KöÅe Yazısı"]})]})]}),e.jsxs("div",{className:"flex gap-2 shrink-0",children:[s.status!=="approved"&&e.jsx(h,{size:"sm",variant:"outline",className:"text-green-600 hover:text-green-700 hover:bg-green-50",onClick:()=>C.mutate(s.id),disabled:C.isPending,"data-testid":`button-approve-${s.id}`,title:"Onayla",children:e.jsx(A,{className:"h-4 w-4"})}),s.status==="approved"&&e.jsx(h,{size:"sm",variant:"outline",className:"text-yellow-600 hover:text-yellow-700 hover:bg-yellow-50",onClick:()=>d.mutate(s.id),disabled:d.isPending,"data-testid":`button-unapprove-${s.id}`,title:"Onayı Kaldır",children:e.jsx(k,{className:"h-4 w-4"})}),s.status==="pending"&&e.jsx(h,{size:"sm",variant:"outline",className:"text-red-600 hover:text-red-700 hover:bg-red-50",onClick:()=>d.mutate(s.id),disabled:d.isPending,"data-testid":`button-reject-${s.id}`,title:"Reddet",children:e.jsx(k,{className:"h-4 w-4"})}),e.jsx(h,{size:"sm",variant:"outline",className:"text-red-600 hover:text-red-700 hover:bg-red-50",onClick:()=>{confirm("Bu yorumu silmek istediÄinizden emin misiniz?")&&w.mutate(s.id)},disabled:w.isPending,"data-testid":`button-delete-${s.id}`,title:"Sil",children:e.jsx(G,{className:"h-4 w-4"})})]})]})})});return e.jsx(L,{children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(a,{className:"h-8 w-8 text-primary"}),e.jsx("h1",{className:"text-2xl font-bold",children:"Yorum Yönetimi"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-sm text-muted-foreground",children:"Filtre:"}),e.jsxs(H,{value:r,onValueChange:s=>S(s),children:[e.jsx(Q,{className:"w-40","data-testid":"select-type-filter",children:e.jsx(V,{})}),e.jsxs(D,{children:[e.jsxs(b,{value:"all",children:["Tümü (",n.length,")"]}),e.jsxs(b,{value:"article",children:["Haberler (",M.length,")"]}),e.jsxs(b,{value:"opinion",children:["KöÅe Yazıları (",Y.length,")"]})]})]})]})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-4 gap-4",children:[e.jsxs(l,{children:[e.jsx(p,{className:"pb-2",children:e.jsxs(u,{className:"text-sm text-muted-foreground flex items-center gap-2",children:[e.jsx(a,{className:"h-4 w-4 text-blue-500"}),"Toplam"]})}),e.jsx(i,{children:e.jsx("div",{className:"text-3xl font-bold",children:t.length})})]}),e.jsxs(l,{children:[e.jsx(p,{className:"pb-2",children:e.jsxs(u,{className:"text-sm text-muted-foreground flex items-center gap-2",children:[e.jsx(U,{className:"h-4 w-4 text-yellow-500"}),"Bekleyen"]})}),e.jsx(i,{children:e.jsx("div",{className:"text-3xl font-bold",children:c.length})})]}),e.jsxs(l,{children:[e.jsx(p,{className:"pb-2",children:e.jsxs(u,{className:"text-sm text-muted-foreground flex items-center gap-2",children:[e.jsx(O,{className:"h-4 w-4 text-green-500"}),"Onaylı"]})}),e.jsx(i,{children:e.jsx("div",{className:"text-3xl font-bold",children:o.length})})]}),e.jsxs(l,{children:[e.jsx(p,{className:"pb-2",children:e.jsxs(u,{className:"text-sm text-muted-foreground flex items-center gap-2",children:[e.jsx(X,{className:"h-4 w-4 text-red-500"}),"Reddedilen"]})}),e.jsx(i,{children:e.jsx("div",{className:"text-3xl font-bold",children:m.length})})]})]}),B?e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx(q,{className:"h-8 w-8 animate-spin text-primary"})}):e.jsxs(P,{defaultValue:"all",className:"w-full",children:[e.jsxs(R,{children:[e.jsxs(j,{value:"all","data-testid":"tab-all",children:["Tümü (",t.length,")"]}),e.jsxs(j,{value:"pending","data-testid":"tab-pending",children:["Bekleyen (",c.length,")"]}),e.jsxs(j,{value:"approved","data-testid":"tab-approved",children:["Onaylı (",o.length,")"]}),e.jsxs(j,{value:"rejected","data-testid":"tab-rejected",children:["Reddedilen (",m.length,")"]})]}),e.jsx(g,{value:"all",className:"mt-4",children:t.length===0?e.jsxs("div",{className:"text-center py-12 text-muted-foreground",children:[e.jsx(a,{className:"h-12 w-12 mx-auto mb-4 opacity-30"}),e.jsx("p",{children:"Yorum bulunamadı"})]}):t.map(s=>e.jsx(x,{comment:s},s.id))}),e.jsx(g,{value:"pending",className:"mt-4",children:c.length===0?e.jsxs("div",{className:"text-center py-12 text-muted-foreground",children:[e.jsx(a,{className:"h-12 w-12 mx-auto mb-4 opacity-30"}),e.jsx("p",{children:"Bekleyen yorum yok"})]}):c.map(s=>e.jsx(x,{comment:s},s.id))}),e.jsx(g,{value:"approved",className:"mt-4",children:o.length===0?e.jsxs("div",{className:"text-center py-12 text-muted-foreground",children:[e.jsx(a,{className:"h-12 w-12 mx-auto mb-4 opacity-30"}),e.jsx("p",{children:"Onaylı yorum yok"})]}):o.map(s=>e.jsx(x,{comment:s},s.id))}),e.jsx(g,{value:"rejected",className:"mt-4",children:m.length===0?e.jsxs("div",{className:"text-center py-12 text-muted-foreground",children:[e.jsx(a,{className:"h-12 w-12 mx-auto mb-4 opacity-30"}),e.jsx("p",{children:"Reddedilen yorum yok"})]}):m.map(s=>e.jsx(x,{comment:s},s.id))})]})]})})}export{ve 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.