1import{j as e}from"./vendor-query-mRUVVlhg.js";import{r as l,L as i}from"./vendor-react-CKoz3VOj.js";import{f,k as n}from"./app-BOhSan5S.js";import{B as o}from"./button-CpE_6BY_.js";import{a5 as v,w,a6 as y,ab as _}from"./vendor-ui-CUITn4_j.js";import"./vendor-supabase-Dr6rXejQ.js";const E=()=>{const[r,g]=l.useState([]),[j,d]=l.useState(!0),c=async()=>{d(!0);const{data:s,error:a}=await f.from("realisations").select("id, title, category, status, display_order, realisation_photos(url, is_favorite)").order("display_order",{ascending:!0});a&&n.error(a.message),g((s||[]).map(t=>{var m,u,x,h,p;return{id:t.id,title:t.title,category:t.category,status:t.status,photo_count:((m=t.realisation_photos)==null?void 0:m.length)||0,cover:((x=(u=t.realisation_photos)==null?void 0:u.find(b=>b.is_favorite))==null?void 0:x.url)||((p=(h=t.realisation_photos)==null?void 0:h[0])==null?void 0:p.url)||null}})),d(!1)};l.useEffect(()=>{c()},[]);const N=async s=>{if(!window.confirm("Supprimer cette réalisation et toutes ses photos ?"))return;const{error:a}=await f.from("realisations").delete().eq("id",s);if(a)return n.error(a.message);n.success("Réalisation supprimée"),c()};return e.jsxs("div",{children:[e.jsxs("header",{className:"flex items-center justify-between mb-6",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-3xl font-heading text-foreground",children:"Réalisations"}),e.jsxs("p",{className:"text-muted-foreground font-body mt-1",children:[r.length," projet",r.length>1?"s":""]})]}),e.jsx(o,{asChild:!0,children:e.jsxs(i,{to:"/admin/realisations/new",children:[e.jsx(v,{className:"w-4 h-4 mr-1"})," Nouveau projet"]})})]}),j?e.jsx("p",{className:"text-muted-foreground",children:"Chargementâ¦"}):r.length===0?e.jsxs("div",{className:"bg-card border rounded-xl p-12 text-center",children:[e.jsx("p",{className:"text-muted-foreground mb-4",children:"Aucune réalisation"}),e.jsx(o,{asChild:!0,children:e.jsx(i,{to:"/admin/realisations/new",children:"Créer la première réalisation"})})]}):e.jsx("div",{className:"grid sm:grid-cols-2 lg:grid-cols-3 gap-4",children:r.map(s=>e.jsxs("div",{className:"bg-card border rounded-xl overflow-hidden group",children:[e.jsxs(i,{to:`/admin/realisations/${s.id}`,className:"block relative h-40 bg-muted",children:[s.cover?e.jsx("img",{src:s.cover,alt:s.title,className:"w-full h-full object-cover"}):e.jsx("div",{className:"flex items-center justify-center h-full text-muted-foreground text-sm",children:"Pas de photo"}),e.jsxs("span",{className:"absolute top-2 left-2 text-xs bg-background/90 px-2 py-0.5 rounded flex items-center gap-1",children:[e.jsx(w,{className:"w-3 h-3 text-amber-500"})," ",s.photo_count]}),s.status==="draft"&&e.jsx("span",{className:"absolute top-2 right-2 text-xs bg-amber-100 text-amber-700 px-2 py-0.5 rounded",children:"Brouillon"})]}),e.jsxs("div",{className:"p-3",children:[e.jsx("div",{className:"text-xs text-muted-foreground",children:s.category}),e.jsx("h3",{className:"font-heading text-sm text-foreground line-clamp-1",children:s.title}),e.jsxs("div",{className:"flex gap-1 mt-2",children:[e.jsx(o,{variant:"ghost",size:"sm",asChild:!0,className:"flex-1",children:e.jsxs(i,{to:`/admin/realisations/${s.id}`,children:[e.jsx(y,{className:"w-3 h-3 mr-1"})," Ãditer"]})}),e.jsx(o,{variant:"ghost",size:"sm",onClick:()=>N(s.id),className:"text-destructive",children:e.jsx(_,{className:"w-4 h-4"})})]})]})]},s.id))})]})};export{E 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.