import{r as s,S as D,j as e,a as E,J as L,f as i}from"./app-BZJf8lgN.js";import{c as k,C as I}from"./confirmdialog.esm-DF1Ea2vk.js";import{I as R}from"./inputtext.esm-B1lZn37a.js";import{L as q}from"./layout-DZ5xjWdd.js";import{B as u}from"./button.esm-D_cwsnQR.js";import{D as B,C as n,P as _}from"./column.esm-BrHEUUD7.js";import{T as F}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"./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 re=({dataEquipos:r})=>{const c=s.useRef(null),p=r.data,[a,l]=s.useState(null),[h,g]=s.useState((r.current_page-1)*r.per_page),[f,x]=s.useState(r.per_page);D({page:r.current_page});const[d,j]=s.useState(()=>new URLSearchParams(window.location.search).get("search")||""),y=t=>{t.key==="Enter"&&N(d)},P=t=>{i.visit(route("equipos.edit",t))},w=t=>{l(t)},v=t=>e.jsx("img",{src:`${t.imagen}`,alt:t.imagen,className:"w-6rem shadow-2 border-round"}),S=t=>e.jsxs(e.Fragment,{children:[" ",e.jsx(u,{type:"button",icon:"pi pi-pencil",onClick:()=>P(t.id)})," ",e.jsx(u,{type:"button",icon:"pi pi-times",severity:"danger",onClick:()=>w(t.id)})," "]}),b=()=>{console.log(a),i.delete(route("equipos.destroy",a),{onSuccess:()=>{c.current.show({severity:"info",summary:"Producto Eliminado",detail:"Se ha eliminado un Producto",life:3e3})}}),l(null)},C=()=>{c.current.show({severity:"warn",summary:"Cancelado",detail:"No se ha eliminado nada",life:3e3}),l(null)};s.useEffect(()=>{a!=null&&k({message:"Esta seguro/a que desea eliminar un Equipo?",header:"Eliminar Equipo",icon:"pi pi-exclamation-triangle",defaultfocus:"accept",accept:b,reject:C})},[a]);const N=t=>{let o=route("productos.index");const m=[];t&&m.push(`search=${encodeURIComponent(t)}`),o+=m.length>0?`?${m.join("&")}`:"",i.get(o,{preserveState:!0,preserveScroll:!0})},T=t=>{const o=t.page+1;g(t.first),x(t.rows),i.get(route("equipos.index",{page:o,search:d}),{preserveState:!0,preserveScroll:!0})};return e.jsxs(q,{children:[e.jsx(I,{}),e.jsx(E,{title:"Editar Equipos"}),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 mb-2",children:e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[e.jsx(R,{className:"form-control",placeholder:"Buscar por Titulo",value:d,onChange:t=>j(t.target.value),onKeyDown:y}),e.jsx(L,{href:route("equipos.create"),className:"p-button mb-2 text-white",children:"Agregar Equipo"})]})}),e.jsx(F,{ref:c}),e.jsxs(B,{value:p,tableStyle:{minWidth:"50rem"},children:[e.jsx(n,{field:"orden",header:"Orden"}),e.jsx(n,{field:"titulo",header:"Titulo"}),e.jsx(n,{field:"imagen",header:"Image",body:v}),e.jsx(n,{header:"Acciones",body:S})]}),e.jsx("div",{className:"card",children:e.jsx(_,{first:h,rows:f,totalRecords:r.total,onPageChange:T,template:"FirstPageLink PrevPageLink PageLinks NextPageLink LastPageLink RowsPerPageDropdown"})})]})})})]})};export{re as default};
//# sourceMappingURL=Equipos-BwmYs2Y4.js.map
