import{q as O,r as a,S as q,j as e,a as z,f as C}from"./app-BZJf8lgN.js";import{T as H}from"./toast.esm-CYGIlaDH.js";import{B as s}from"./button.esm-D_cwsnQR.js";import{L as M}from"./layout-DZ5xjWdd.js";import{D as R,C as f}from"./column.esm-BrHEUUD7.js";import{D as j}from"./dialog.esm-B_DzXfDY.js";import{I as n}from"./inputtext.esm-B1lZn37a.js";import{c as F,C as P}from"./confirmdialog.esm-DF1Ea2vk.js";import{M as w}from"./message.esm-Do6SkgWF.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 de=({categoriaVibraChocs:S})=>{const{errors:i}=O().props,o=a.useRef(null),{reset:N}=q(),[E,c]=a.useState(!1),[V,d]=a.useState(!1),[m,y]=a.useState({orden:"",titulo:""}),[r,b]=a.useState({id:null,orden:"",titulo:""}),[l,u]=a.useState(null),[U,W]=a.useState(1),D=t=>e.jsxs(e.Fragment,{children:[" ",e.jsx(s,{type:"button",icon:"pi pi-pencil",onClick:()=>T(t)})," ",e.jsx(s,{type:"button",icon:"pi pi-times",severity:"danger",onClick:()=>L(t.id)})," "]}),T=t=>{b(t),d(!0)},k=()=>{console.log(l),C.delete(route("categoria-vibra-chocs.destroy",l),{onSuccess:()=>{o.current.show({severity:"info",summary:"Categoria Eliminada",detail:"Se ha eliminado una categoria vibra choc",life:3e3})}}),u(null)},A=()=>{o.current.show({severity:"warn",summary:"Cancelado",detail:"No se ha eliminado nada",life:3e3}),u(null)},x=t=>{const g=t.target.name,h=t.target.value;y(p=>({...p,[g]:h}))},v=t=>{const g=t.target.name,h=t.target.value;b(p=>({...p,[g]:h}))},I=t=>{t.preventDefault(),C.post(route("categoria-vibra-chocs.store"),m,{onSuccess:()=>{o.current.show({severity:"success",summary:"Exito",detail:"Categoria Vibra Choc Agregada",life:3e3}),y({orden:"",titulo:""}),c(!1)}})},B=t=>{t.preventDefault(),console.log(r),C.post(route("categoria-vibra-chocs.update",r.id),{...r,_method:"put",preserveState:!1},{onSuccess:()=>{o.current.show({severity:"success",summary:"Exito",detail:"Categoria Vibra Choc Actualizada",life:3e3}),N()}}),d(!1)},L=t=>{console.log(t),u(t)};return a.useEffect(()=>{l!=null&&F({message:"Esta seguro/a que desea eliminar una categoria vibra choc?",header:"Eliminar Categoria Vibra Choc",icon:"pi pi-exclamation-triangle",defaultfocus:"accept",accept:k,reject:A})},[l]),e.jsxs(M,{children:[e.jsx(j,{header:"Agregar Categoria Vibra Choc",visible:E,style:{width:"50vw"},onHide:()=>c(!1),children:e.jsxs("form",{onSubmit:I,children:[e.jsx(n,{name:"orden",placeholder:"Orden",value:m.orden,className:"w-full mb-2",onChange:x}),i.orden&&e.jsx(w,{severity:"error",text:i.orden}),e.jsx(n,{name:"titulo",placeholder:"Titulo",value:m.titulo,className:"w-full mb-2",onChange:x}),i.titulo&&e.jsx(w,{severity:"error",text:i.titulo}),e.jsx(s,{type:"submit",className:"mt-5",style:{display:"block",margin:"auto"},children:"Agregar Categoria Vibra Choc"})]})}),e.jsx(j,{header:"Editar Categoria Vibra Choc",visible:V,style:{width:"50vw"},onHide:()=>d(!1),children:e.jsxs("form",{onSubmit:B,children:[e.jsx(n,{name:"orden",placeholder:"Orden",value:r.orden,className:"w-full mb-2",onChange:v}),e.jsx(n,{name:"titulo",placeholder:"Titulo",value:r.titulo,className:"w-full mb-2",onChange:v}),e.jsx(s,{type:"submit",className:"mt-5",style:{display:"block",margin:"auto"},children:"Actualizar Categoria Vibra Choc"})]})}),e.jsx(P,{}),e.jsx(z,{title:"Editar Categoria Vibra Chocs"}),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(s,{onClick:()=>c(!0),className:"mb-2",children:"Agregar Categoria Vibra Choc"})}),e.jsx(H,{ref:o}),e.jsxs(R,{value:S,tableStyle:{minWidth:"50rem"},children:[e.jsx(f,{field:"orden",header:"Orden"}),e.jsx(f,{field:"titulo",header:"Titulo"}),e.jsx(f,{header:"Acciones",body:D})]})]})})})]})};export{de as default};
//# sourceMappingURL=CategoriaVibraChocs-B2ZoLqod.js.map
