import{a as o,W as f,j as e}from"./BulkImageUpload-DGPbX05r.js";import{A as g}from"./Authenticated-DQno4VYw.js";import{P as p}from"./PageTitle-feHaMeNG.js";import{P as b}from"./Panel-CCKAj23D.js";import i from"./CategoryForm-EMJPCNpz.js";import{E as C}from"./EditModel--5YmZ-em.js";import{M as N}from"./bootstrap.esm-e_F80uXB.js";import{S as d}from"./sweetalert2.all-CGGHY7K6.js";import"./Input-CR3dcIBA.js";const F=a=>{const[r,E]=o.useState(a.category),[l,c]=o.useState([]),[m,x]=o.useState([]),{put:u,delete:h}=f(),j=t=>()=>{var s=new N(document.getElementById("myModal"));s.show(),x(s),c(r[t])},y=t=>()=>{d.fire({title:"Are you sure want to Delete?",icon:"warning",showCancelButton:!0,confirmButtonText:"Yes, delete!"}).then(s=>{s.isConfirmed&&h(route("category.destroy",t),{onSuccess:()=>{d.fire("Deleted!","Category Removed Successfully","success")},preserveState:!1})})},n=t=>()=>{r[t].featured=!r[t].featured,u(route("update-category-featured",r[t]))};return e.jsxs(g,{auth:a.auth,errors:a.errors,current:a.current,children:[e.jsx(p,{title:"Manage Category",path:"Category",pathurl:""}),e.jsxs(b,{title:"Add Category",md:"6",children:[e.jsx(i,{typ:"add",edit:""}),e.jsx("div",{className:"table-responsive-md",children:e.jsx("table",{className:"table",children:e.jsxs("tbody",{children:[e.jsxs("tr",{children:[e.jsx("th",{className:"slno text-center",children:"ID"}),e.jsx("th",{children:"Icon"}),e.jsx("th",{children:"Category Name"}),e.jsx("th",{children:"Featured"}),e.jsx("th",{className:"text-end pe-5",children:"Action"})]}),r&&r.map((t,s)=>e.jsxs("tr",{children:[e.jsx("td",{className:"slno text-center",children:t.id}),e.jsx("td",{className:"caticon",children:e.jsx("img",{src:t.icon,alt:t.icon})}),e.jsx("td",{children:t.name}),e.jsx("td",{className:"center",children:t.featured==0?e.jsx("i",{onClick:n(s),className:"bi text-primary fs-4 bi-toggle-off"}):e.jsx("i",{onClick:n(s),className:"bi text-primary fs-4 bi-toggle-on"})}),e.jsxs("td",{className:"text-end pe-3 action",children:[e.jsxs("button",{onClick:j(s),className:"btn btn-primary btn-xs",children:[e.jsx("i",{className:"bi bi-pencil-square"})," Edit"]}),e.jsxs("button",{onClick:y(t.id),className:"btn btn-danger btn-xs",children:[e.jsx("i",{className:"bi bi-trash"})," Delete"]})]})]},s))]})})})]}),e.jsx(C,{title:"Edit Location",id:"editlocation",children:e.jsx(i,{typ:"edit",edit:l,mymodel:m})})]})};export{F as default};
