PageSourceSearch

https://siripremierec.lovable.app/assets/EyewearManager-B3YYohia.js

js siripremierec.lovable.app collected 2026-10-03 03:45:37 UTC 3,002 bytes, 1 lines download raw bytes

1import{r as t,s as o,f as a,j as e,B as i}from"./index-BQfIByVV.js";import{C as l}from"./card-ByAWfDs2.js";import{P as u}from"./plus-Xp4rGIE5.js";import{E as p}from"./eye-DhqrkV_C.js";import{E as y}from"./eye-off-BiIlAe7a.js";import{S as w}from"./square-pen-DMwuzcxA.js";import{T as v}from"./trash-2-AGK49x4a.js";function F(){const[n,d]=t.useState([]),[m,x]=t.useState(!0),[N,h]=t.useState(null),[b,f]=t.useState(!1);t.useEffect(()=>{c()},[]);const c=async()=>{try{const{data:s,error:r}=await o.from("eyewear_brands").select("*").order("sort_order");if(r)throw r;d(s||[])}catch(s){console.error("Error loading brands:",s),a.error("Failed to load brands")}finally{x(!1)}},g=async s=>{try{const{error:r}=await o.from("eyewear_brands").update({is_active:!s.is_active}).eq("id",s.id);if(r)throw r;a.success(`Brand ${s.is_active?"deactivated":"activated"}`),c()}catch(r){console.error("Error toggling brand:",r),a.error("Failed to update brand")}},j=async s=>{if(confirm("Are you sure you want to delete this brand?"))try{const{error:r}=await o.from("eyewear_brands").delete().eq("id",s);if(r)throw r;a.success("Brand deleted"),c()}catch(r){console.error("Error deleting brand:",r),a.error("Failed to delete brand")}};return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-3xl font-semibold text-black mb-2",children:"Eyewear Brands"}),e.jsx("p",{className:"text-black/60",children:"Manage your eyewear brand catalog"})]}),e.jsxs(i,{onClick:()=>f(!0),children:[e.jsx(u,{className:"w-4 h-4 mr-2"}),"Add Brand"]})]}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:n.map(s=>e.jsx(l,{className:"p-4",children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsx("h3",{className:"font-semibold text-lg text-black",children:s.brand_name}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(i,{variant:"ghost",size:"sm",onClick:()=>g(s),children:s.is_active?e.jsx(p,{className:"w-4 h-4 text-green-600"}):e.jsx(y,{className:"w-4 h-4 text-gray-400"})}),e.jsx(i,{variant:"ghost",size:"sm",onClick:()=>h(s),children:e.jsx(w,{className:"w-4 h-4"})}),e.jsx(i,{variant:"ghost",size:"sm",onClick:()=>j(s.id),children:e.jsx(v,{className:"w-4 h-4 text-red-600"})})]})]}),s.description&&e.jsx("p",{className:"text-sm text-black/60",children:s.description}),e.jsxs("div",{className:"flex items-center justify-between text-xs",children:[e.jsx("span",{className:`px-2 py-1 rounded ${s.is_active?"bg-green-100 text-green-800":"bg-gray-100 text-gray-600"}`,children:s.is_active?"Active":"Inactive"}),e.jsxs("span",{className:"text-black/40",children:["Order: ",s.sort_order]})]})]})},s.id))}),n.length===0&&!m&&e.jsx(l,{className:"p-12 text-center",children:e.jsx("p",{className:"text-black/60",children:"No brands yet. Add your first brand to get started."})})]})}export{F 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.