1import{cd as M,ct as z,cp as O,bR as d,co as K,bx as e,a1 as j,ay as T,bO as Q,v as R,a0 as U,e as I,c4 as k}from"./index-BCXCPzZW.js";import{l as H,r as P,u as V,L as $,T as G}from"./member-questions.functions-BGtzqwAO.js";import{B as o,A as W,c as J,f as X,g as Z,d as q,e as ee,b as ae,a as se}from"./alert-dialog-DmgNPqkC.js";import{S as re,c as te,d as ne,a as ie,b as A}from"./select-jFFVZzzg.js";import{T as le,b as de,c as Y,a as E}from"./tabs-BeyUwrK4.js";import{P as oe}from"./PodcastNotes-D74fZ8bV.js";import{E as me}from"./external-link-BJHjThDn.js";import{R as ce}from"./refresh-cw-CImy0BJn.js";import{C as xe}from"./circle-check-CCuDqSRG.js";import{L as ue}from"./lock-keyhole-DLXvQyQI.js";import{S as ye}from"./save-Bn49rZQR.js";import{S as he}from"./send-BkIzKkU-.js";import"./index-DxgFsWMp.js";import"./index-Bg59b1IH.js";function Ye(){const{isAdmin:g,user:B}=M(),D=z(H),L=z(P),_=O(),[u,v]=d.useState("pending"),[m,y]=d.useState(0),[s,l]=d.useState(null),[t,i]=d.useState(""),[r,w]=d.useState(!1),[h,x]=d.useState(null),[N,p]=d.useState(""),n=K({queryKey:["admin-member-questions",B?.id,u,m],queryFn:()=>D({data:{status:u,offset:m}}),enabled:g,retry:!1,staleTime:15e3,gcTime:0,refetchOnWindowFocus:!1}),f=!!s&&t!==s.draft_answer;if(V({shouldBlockFn:()=>r||f&&!window.confirm("KaydedilmemiÅ yanıt taslaÄından ayrılmak istiyor musun?"),enableBeforeUnload:f||r}),!g)return null;const c=()=>!r&&(!f||window.confirm("KaydedilmemiÅ yanıt taslaÄından ayrılmak istiyor musun?"));async function S(a){if(!(!s||r)){if(a!=="draft"&&t.trim().length<10){p("Yanıt veya kapatma açıklaması en az 10 karakter olmalı.");return}w(!0),p("");try{await L({data:{id:s.id,revision:s.revision,action:a,answer:t}}),l({...s,revision:s.revision+1,draft_answer:t.trim(),...a==="draft"?{}:{answer:t.trim(),status:a==="answer"?"answered":"closed"}}),i(t.trim()),x(null),await _.invalidateQueries({queryKey:["admin-member-questions"]}),k.success(a==="draft"?"Taslak kaydedildi. Ãyeye henüz gösterilmedi.":"Yanıt üyenin hesabında açıldı.")}catch(b){const C=b instanceof Error?b.message:"";x(null),p(C.includes("baÅka bir sekmede")?C:"Yanıt kaydedilemedi. Metin korunuyor; yeniden deneyebilirsin.")}finally{w(!1)}}}const F=async a=>{try{await navigator.clipboard.writeText(`https://harikabirtavsiye.com/sor?kaynak=${a}`),k.success("PaylaÅım baÄlantısı kopyalandı.")}catch{k.error("Kopyalanamadı. BaÄlantıyı aÅaÄıdaki metinden seçebilirsin.")}};return e.jsxs("section",{className:"container-page py-9",children:[e.jsxs("div",{className:"flex flex-wrap items-end justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium text-primary",children:"Yönetim paneli"}),e.jsx("h1",{className:"mt-2 font-serif text-3xl",children:"Ãye Soruları"}),e.jsx("p",{className:"mt-2 text-base text-muted-foreground",children:"Yanıtı hazırla, ön izle ve yalnızca soruyu soran üyeye aç."})]}),e.jsxs("a",{href:"/sor",className:"inline-flex items-center gap-2 text-sm text-primary underline",children:["Ãye ekranını aç ",e.jsx(me,{className:"h-4 w-4"})]})]}),e.jsx("div",{className:"mt-6 grid gap-3 sm:grid-cols-3",children:["pending","answered","closed"].map(a=>e.jsxs("button",{type:"button",onClick:()=>{c()&&(v(a),y(0),l(null),i(""))},className:`rounded-2xl border p-4 text-left ${u===a?"border-primary bg-primary/5":"border-border bg-card"}`,children:[e.jsx("span",{className:"text-sm text-muted-foreground",children:a==="pending"?"Yanıt bekleyen":j[a]}),e.jsx("strong",{className:"mt-1 block text-2xl",children:n.data?.counts[a]??"â"})]},a))}),e.jsxs("div",{className:"mt-7 grid items-start gap-5 lg:grid-cols-[minmax(280px,0.8fr)_minmax(0,1.2fr)]",children:[e.jsxs("div",{className:"min-w-0 rounded-2xl border border-border bg-card p-4",children:[e.jsxs("div",{className:"mb-4 flex items-center gap-3",children:[e.jsxs(re,{value:u,onValueChange:a=>{c()&&(v(a),y(0),l(null),i(""))},children:[e.jsx(te,{className:"w-full","aria-label":"Soru durumu",children:e.jsx(ne,{})}),e.jsxs(ie,{children:[e.jsx(A,{value:"all",children:"Tüm sorular"}),Object.entries(j).map(([a,b])=>e.jsx(A,{value:a,children:b},a))]})]}),e.jsx(o,{type:"button",variant:"outline",size:"icon","aria-label":"Soruları yenile",disabled:n.isFetching||r,onClick:()=>{c()&&(l(null),i(""),n.refetch())},children:e.jsx(ce,{className:`h-4 w-4 ${n.isFetching?"animate-spin":""}`})})]}),n.isPending?e.jsx("p",{role:"status",className:"py-10 text-center",children:"Sorular yükleniyorâ¦"}):n.isError?e.jsx("p",{role:"alert",className:"py-6 text-base",children:"Sorular yüklenemedi. Yenile düÄmesiyle tekrar deneyin."}):n.data.items.length===0?e.jsxs("div",{className:"py-10 text-center",children:[e.jsx(xe,{className:"mx-auto h-7 w-7 text-primary"}),e.jsx("p",{className:"mt-3 text-base",children:"Bu listede henüz soru yok."})]}):e.jsx("ul",{className:"space-y-2",children:n.data.items.map(a=>e.jsx("li",{children:e.jsxs("button",{type:"button",className:`w-full rounded-xl border p-4 text-left ${s?.id===a.id?"border-primary bg-primary/5":"border-border hover:bg-muted/50"}`,onClick:()=>{s?.id===a.id||!c()||(l(a),i(a.draft_answer||a.answer),p(""))},children:[e.jsxs("span",{className:"text-xs text-muted-foreground",children:[T[a.source]," · ",Q(a.created_at)]}),e.jsx("span",{className:"mt-2 block break-words font-serif text-xl",children:a.title}),e.jsxs("span",{className:"mt-2 block text-sm text-muted-foreground",children:[a.display_name," · ",j[a.status]]}),a.draft_answer&&a.draft_answer!==a.answer&&e.jsx("span",{className:"mt-2 inline-block text-xs font-semibold text-primary",children:"Taslak yanıt var"})]})},a.id))}),(m>0||n.data?.hasMore)&&e.jsxs("div",{className:"mt-4 flex justify-between",children:[e.jsx(o,{variant:"outline",disabled:!m,onClick:()=>{c()&&(l(null),i(""),y(Math.max(0,m-20)))},children:"Ãnceki"}),e.jsx(o,{variant:"outline",disabled:!n.data?.hasMore,onClick:()=>{c()&&(l(null),i(""),y(m+20))},children:"Sonraki"})]})]}),e.jsx("div",{className:"min-w-0 rounded-2xl border border-border bg-card p-5 md:p-6",children:s?e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-sm text-primary",children:U[s.category]}),e.jsx("h2",{className:"mt-2 break-words font-serif text-2xl",children:s.title}),e.jsx("p",{className:"mt-4 whitespace-pre-wrap break-words rounded-xl bg-muted p-4 text-base leading-7",children:s.body}),e.jsxs("p",{className:"mt-3 flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(ue,{className:"h-4 w-4"})," Yalnızca soruyu soran üyeye görünür."]}
1),e.jsxs(le,{defaultValue:"write",className:"mt-6",children:[e.jsxs(de,{children:[e.jsx(Y,{value:"write",children:"Yanıtı yaz"}),e.jsx(Y,{value:"preview",children:"Ãn izle"})]}),e.jsxs(E,{value:"write",children:[e.jsx($,{htmlFor:"member-answer",className:"mb-2 mt-4 block text-sm",children:"Yanıtın veya kapatma açıklaman"}),e.jsx(G,{id:"member-answer",value:t,onChange:a=>i(a.target.value),maxLength:12e3,rows:12,disabled:r,className:"text-base leading-7",placeholder:"Yanıtını yaz. İlgili site yazılarını [baÅlık](https://...) biçiminde ekleyebilirsin."}),e.jsx("p",{className:"mt-2 text-sm text-muted-foreground",children:"Markdown ve baÄlantılar desteklenir. KiÅiye özel teÅhis veya ilaç dozu yazmayın; gerektiÄinde saÄlık profesyoneline yönlendirin."})]}),e.jsx(E,{value:"preview",children:e.jsx("div",{className:"prose min-h-48 max-w-none break-words rounded-xl border border-border p-4 text-base leading-7 dark:prose-invert",children:t.trim()?e.jsx(oe,{text:t}):e.jsx("p",{children:"Ãn izleme için yanıt yaz."})})})]}),N&&e.jsx("p",{role:"alert",className:"mt-4 rounded-xl border border-destructive/30 p-3 text-sm text-destructive",children:N}),e.jsxs("div",{className:"mt-5 flex flex-wrap gap-3",children:[e.jsxs(o,{variant:"outline",disabled:r,onClick:()=>{S("draft")},children:[e.jsx(ye,{className:"h-4 w-4"})," TaslaÄı kaydet"]}),e.jsxs(o,{disabled:r||t.trim().length<10,onClick:()=>x("answer"),children:[e.jsx(he,{className:"h-4 w-4"})," Yanıtı üyeye aç"]}),e.jsx(o,{variant:"ghost",disabled:r||t.trim().length<10,onClick:()=>x("close"),children:"Açıklamayla kapat"})]})]}):e.jsxs("div",{className:"py-16 text-center",children:[e.jsx(R,{className:"mx-auto h-9 w-9 text-primary"}),e.jsx("h2",{className:"mt-4 font-serif text-2xl",children:"Bir soru seç"}),e.jsx("p",{className:"mt-2 text-base text-muted-foreground",children:"Soruyu oku, yanıtını hazırlamaya baÅla."})]})})]}),e.jsxs("details",{className:"mt-7 rounded-2xl border border-border bg-card p-5",children:[e.jsx("summary",{className:"cursor-pointer font-medium",children:"Sosyal medya yönlendirme baÄlantıları"}),e.jsx("p",{className:"mt-4 text-base leading-7",children:"âSorular yorumlarda kaybolmasın. Harika Bir Tavsiyeâde Bize Sor bölümünden sorunu gönder, yanıtını hesabından takip et.â"}),["youtube","instagram"].map(a=>e.jsxs("div",{className:"mt-4 flex flex-wrap items-center justify-between gap-2 rounded-xl bg-muted p-3",children:[e.jsxs("span",{className:"min-w-0 break-all text-sm",children:["https://harikabirtavsiye.com/sor?kaynak=",a]}),e.jsxs(o,{size:"sm",variant:"outline",onClick:()=>{F(a)},children:[e.jsx(I,{className:"h-4 w-4"})," ",T[a]," linki"]})]},a)),e.jsx("p",{className:"mt-3 text-sm leading-6 text-muted-foreground",children:"YouTube kanal profiline ve uzun video açıklamasına; Instagram profil baÄlantısına ve Hikâye baÄlantı çıkartmasına ekleyebilirsin. Shorts açıklamasındaki URL tıklanmaz: kanal profiline yönlendir."})]}),e.jsx(W,{open:!!h,onOpenChange:a=>{!a&&!r&&x(null)},children:e.jsxs(J,{children:[e.jsxs(X,{children:[e.jsx(Z,{children:h==="close"?"Soruyu açıklamayla kapat":"Yanıtı üyeye aç"}),e.jsx(q,{children:"YazdıÄın metin soruyu soran üyenin hesabında hemen görünür. Herkese açık yayımlanmaz ve e-posta gönderilmez."})]}),e.jsxs(ee,{children:[e.jsx(ae,{disabled:r,children:"Vazgeç"}),e.jsx(se,{disabled:r,onClick:a=>{a.preventDefault(),h&&S(h)},children:r?"Kaydediliyorâ¦":"Onayla"})]})]})})]})}export{Ye 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.