PageSourceSearch

https://faf.co.ao/assets/AdminCategories-DuhRHMbz.js

js faf.co.ao collected 2026-10-02 19:09:48 UTC 4,502 bytes, 1 lines download raw bytes

1import{r as n,s as v,b as w,j as e,L as m}from"./vendor-react-core-_0sZDOLQ.js";import{c as x,B as r,b as C}from"./index-j07E1qHv.js";import{C as h,a as p}from"./card-DHmBnTdH.js";import{I as g}from"./input-rti45mgP.js";import{L as u}from"./label-7HT5__eZ.js";import{t as i}from"./index-CDqomOa1.js";import{m as j}from"./vendor-framer-motion-C1oRD-X5.js";import{_ as A,$ as c,a0 as N,a1 as E}from"./vendor-lucide-Ddz0eB7N.js";import"./vendor-radix-CFmJ1img.js";import"./vendor-utils-BRu4i-LD.js";import"./vendor-supabase-Ca6cp8v2.js";function K(){const[P,D]=n.useState(null),[s,o]=n.useState({name:"",description:""}),[L,S]=n.useState({});v();const{data:l=[]}=w({queryKey:["all-products"],queryFn:()=>C.entities.Product.list()}),d=[...new Set(l.map(a=>a.category).filter(Boolean))].map(a=>({id:a,name:a,count:l.filter(t=>t.category===a).length})),y=()=>{if(!s.name){i.error("Por favor insira o nome da categoria");return}i.success(`Categoria "${s.name}" adicionada`),o({name:"",description:""})},b=a=>{const t=l.filter(f=>f.category===a);if(t.length>0){i.error(`Não é possível eliminar: ${t.length} produtos usam esta categoria`);return}i.success(`Categoria "${a}" eliminada`)};return e.jsxs("main",{className:"min-h-screen bg-gray-50",children:[e.jsx("section",{className:"bg-gradient-to-br from-gray-900 via-gray-800 to-black py-20",children:e.jsx("div",{className:"container mx-auto px-4",children:e.jsxs(j.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},className:"text-center text-white",children:[e.jsx(m,{to:x("Admin"),children:e.jsxs(r,{variant:"ghost",className:"text-white hover:bg-white/10 mb-4",children:[e.jsx(A,{className:"w-4 h-4 mr-2"}),"Voltar ao Admin"]})}),e.jsx(c,{className:"w-16 h-16 mx-auto mb-4"}),e.jsx("h1",{className:"text-4xl md:text-5xl font-bold mb-4",children:"Gestão de Categorias"}),e.jsx("p",{className:"text-xl text-white/90",children:"Organize os produtos da loja por categorias"})]})})}),e.jsx("section",{className:"py-8 bg-white border-b",children:e.jsx("div",{className:"container mx-auto px-4",children:e.jsx(h,{className:"border-0 shadow-lg",children:e.jsxs(p,{className:"p-6",children:[e.jsxs("h2",{className:"text-xl font-bold text-gray-900 mb-4 flex items-center gap-2",children:[e.jsx(N,{className:"w-5 h-5"}),"Adicionar Nova Categoria"]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[e.jsxs("div",{children:[e.jsx(u,{children:"Nome da Categoria"}),e.jsx(g,{placeholder:"Ex: Equipamento",value:s.name,onChange:a=>o({...s,name:a.target.value})})]}),e.jsxs("div",{children:[e.jsx(u,{children:"Descrição (opcional)"}),e.jsx(g,{placeholder:"Descrição da categoria",value:s.description,onChange:a=>o({...s,description:a.target.value})})]}),e.jsx("div",{className:"flex items-end",children:e.jsxs(r,{onClick:y,className:"w-full bg-purple-600 hover:bg-purple-700",children:[e.jsx(N,{className:"w-4 h-4 mr-2"}),"Adicionar"]})})]})]})})})}),e.jsx("section",{className:"py-12",children:e.jsxs("div",{className:"container mx-auto px-4",children:[e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6",children:d.map((a,t)=>e.jsx(j.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{delay:t*.05},children:e.jsx(h,{className:"border-0 shadow-lg hover:shadow-xl transition-shadow",children:e.jsxs(p,{className:"p-6",children:[e.jsxs("div",{className:"flex items-start justify-between mb-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-12 h-12 bg-purple-100 rounded-xl flex items-center justify-center",children:e.jsx(c,{className:"w-6 h-6 text-purple-600"})}),e.jsxs("div",{children:[e.jsx("h3",{className:"font-bold text-lg text-gray-900 capitalize",children:a.name}),e.jsxs("p",{className:"text-sm text-gray-500",children:[a.count," produtos"]})]})]}),e.jsx(r,{variant:"ghost",size:"icon",onClick:()=>b(a.name),className:"text-red-600 hover:bg-red-50",children:e.jsx(E,{className:"w-4 h-4"})})]}),e.jsx("div",{className:"pt-4 border-t",children:e.jsx(m,{to:x("AdminProducts"),children:e.jsx(r,{variant:"outline",className:"w-full",children:"Ver Produtos"})})})]})})},a.id))}),d.length===0&&e.jsxs("div",{className:"text-center py-20",children:[e.jsx(c,{className:"w-20 h-20 text-gray-300 mx-auto mb-4"}),e.jsx("h3",{className:"text-xl font-semibold text-gray-900 mb-2",children:"Sem categorias"}),e.jsx("p",{className:"text-gray-500",children:"Adicione a primeira categoria para organizar os produtos"})]})]})})]})}export{K 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.