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