import{r as t,j as e,a as b,f as E}from"./app-BZJf8lgN.js";import{L as C}from"./layout-DZ5xjWdd.js";import{B as l}from"./button.esm-D_cwsnQR.js";import{D,C as n}from"./column.esm-BrHEUUD7.js";import{D as c}from"./dialog.esm-B_DzXfDY.js";import{T as S}from"./toast.esm-CYGIlaDH.js";import T from"./AddFormNovedad-LZ0zjq6K.js";import A from"./EditFormNovedad-Bz9TaIIn.js";import{c as B,C as k}from"./confirmdialog.esm-DF1Ea2vk.js";import"./hooks.esm-UVLztt_0.js";import"./CSSTransition-DBuKQJwM.js";import"./inputtext.esm-B1lZn37a.js";import"./index.esm-mvXJc0W-.js";import"./dropdown.esm-HqLoOpxI.js";import"./overlayservice.esm-B-BnP5c1.js";import"./index.esm-hRnQzR_k.js";import"./csstransition.esm-BNRxTMOa.js";import"./index.esm-CygY3Qsw.js";import"./index.esm-Ckth6fI3.js";import"./index.esm-B5zYYMSp.js";import"./CustomCKEditor-BpmNiC9B.js";import"./fileupload.esm-CWt4e-Qk.js";import"./image.esm-DhzuK4QZ.js";import"./InputLabel-Dd3VnoK3.js";import"./message.esm-Do6SkgWF.js";const ie=({novedades:p,categorias:m})=>{const i=t.useRef(null),[u,a]=t.useState(!1),[f,o]=t.useState(!1),[h,x]=t.useState(null),[r,d]=t.useState(null),N=s=>{x(s),o(!0)},j=s=>e.jsxs(e.Fragment,{children:[" ",e.jsx(l,{type:"button",icon:"pi pi-pencil",onClick:()=>N(s)})," ",e.jsx(l,{type:"button",icon:"pi pi-times",severity:"danger",onClick:()=>w(s.id)})," "]}),v=s=>e.jsx("img",{src:`${s.imagen}`,alt:s.imagen,className:"w-6rem shadow-2 border-round"}),w=s=>{d(s)},g=()=>{E.delete(route("novedades.destroy",r),{onSuccess:()=>{i.current.show({severity:"info",summary:"Novedad Eliminada",detail:"Se ha eliminado una novedad",life:3e3})}}),d(null)},y=()=>{i.current.show({severity:"warn",summary:"Cancelado",detail:"No se ha eliminado nada",life:3e3}),d(null)};return t.useEffect(()=>{r!=null&&B({message:"Esta seguro/a que desea eliminar una novedad?",header:"Eliminar Novedad",icon:"pi pi-exclamation-triangle",defaultfocus:"accept",accept:g,reject:y})},[r]),e.jsxs(C,{children:[e.jsx(k,{}),e.jsx(c,{header:"Agregar Novedad",visible:u,style:{width:"55vw"},onHide:()=>a(!1),children:e.jsx(T,{categorias:m,toast:i,setVisibleNewNews:a})}),e.jsx(c,{header:"Editar Novedad",visible:f,style:{width:"55vw"},onHide:()=>o(!1),children:e.jsx(A,{novedad:h,categorias:m,toast:i,setVisibleEditNews:o})}),e.jsx(b,{title:"Editar Novedades"}),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(l,{onClick:()=>a(!0),className:"mb-2",children:"Agregar Novedad"})}),e.jsx(S,{ref:i}),e.jsxs(D,{value:p,tableStyle:{minWidth:"50rem"},children:[e.jsx(n,{field:"titulo",header:"Titulo"}),e.jsx(n,{field:"imagen",header:"Image",body:v}),e.jsx(n,{header:"Acciones",body:j})]})]})})})]})};export{ie as default};
//# sourceMappingURL=Novedades-CM3zb1D8.js.map
