1import{r as c,l as k,v as A,s as d,j as e,b as m,B as r,m as _,ab as u,E as C}from"./index-YktK68x2.js";import{u as E,S as D}from"./useBatchTranslate-BZ-QR31P.js";import{u as P}from"./useAdminAuth-BCCNENTY.js";import{u as T}from"./useResizeExistingImages-DPDzM6RD.js";import{W as z}from"./WorkshopHeader-BVXFFXQz.js";import{A as S,a as I,b as L,c as F,d as B,e as H,f as O,g as R,h as q}from"./alert-dialog-CWlM-CL4.js";import{I as G}from"./image-BKz0lsU2.js";import{L as $}from"./languages-CAIrEwzw.js";import{P as U}from"./plus-BVIWU_Ud.js";import{G as V}from"./grip-vertical-COYDoxQT.js";import{E as W}from"./eye-off-B8Eu_372.js";import{E as J}from"./eye-D5va168V.js";import{T as K}from"./trash-2-DBIeK1g2.js";import"./imageOptimizer-BYuS8Das.js";import"./clock-CtJY-xOX.js";const de=()=>{const[i,f]=c.useState([]),[j,b]=c.useState(!0),o=k(),{toast:a}=A(),{isLoading:l}=P();c.useEffect(()=>{l||n()},[l]);const{translateUntranslated:N,translating:p,progress:h}=E({entityType:"portfolio_item",tableName:"portfolio_items",fields:["title","hook","description"]}),{resizeAllImages:v,resizing:x,progress:g}=T(),n=async()=>{const{data:s,error:t}=await d.from("portfolio_items").select("id, title, slug, hook, description, category, status, published, sort_order, project_url, start_date, end_date, is_ongoing").order("end_date",{ascending:!1,nullsFirst:!0}).order("start_date",{ascending:!1});t?a({title:"Error loading portfolio items",description:t.message,variant:"destructive"}):f(s||[]),b(!1)},w=async s=>{const{error:t}=await d.from("portfolio_items").update({published:!s.published}).eq("id",s.id);t?a({title:"Error updating portfolio item",description:t.message,variant:"destructive"}):(a({title:s.published?"Portfolio item hidden":"Portfolio item visible"}),n())},y=async s=>{const{error:t}=await d.from("portfolio_items").delete().eq("id",s);t?a({title:"Error deleting portfolio item",description:t.message,variant:"destructive"}):(a({title:"Portfolio item deleted"}),n())};return l||j?e.jsx("div",{className:"min-h-screen bg-background flex items-center justify-center",children:e.jsx(m,{className:"h-8 w-8 animate-spin text-primary"})}):e.jsxs("div",{className:"min-h-screen bg-background",children:[e.jsx(z,{}),e.jsxs("div",{className:"container mx-auto px-6 py-4 flex items-center justify-between border-b border-border",children:[e.jsx("h1",{className:"text-xl font-serif",children:"Portfolio"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(r,{variant:"outline",onClick:v,disabled:x||i.length===0,title:"Resize all portfolio images to 1920px width",children:x?e.jsxs(e.Fragment,{children:[e.jsx(m,{className:"h-4 w-4 animate-spin mr-2"}),g.current,"/",g.total]}):e.jsxs(e.Fragment,{children:[e.jsx(G,{className:"h-4 w-4 mr-2"}),"Optimize Images"]})}),e.jsx(r,{variant:"outline",onClick:()=>N(i),disabled:p||i.length===0,children:p?e.jsxs(e.Fragment,{children:[e.jsx(m,{className:"h-4 w-4 animate-spin mr-2"}),h.current,"/",h.total]}):e.jsxs(e.Fragment,{children:[e.jsx($,{className:"h-4 w-4 mr-2"}),"Translate All"]})}),e.jsxs(r,{onClick:()=>o("/workshop/portfolio/new"),children:[e.jsx(U,{className:"h-4 w-4 mr-2"}),"New Project"]})]})]}),e.jsx("main",{className:"container mx-auto px-6 py-12",children:e.jsx(_.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{duration:.5},children:i.length===0?e.jsxs("div",{className:"text-center py-16",children:[e.jsx("p",{className:"text-muted-foreground mb-4",children:"No portfolio items yet"}),e.jsx(r,{onClick:()=>o("/workshop/portfolio/new"),children:"Create your first project"})]}):e.jsx("div",{className:"space-y-4",children:i.map((s,t)=>e.jsxs("div",{className:"bg-card border border-border rounded-lg p-4 flex items-center gap-4",children:[e.jsx("div",{className:"text-muted-foreground",children:e.jsx(V,{className:"h-5 w-5"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1 flex-wrap",children:[e.jsxs("span",{className:"text-primary font-serif",children:[String(t+1).padStart(2,"0"),"."]}),e.jsx("h3",{className:"font-medium truncate cursor-pointer hover:text-primary transition-colors",onClick:()=>o(`/workshop/portfolio/${s.id}`),children:s.title}),e.jsx("span",{className:`text-xs px-2 py-0.5 rounded ${u[s.status]||u.Idea}`,children:s.status}),s.published?e.jsx("span",{className:"text-xs bg-green-500/20 text-green-500 px-2 py-0.5 rounded",children:"Visible"}):e.jsx("span",{className:"text-xs bg-yellow-500/20 text-yellow-500 px-2 py-0.5 rounded",children:"Hidden"})]}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:[s.category," ⢠",s.slug]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[s.project_url&&e.jsx(r,{variant:"ghost",size:"icon",asChild:!0,children:e.jsx("a",{href:s.project_url,target:"_blank",rel:"noopener noreferrer",children:e.jsx(C,{className:"h-4 w-4"})})}),e.jsx(r,{variant:"ghost",size:"icon",onClick:()=>w(s),title:s.published?"Hide":"Show",children:s.published?e.jsx(W,{className:"h-4 w-4"}):e.jsx(J,{className:"h-4 w-4"})}),e.jsx(r,{variant:"ghost",size:"icon",onClick:()=>o(`/workshop/portfolio/${s.id}`),children:e.jsx(D,{className:"h-4 w-4"})}),e.jsxs(S,{children:[e.jsx(I,{asChild:!0,children:e.jsx(r,{variant:"ghost",size:"icon",children:e.jsx(K,{className:"h-4 w-4 text-destructive"})})}),e.jsxs(L,{children:[e.jsxs(F,{children:[e.jsx(B,{children:"Delete portfolio item?"}),e.jsx(H,{children:"This action cannot be undone. This will permanently delete the project."})]}),e.jsxs(O,{children:[e.jsx(R,{children:"Cancel"}),e.jsx(q,{onClick:()=>y(s.id),children:"Delete"})]})]})]})]})]},s.id))})})})]})};export{de 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.