1import{p as y,r as a,j as e,B as n,b as o}from"./index-B1fkcL_P.js";import{I as x}from"./input-JBLMkcuP.js";import{D,a as E,b as S,c as B}from"./dialog-Do0njY4c.js";import{L as m}from"./label-BF002xLv.js";import{S as k}from"./skeleton-G8XUtL-g.js";import{P}from"./plus-LijQTUTJ.js";import{P as T}from"./pencil-yS0qN-gp.js";import{T as z}from"./trash-2-CG7rCHW9.js";import"./index-DJ9UtBJM.js";import"./index-Cdw-_ZsZ.js";import"./index-C2wsBu6S.js";import"./Combination-q4ljoD0p.js";import"./index-BpZdkG7y.js";import"./index-BQU9N9q7.js";function U(){const{toast:c}=y(),[h,u]=a.useState([]),[p,j]=a.useState(!0),[w,r]=a.useState(!1),[l,g]=a.useState(null),[s,i]=a.useState({name:"",slug:"",description:"",icon:"",image_url:""}),d=async()=>{u(await o.entities.Category.list("order",100)),j(!1)};a.useEffect(()=>{d()},[]);const N=()=>{g(null),i({name:"",slug:"",description:"",icon:"",image_url:""}),r(!0)},f=t=>{g(t),i({...t}),r(!0)},v=async()=>{l?(await o.entities.Category.update(l.id,s),c({title:"Categoria atualizada!"})):(await o.entities.Category.create(s),c({title:"Categoria criada!"})),r(!1),d()},C=async t=>{confirm("Excluir?")&&(await o.entities.Category.delete(t),c({title:"ExcluÃda!"}),d())};return p?e.jsx("div",{className:"space-y-3",children:[...Array(4)].map((t,b)=>e.jsx(k,{className:"h-14 bg-white/5 rounded-xl"},b))}):e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-6",children:[e.jsx("h1",{className:"text-2xl font-heading font-bold text-white",children:"Categorias"}),e.jsxs(n,{onClick:N,className:"bg-[#6D5DFB] hover:bg-[#5B4DE8] text-white rounded-xl",children:[e.jsx(P,{className:"w-4 h-4 mr-2"})," Nova"]})]}),e.jsxs("div",{className:"space-y-2",children:[h.map(t=>
1e.jsxs("div",{className:"flex items-center gap-4 rounded-xl bg-[#1C1C1C] border border-white/5 p-4",children:[e.jsx("span",{className:"text-lg",children:t.icon||"ð"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"text-sm font-medium text-white",children:t.name}),e.jsx("p",{className:"text-xs text-white/30",children:t.slug})]}),e.jsx(n,{size:"icon",variant:"ghost",onClick:()=>f(t),className:"text-white/30 hover:text-white h-8 w-8",children:e.jsx(T,{className:"w-4 h-4"})}),e.jsx(n,{size:"icon",variant:"ghost",onClick:()=>C(t.id),className:"text-white/30 hover:text-red-400 h-8 w-8",children:e.jsx(z,{className:"w-4 h-4"})})]},t.id)),h.length===0&&e.jsx("p",{className:"text-center text-white/30 text-sm py-10",children:"Nenhuma categoria."})]}),e.jsx(D,{open:w,onOpenChange:r,children:e.jsxs(E,{className:"bg-[#1C1C1C] border-white/10 max-w-md",children:[e.jsx(S,{children:e.jsxs(B,{className:"text-white font-heading",children:[l?"Editar":"Nova"," Categoria"]})}),e.jsxs("div",{className:"space-y-4 pt-2",children:[e.jsxs("div",{children:[e.jsx(m,{className:"text-white/60 text-xs",children:"Nome"}),e.jsx(x,{value:s.name,onChange:t=>i({...s,name:t.target.value}),className:"bg-[#141414] border-white/10 text-white"})]}),e.jsxs("div",{children:[e.jsx(m,{className:"text-white/60 text-xs",children:"Slug"}),e.jsx(x,{value:s.slug,onChange:t=>i({...s,slug:t.target.value}),className:"bg-[#141414] border-white/10 text-white"})]}),e.jsxs("div",{children:[e.jsx(m,{className:"text-white/60 text-xs",children:"Ãcone (emoji)"}),e.jsx(x,{value:s.icon,onChange:t=>i({...s,icon:t.target.value}),className:"bg-[#141414] border-white/10 text-white"})]}),e.jsx(n,{onClick:v,className:"w-full bg-[#6D5DFB] hover:bg-[#5B4DE8] text-white rounded-xl",children:l?"Salvar":"Criar"})]})]})})]})}export{U as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.