import{q as L,r as t,S as O,j as e,a as q,f as x}from"./app-BZJf8lgN.js";import{I as z}from"./InputLabel-Dd3VnoK3.js";import{T as H}from"./toast.esm-CYGIlaDH.js";import{B as r}from"./button.esm-D_cwsnQR.js";import{L as P}from"./layout-DZ5xjWdd.js";import{D as R,C as m}from"./column.esm-BrHEUUD7.js";import{D as b}from"./dialog.esm-B_DzXfDY.js";import{I as i}from"./inputtext.esm-B1lZn37a.js";import{c as F,C as U}from"./confirmdialog.esm-DF1Ea2vk.js";import"./csstransition.esm-BNRxTMOa.js";import"./hooks.esm-UVLztt_0.js";import"./CSSTransition-DBuKQJwM.js";import"./index.esm-CygY3Qsw.js";import"./index.esm-B5zYYMSp.js";import"./index.esm-hRnQzR_k.js";import"./index.esm-mvXJc0W-.js";import"./dropdown.esm-HqLoOpxI.js";import"./overlayservice.esm-B-BnP5c1.js";import"./index.esm-Ckth6fI3.js";const me=({videos:w})=>{const{errors:d}=L().props,a=t.useRef(null),{reset:j}=O(),[V,u]=t.useState(!1),[C,p]=t.useState(!1),[N,S]=t.useState({orden:"",titulo:"",codigo:""}),[s,v]=t.useState({id:null,orden:"",titulo:"",codigo:""}),[n,y]=t.useState(null),[W,_]=t.useState(1),E=o=>e.jsxs(e.Fragment,{children:[" ",e.jsx(r,{type:"button",icon:"pi pi-pencil",onClick:()=>T(o)})," ",e.jsx(r,{type:"button",icon:"pi pi-times",severity:"danger",onClick:()=>B(o.id)})," "]}),D=o=>e.jsx("iframe",{width:"302",height:"221",src:`https://www.youtube.com/embed/${o.codigo}`,frameborder:"0",allow:"accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture",allowfullscreen:!0}),T=o=>{const{imagen:c,...l}=o;v({...l,imagenPreview:o.imagen}),p(!0)},k=()=>{console.log(n),x.delete(route("videos.destroy",n),{onSuccess:()=>{a.current.show({severity:"info",summary:"Video Eliminado",detail:"Se ha eliminado un Video",life:3e3})}}),y(null)},A=()=>{a.current.show({severity:"warn",summary:"Cancelado",detail:"No se ha eliminado nada",life:3e3}),setDeleteDistributorId(null)},h=o=>{const c=o.target.name,l=o.target.value;S(f=>({...f,[c]:l}))},g=o=>{const c=o.target.name,l=o.target.value;v(f=>({...f,[c]:l}))},I=o=>{o.preventDefault(),x.post(route("videos.store"),N,{onSuccess:()=>{a.current.show({severity:"success",summary:"Exito",detail:"Video Agregado",life:3e3}),j(),u(!1)}})},X=o=>{o.preventDefault(),console.log(s),x.post(route("videos.update",s.id),{...s,_method:"put",preserveState:!1},{onSuccess:()=>{a.current.show({severity:"success",summary:"Exito",detail:"Video Actualizado",life:3e3}),j()}}),p(!1)},B=o=>{console.log(o),y(o)};return t.useEffect(()=>{n!=null&&F({message:"Esta seguro/a que desea eliminar un Video?",header:"Eliminar video",icon:"pi pi-exclamation-triangle",defaultfocus:"accept",accept:k,reject:A})},[n]),e.jsxs(P,{children:[e.jsx(b,{header:"Agregar video",visible:V,style:{width:"50vw"},onHide:()=>u(!1),children:e.jsxs("form",{onSubmit:I,children:[e.jsx(i,{name:"orden",placeholder:"Orden",className:"w-full mb-2",onChange:h}),d.orden&&e.jsx("div",{style:{color:"red"},children:d.orden}),e.jsx(i,{name:"titulo",placeholder:"Titulo",className:"w-full mb-2",onChange:h}),d.titulo&&e.jsx("div",{style:{color:"red"},children:d.titulo}),e.jsx(i,{name:"codigo",placeholder:"Codigo",tooltip:"Ejemplo: https://www.youtube.com/watch?v=XXXXX",tooltipOptions:{position:"top"},className:"w-full mb-2",onChange:h}),e.jsx(r,{type:"submit",className:"mt-5",style:{display:"block",margin:"auto"},children:"Agregar video"})]})}),e.jsx(b,{header:"Editar video",visible:C,style:{width:"50vw"},onHide:()=>p(!1),children:e.jsxs("form",{onSubmit:X,children:[e.jsx(i,{name:"orden",placeholder:"Orden",value:s.orden,className:"w-full mb-2",onChange:g}),e.jsx(i,{name:"titulo",placeholder:"Titulo",value:s.titulo,className:"w-full mb-2",onChange:g}),e.jsx(z,{children:"Codigo de Video"}),e.jsx(i,{name:"codigo",placeholder:"Codigo",value:s.codigo,className:"w-full mb-2",onChange:g}),e.jsx(r,{type:"submit",className:"mt-5",style:{display:"block",margin:"auto"},children:"Actualizar video"})]})}),e.jsx(U,{}),e.jsx(q,{title:"Editar Videos"}),e.jsx("div",{className:"grid",children:e.jsx("div",{className:"col-md-12",children:e.jsxs("div",{className:"card",children:[e.jsx("div",{className:"card-header",style:{marginLeft:"80%"},children:e.jsx(r,{onClick:()=>u(!0),className:"mb-2",children:"Agregar video"})}),e.jsx(H,{ref:a}),e.jsxs(R,{value:w,tableStyle:{minWidth:"50rem"},children:[e.jsx(m,{field:"orden",header:"Orden"}),e.jsx(m,{field:"titulo",header:"Titulo"}),e.jsx(m,{field:"url",header:"Video",body:D}),e.jsx(m,{header:"Acciones",body:E})]})]})})})]})};export{me as default};
//# sourceMappingURL=Videos-Axn_LFSK.js.map
