PageSourceSearch

https://harikabirtavsiye.com/assets/admin.makaleler-BoUDMKch.js

js harikabirtavsiye.com collected 2026-10-02 01:33:58 UTC 10,553 bytes, 1 lines download raw bytes

1import{cd as O,cp as V,bR as o,c1 as d,c4 as n,aX as X,bx as s,L as m,az as J}from"./index-BCXCPzZW.js";import{r as U}from"./use-category-overrides-DKygSAYv.js";import{A as W}from"./arrow-left-Dd0eAQ7R.js";import{L as Z}from"./loader-circle-VmLf0q_B.js";import{E as K}from"./external-link-BJHjThDn.js";import{P as w}from"./pencil-BiaYOVMO.js";import{T as ee}from"./trash-2-Hrnx3PaZ.js";function ne(){const{isAdmin:b,loading:B}=O(),D=V(),[v,E]=o.useState([]),[i,x]=o.useState([]),[R,S]=o.useState(!0),[j,u]=o.useState(null),[N,T]=o.useState(""),[p,Y]=o.useState("all"),[f,q]=o.useState("all"),[h,M]=o.useState("all"),_=o.useCallback(async()=>{S(!0);const[e,t,r]=await Promise.all([d.from("content_categories").select("slug, name, emoji, is_system").order("sort_order",{ascending:!0}),d.from("blog_posts").select("id, slug, title, status, source").order("published_at",{ascending:!1,nullsFirst:!1}).limit(2e3),d.from("article_category_overrides").select("source, slug, category_slug")]);e.error&&n.error("Kategoriler yüklenemedi",{description:e.error.message}),t.error&&n.error("Yazılar yüklenemedi",{description:t.error.message}),r.error&&n.error("Atamalar yüklenemedi",{description:r.error.message});const l=e.data??[];E(l);const C=r.data??[],c=new Map;for(const a of C)c.set(`${a.source}:${a.slug}`,a.category_slug);const H=X.map(a=>{const g=`static:${a.slug}`,y=a.category||"saglikli-yasam-onerileri";return{key:g,source:"static",slug:a.slug,title:a.title,defaultCategory:y,effectiveCategory:c.get(g)??y}}),I=(t.data??[]).map(a=>{const g=a.source,y=g==="herb",z=g==="spice",L=y?"herb":z?"spice":"blog_post",$=`${L}:${a.slug}`,A=z?"baharatlar":"yazilar";return{key:$,source:L,id:a.id,slug:a.slug,title:a.title,defaultCategory:A,effectiveCategory:c.get($)??A,status:a.status}});x([...H,...I]),S(!1)},[]);o.useEffect(()=>{b&&_()},[b,_]);const F=async(e,t)=>{u(e.key);try{if(t===e.defaultCategory){const{error:r}=await d.from("article_category_overrides").delete().eq("source",e.source).eq("slug",e.slug);if(r)throw r}else{const{error:r}=await d.from("article_category_overrides").upsert({source:e.source,slug:e.slug,category_slug:t},{onConflict:"source,slug"});if(r)throw r}x(r=>r.map(l=>l.key===e.key?{...l,effectiveCategory:t}:l)),U(D),n.success("Kategori güncellendi")}catch(r){const l=r instanceof Error?r.message:String(r);n.error("Değiştirilemedi",{description:l})}finally{u(null)}},P=async(e,t)=>{if(!(e.source==="static"||!e.id)){u(e.key);try{const r={status:t};t==="published"&&(r.published_at=new Date().toISOString());const{error:l}=await d.from("blog_posts").update(r).eq("id",e.id);if(l)throw l;x(C=>C.map(c=>c.key===e.key?{...c,status:t}:c)),n.success("Durum güncellendi")}catch(r){const l=r instanceof Error?r.message:String(r);n.error("Güncellenemedi",{description:l})}finally{u(null)}}},Q=async e=>{if(!(e.source==="static"||!e.id)&&confirm(`"${e.title}" silinsin mi? Bu işlem geri alınamaz.`)){u(e.key);try{const{error:t}=await d.from("blog_posts").delete().eq("id",e.id);if(t)throw t;x(r=>r.filter(l=>l.key!==e.key)),n.success("Yazı silindi")}catch(t){const r=t instanceof Error?t.message:String(t);n.error("Silinemedi",{description:r})}finally{u(null)}}},k=o.useMemo(()=>{const e=N.trim().toLowerCase();return i.filter(t=>!(f!=="all"&&t.source!==f||p!=="all"&&t.effectiveCategory!==p||h!=="all"&&t.status!==h||e&&!t.title.toLowerCase().includes(e)&&!t.slug.toLowerCase().includes(e)))},[i,N,p,f,h]),G=o.useMemo(()=>{const e=new Map;for(const t of i)e.set(t.effectiveCategory,(e.get(t.effectiveCategory)??0)+1);return e},[i]);return B?null:b?s.jsxs("section",{className:"container-page py-10",children:[s.jsxs(m,{to:"/admin/istatistikler",className:"inline-flex items-center gap-1.5 text-sm text-muted-foreground hover:text-foreground",children:[s.jsx(W,{className:"h-4 w-4"})," Admin"]}),s.jsxs("div",{className:"mt-4 flex flex-wrap items-end justify-between gap-3",children:[s.jsxs("div",{children:[s.jsx("h1",{className:"font-serif text-3xl",children:"Makale & Kategori Yönetimi"}),s.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:"Tüm makaleler tek listede. Kategorisini değiştirmek için satırdaki menüyü kullanın."})]}),s.jsxs("div",{className:"flex flex-wrap items-center gap-3 text-sm",children:[s.jsx(m,{to:"/admin/yazilar/yeni",className:"rounded-full bg-primary px-4 py-2 font-medium text-primary-foreground hover:bg-primary/90",children:"+ Yeni Yazı"}),s.jsx(m,{to:"/admin/kategoriler",className:"text-primary hover:underline",children:"Kategorileri yönet →"})]})]}),s.jsxs("div",{className:"mt-6 grid gap-3 sm:grid-cols-4",children:[s.jsxs("div",{className:"relative sm:col-span-1",children:[s.jsx(J,{className:"pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground"}),s.jsx("input",{value:N,onChange:e=>T(e.target.value),placeholder:"Başlık veya slug ara",className:"w-full rounded-lg border border-border bg-card py-2 pl-9 pr-3 text-sm focus:border-primary focus:outline-none"})]}),s.jsxs("select",{value:p,onChange:e=>Y(e.target.value),className:"rounded-lg border border-border bg-card px-3 py-2 text-sm",children:[s.jsxs("option",{value:"all",children:["Tüm kategoriler (",i.length,")"]}),v.map(e=>s.jsxs("option",{value:e.slug,children:[e.emoji?`${e.emoji} `:"",e.name," (",G.get(e.slug)??0,")"]},e.slug))]}),s.jsxs("select",{value:f,onChange:e=>q(e.target.value),className:"rounded-lg border border-border bg-card px-3 py-2 text-sm",children:[s.jsx("option",{value:"all",children:"Tüm kaynaklar"}),s.jsxs("option",{value:"static",children:["Statik makaleler (",i.filter(e=>e.source==="static").length,")"]}),s.jsxs("option",{value:"herb",children:["Bitki çayları (",i.filter(e=>e.source==="herb").length,")"]}),s.jsxs("option",{value:"spice",children:["Baharatlar (",i.filter(e=>e.source==="spice").length,")"]}),s.jsxs("option",{value:"blog_post",children:["Veritabanı yazıları (",i.filter(e=>e.source==="blog_post").length,")"]})]}),s.jsxs("select",{value:h,onChange:e=>M(e.target.value),className:"rounded-lg border border-border bg-card px-3 py-2 text-sm",children:[s.jsx("option",{value:"all",children:"Tüm durumlar"}),s.jsxs("option",{value:"published",children:["Yayında (",i.filter(e=>e.status==="published").length,")"]}),s.jsxs("option",{value:"draft",children:["Taslak (",i.filter(e=>e.status==="draft").length,")"]}),s.jsxs("option",{value:"archived",children:["Arşiv (",i.filter(e=>e.status==="archived").length,")"]})]})]}),s.jsx("div",{className:"mt-6",children:R?s.jsx("div",{className:"flex justify-center py-16 text-muted-foreground",children:s.jsx(Z,{className:"h-5 w-5 animate-spin"})}):s.jsxs("div",{className:"overflow-hidden rounded-xl border border-border",children:[s.jsxs("table",{className:"w-full text-sm",children:[s.jsx("thead",{className:"bg-muted/40 text-left text-xs uppercase tracking-wider text-muted-foreground",children:s.jsxs("tr",{children:[s.jsx("th",{className:"px-3 py-2",children:"Başlık"}),s.jsx("th",{className:"px-3 py-2 hidden md:table-cell",children:"Kaynak"}),s.jsx("th",{className:"px-3 py-2 w-36",children:"Durum"}),s.jsx("th",{className:"px-3 py-2 w-56",children:"Kategori"}),s.jsx("th",{className:"px-3 py-2 w-40 text-right",children:"İşlemler"})]})}),s.jsx("tbody",{children:k.slice(0,500).map(e=>s.jsxs("tr",{className:"border-t border-border align-top",children:[s.jsxs("td",{className:"px-3 py-2",children:[s.jsx("div",{className:"line-clamp-1 font-medium",children:e.title}),s.jsx("div",{className:"font-mono text-[11px] text-muted-foreground",children:e.source==="herb"?s.jsxs("span",{children:["/",e.slug]}):e.source==="spice"?s.jsxs(m,{to:"/baharatlar/$slug",params:{slug:e.slug},className:"hover:text-primary inline-flex items-center gap-1",children:["/baharatlar/",e.slug," ",s.jsx(K,{className:"h-3 w-3"})]}):e.source==="blog_post"?s.jsxs(m,{to:"/yazilar/$slug",params:{slug:e.slug},className:"hover:text-primary inline-flex items-center gap-1",children:["/",e.slug," ",s.jsx(K,{className:"h-3 w-3"})]}):s.jsxs("span",{children:["/",e.slug]})})]}),s.jsx("td",{className:"px-3 py-2 hidden md:table-cell text-muted-foreground",children:e.source==="static"?"Statik":e.source==="herb"?"Bitki çayı":e.source==="spice"?"Baharat":"DB"}),s.jsx("td",{className:"px-3 py-2",children:e.source!=="static"&&e.status?s.jsxs("select",{value:e.status,disabled:j===e.ke
1y,onChange:t=>{P(e,t.target.value)},className:"w-full rounded-lg border border-border bg-card px-2 py-1.5 text-xs focus:border-primary focus:outline-none disabled:opacity-50",children:[s.jsx("option",{value:"draft",children:"Taslak"}),s.jsx("option",{value:"published",children:"Yayında"}),s.jsx("option",{value:"archived",children:"Arşiv"})]}):s.jsx("span",{className:"text-xs text-muted-foreground",children:"—"})}),s.jsx("td",{className:"px-3 py-2",children:s.jsxs("select",{value:e.effectiveCategory,disabled:j===e.key,onChange:t=>{F(e,t.target.value)},className:"w-full rounded-lg border border-border bg-card px-2 py-1.5 text-sm focus:border-primary focus:outline-none disabled:opacity-50",children:[!v.some(t=>t.slug===e.effectiveCategory)&&s.jsxs("option",{value:e.effectiveCategory,children:["(atanmamış: ",e.effectiveCategory,")"]}),v.map(t=>s.jsxs("option",{value:t.slug,children:[t.emoji?`${t.emoji} `:"",t.name]},t.slug))]})}),s.jsx("td",{className:"px-3 py-2",children:e.source!=="static"&&e.id?s.jsxs("div",{className:"flex justify-end gap-1.5",children:[s.jsxs(m,{to:"/admin/yazilar/$id",params:{id:e.id},className:"inline-flex items-center gap-1 rounded-md border border-border px-2 py-1 text-xs hover:border-primary/40",title:"Düzenle",children:[s.jsx(w,{className:"h-3.5 w-3.5"})," Düzenle"]}),s.jsx("button",{type:"button",disabled:j===e.key,onClick:()=>{Q(e)},className:"inline-flex items-center gap-1 rounded-md border border-border px-2 py-1 text-xs hover:border-destructive hover:text-destructive disabled:opacity-50",title:"Sil",children:s.jsx(ee,{className:"h-3.5 w-3.5"})})]}):s.jsx("div",{className:"text-right text-xs text-muted-foreground",children:"Statik"})})]},e.key))})]}),k.length>500&&s.jsx("div",{className:"border-t border-border bg-muted/20 px-3 py-2 text-xs text-muted-foreground",children:"İlk 500 sonuç gösteriliyor. Arama veya filtreyle daraltın."}),k.length===0&&s.jsx("div",{className:"px-3 py-10 text-center text-sm text-muted-foreground",children:"Sonuç yok."})]})})]}):s.jsx("section",{className:"container-page py-16 text-center",children:s.jsx("h1",{className:"font-serif text-2xl",children:"Yetkisiz erişim"})})}export{ne as component};

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.