import{r as a,j as e,a as f,J as n,f as x}from"./app-BZJf8lgN.js";import{c as h,C as j}from"./confirmdialog.esm-DF1Ea2vk.js";import{L as g}from"./layout-DZ5xjWdd.js";import{B as l}from"./button.esm-D_cwsnQR.js";import{D as b,C as t}from"./column.esm-BrHEUUD7.js";import{T as N}from"./toast.esm-CYGIlaDH.js";import"./dialog.esm-B_DzXfDY.js";import"./csstransition.esm-BNRxTMOa.js";import"./hooks.esm-UVLztt_0.js";import"./CSSTransition-DBuKQJwM.js";import"./index.esm-hRnQzR_k.js";import"./overlayservice.esm-B-BnP5c1.js";import"./inputtext.esm-B1lZn37a.js";import"./index.esm-mvXJc0W-.js";import"./dropdown.esm-HqLoOpxI.js";import"./index.esm-CygY3Qsw.js";import"./index.esm-Ckth6fI3.js";import"./index.esm-B5zYYMSp.js";const W=({proyectos:c})=>{const o=a.useRef(null),[s,i]=a.useState(null),m=r=>{i(r)},d=r=>e.jsx("img",{src:`${r.imagen}`,alt:r.imagen,className:"w-10rem shadow-2 border-round"}),p=r=>e.jsxs(e.Fragment,{children:[e.jsx(n,{href:route("proyectos.edit",r.id),className:" mr-2",children:e.jsx(l,{type:"button",icon:"pi pi-pencil"})}),e.jsx(l,{type:"button",icon:"pi pi-times",severity:"danger",className:"p-button-icon-only",onClick:()=>m(r.id)})]}),u=()=>{x.delete(route("proyectos.destroy",s),{onSuccess:()=>{o.current.show({severity:"info",summary:"Proyecto Eliminado",detail:"Se ha eliminado un Proyecto",life:3e3})},onError:r=>{console.error("Error deleting project:",r),o.current.show({severity:"error",summary:"Error",detail:"Ocurrió un error al eliminar el proyecto.",life:3e3})}}),i(null)},y=()=>{o.current.show({severity:"warn",summary:"Cancelado",detail:"No se ha eliminado ningún proyecto",life:3e3}),i(null)};return a.useEffect(()=>{s!=null&&h({message:"¿Está seguro/a que desea eliminar este proyecto?",header:"Eliminar Proyecto",icon:"pi pi-exclamation-triangle",accept:u,reject:y})},[s]),e.jsxs(g,{children:[e.jsx(j,{}),e.jsx(f,{title:"Proyectos"}),e.jsx("div",{className:"grid",children:e.jsx("div",{className:"col-md-12",children:e.jsxs("div",{className:"card",children:[e.jsxs("div",{className:"card-header pb-2",style:{display:"flex",justifyContent:"flex-end"},children:[" ",e.jsx(n,{href:route("proyectos.create"),className:"p-button  p-button-primary",children:"Agregar Proyecto"})]}),e.jsx(N,{ref:o}),e.jsxs(b,{value:c,tableStyle:{minWidth:"50rem"},children:[e.jsx(t,{field:"orden",header:"Orden"}),e.jsx(t,{field:"nombre",header:"Nombre"}),e.jsx(t,{field:"imagen",header:"Imagen",body:d}),e.jsx(t,{header:"Acciones",body:p})]})]})})})]})};export{W as default};
//# sourceMappingURL=Index-DO5xxt4m.js.map
