1import{r as a,b9 as v,ba as k,bb as V,bc as S,d as t,j as e,ae as U,bd as w,B as i,I as u}from"./index-Djb4nDM2.js";import{C as D,a as L,b as P,c as z}from"./card-DsZ4G796.js";import{D as T,a as B,c as F,d as Y,b as I}from"./dialog-DU7Jgi03.js";import{L as m}from"./label-IDLx24iy.js";import{P as O}from"./plus-CvKDTqOb.js";import{S as R}from"./square-pen-DnFPXAm4.js";import{T as G}from"./trash-2-ayynsDbv.js";import{E as M}from"./external-link-B8_Dsf0a.js";const X=function(){a.useEffect(()=>{console.log("EducationalVideosComponent mounted")},[]);const{data:d,isPending:g,error:c}=v(),h=k(),x=V(),b=S();a.useEffect(()=>{c&&(console.error("List fetch error:",c),t.error("Videolar yüklenirken hata oluÅtu"))},[c]);const[y,l]=a.useState(!1),[n,p]=a.useState(null),[r,o]=a.useState({title:"",youtubeUrl:"",orderNo:0}),N=(d==null?void 0:d.data)??[],j=s=>{s?(p(s),o({title:s.title,youtubeUrl:s.youtubeUrl,orderNo:s.orderNo})):(p(null),o({title:"",youtubeUrl:"",orderNo:0})),l(!0)},C=()=>{if(console.log("Saving video...",r),!r.title||!r.youtubeUrl){t.error("BaÅlık ve URL zorunludur");return}n?x.mutate({id:n.id,body:r},{onSuccess:()=>{l(!1),t.success("Video güncellendi")},onError:s=>{console.error("Update error:",s),t.error("Güncelleme sırasında hata oluÅtu")}}):h.mutate(r,{onSuccess:()=>{l(!1),t.success("Video eklendi")},onError:s=>{console.error("Create error:",s),t.error("Ekleme sırasında hata oluÅtu")}})},E=s=>{confirm("Bu videoyu silmek istediÄinize emin misiniz?")&&b.mutate(s)};return e.jsxs(U,{routeId:w.id,title:"EÄitim Videoları",children:[e.jsx("div",{className:"flex justify-end mb-4",children:e.jsxs(i,{onClick:()=>j(),children:[e.jsx(O,{className:"w-4 h-4 mr-2"}),"Yeni Video Ekle"]})}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:g?e.jsx("p",{children:"Yükleniyor..."}):N.map(s=>{var f;return e.jsxs(D,{children:[e.jsxs(L,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(P,{className:"text-sm font-medium",children:s.title}),e.jsxs("div",{className:"flex gap-1",children:[e.jsx(i,{variant:"ghost",size:"icon",onClick:()=>j(s),children:e.jsx(R,{className:"w-4 h-4"})}),e.jsx(i,{variant:"ghost",size:"icon",onClick:()=>E(s.id),children:e.jsx(G,{className:"w-4 h-4 text-destructive"})})]})]}),e.jsxs(z,{children:[e.jsx("div",{className:"aspect-video bg-muted rounded-md flex items-center justify-center mb-2",children:e.jsx("img",{src:`https://img.youtube.com/vi/${((f=s.youtubeUrl.split("v=")[1])==null?void 0:f.split("&")[0])||s.youtubeUrl.split("/").pop()}/0.jpg`,className:"w-full h-full object-cover rounded-md",alt:s.title})}),e.jsxs("div",{className:"flex justify-between items-center text-xs text-muted-foreground",children:[e.jsxs("span",{children:["Sıra: ",s.orderNo]}),e.jsxs("a",{href:s.youtubeUrl,target:"_blank",rel:"noopener noreferrer",className:"flex items-center hover:text-primary",children:["YouTube'da Aç ",e.jsx(M,{className:"w-3 h-3 ml-1"})]})]})]})]},s.id)})}),e.jsx(T,{open:y,onOpenChange:l,children:e.jsxs(B,{children:[e.jsx(F,{children:e.jsx(Y,{children:n?"Videoyu Düzenle":"Yeni Video Ekle"})}),e.jsxs("div",{className:"grid gap-4 py-4",children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx(m,{htmlFor:"title",children:"Video BaÅlıÄı"}),e.jsx(u,{id:"title",value:r.title,onChange:s=>o({...r,title:s.target.value}),placeholder:"Ãrn: Sefer Nasıl Eklenir?"})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(m,{htmlFor:"url",children:"YouTube URL"}),e.jsx(u,{id:"url",value:r.youtubeUrl,onChange:s=>o({...r,youtubeUrl:s.target.value}),placeholder:"https://www.youtube.com/watch?v=..."})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(m,{htmlFor:"order",children:"Görüntüleme Sırası"}),e.jsx(u,{id:"order",type:"number",value:r.orderNo,onChange:s=>o({...r,orderNo:parseInt(s.target.value)||0})})]})]}),e.jsxs(I,{children:[e.jsx(i,{variant:"outline",onClick:()=>l(!1),children:"İptal"}),e.jsx(i,{onClick:C,disabled:h.isPending||x.isPending,children:n?"Güncelle":"Kaydet"})]})]})})]})};export{X 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.