1import{r as b,j as e}from"./react-vendor-C-_weJGF.js";import{b as N,u as _,c as p}from"./query-DA-B5yju.js";import{B as o,s as n,a as m}from"./index-sHdJRwRo.js";import{A as y}from"./AdminLayout-83yQHb0s.js";import{I as d}from"./input-DDtkh_8z.js";import{T as w}from"./textarea-COvO_KSb.js";import{S as k}from"./switch-DmVMlHO-.js";import{C}from"./ConfirmDialog-DjQv5vKb.js";import{F as t}from"./FormField-sjggNfPQ.js";import{aD as T,as as F,a5 as M}from"./icons-BZJMmL1V.js";import"./radix-CMA3xQgM.js";import"./supabase-BppBjPB2.js";import"./motion-CfmjrLVm.js";import"./logo-BWhOaj1e.js";function D(){const c=N(),[i,u]=b.useState(null),[r,a]=b.useState({name:"",role:"",bio:"",photo_url:"",linkedin_url:"",is_visible:!0}),{data:l=[]}=_({queryKey:["admin-team"],queryFn:async()=>{const{data:s}=await n.from("team_members").select("*").order("sort_order");return s||[]}}),h=p({mutationFn:async()=>{if(!r.name.trim())throw new Error("Name is required");const s={name:r.name,role:r.role||null,bio:r.bio||null,photo_url:r.photo_url||null,linkedin_url:r.linkedin_url||null,is_visible:r.is_visible};if(i)await n.from("team_members").update(s).eq("id",i.id);else{const v=l.length>0?Math.max(...l.map(f=>f.sort_order))+1:0;await n.from("team_members").insert({...s,sort_order:v})}},onSuccess:()=>{c.invalidateQueries({queryKey:["admin-team"]}),x(),m.success(i?"Team member updated!":"Team member added!")},onError:s=>m.error(s.message)}),g=p({mutationFn:async s=>{await n.from("team_members").delete().eq("id",s)},onSuccess:()=>{c.invalidateQueries({queryKey:["admin-team"]}),m.success("Team member removed")}}),x=()=>{u(null),a({name:"",role:"",bio:"",photo_url:"",linkedin_url:"",is_visible:!0})},j=s=>{u(s),a({name:s.name,role:s.role||"",bio:s.bio||"",photo_url:s.photo_url||"",linkedin_url:s.linkedin_url||"",is_visible:s.is_visible})};return e.jsxs(y,{children:[e.jsx("div",{className:"flex items-center justify-between mb-6",children:e.jsxs("div",{children:[e.jsx("h1",{className:"font-display text-2xl font-bold",children:"Team Members"}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"Manage team members displayed on the website."})]})}),e.jsxs("div",{className:"bg-card border border-border rounded-lg p-5 mb-6 space-y-4",children:[e.jsx("h2",{className:"font-display font-semibold text-sm",children:i?"Edit Team Member":"Add Team Member"}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsx(t,{label:"Full Name",hint:"Team member's display name.",children:e.jsx(d,{value:r.name,onChange:s=>a({...r,name:s.target.value}),placeholder:"e.g. John Smith",className:"bg-secondary"})}),e.jsx(t,{label:"Role / Title",hint:"Their job title or role.",children:e.jsx(d,{value:r.role,onChange:s=>a({...r,role:s.target.value}),placeholder:"e.g. CEO & Founder",className:"bg-secondary"})})]}),e.jsx(t,{label:"Bio",hint:"A short bio (2-3 sentences).",children:e.jsx(w,{value:r.bio,onChange:s=>a({...r,bio:s.target.value}),placeholder:"Brief description...",rows:3,className:"bg-secondary"})}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsx(t,{label:"Photo URL",hint:"Upload in Media Library, paste the URL here.",children:e.jsx(d,{value:r.photo_url,onChange:s=>a({...r,photo_url:s.target.value}),placeholder:"https://...",className:"bg-secondary"})}),e.jsx(t,{label:"LinkedIn URL",hint:"Optional LinkedIn profile link.",children:e.jsx(d,{value:r.linkedin_url,onChange:s=>a({...r,linkedin_url:s.target.value}),placeholder:"https://linkedin.com/in/...",className:"bg-secondary"})})]}),r.photo_url&&e.jsx("div",{className:"rounded-md overflow-hidden border border-border w-20 h-20",children:e.jsx("img",{src:r.photo_url,alt:"Preview",className:"w-full h-full object-cover"})}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(k,{checked:r.is_visible,onCheckedChange:s=>a({...r,is_visible:s})}),e.jsx("span",{className:"text-sm text-muted-foreground",children:"Visible on website"})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(o,{onClick:()=>h.mutate(),disabled:h.isPending,children:[e.jsx(T,{className:"w-4 h-4 mr-1"})," ",i?"Update":"Add"," Member"]}),i&&e.jsx(o,{variant:"outline",onClick:x,children:"Cancel"})]})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:[l.map(s=>e.jsxs("div",{className:"bg-card border border-border rounded-lg overflow-hidden",children:[s.photo_url?e.jsx("div",{className:"aspect-video overflow-hidden",children:e.jsx("img",{src:s.photo_url,alt:s.name,className:"w-full h-full object-cover"})}):e.jsx("div",{className:"aspect-video bg-muted/30 flex items-center justify-center",children:e.jsx(F,{className:"w-8 h-8 text-muted-foreground
1/30"})}),e.jsxs("div",{className:"p-4",children:[e.jsxs("div",{className:"flex items-center justify-between mb-1",children:[e.jsx("h3",{className:"font-medium text-sm",children:s.name}),!s.is_visible&&e.jsx("span",{className:"text-xs bg-muted px-2 py-0.5 rounded text-muted-foreground",children:"Hidden"})]}),s.role&&e.jsx("p",{className:"text-xs text-primary",children:s.role}),s.bio&&e.jsx("p",{className:"text-xs text-muted-foreground mt-2 line-clamp-2",children:s.bio}),e.jsxs("div",{className:"flex gap-1 mt-3",children:[e.jsx(o,{variant:"ghost",size:"sm",onClick:()=>j(s),children:"Edit"}),e.jsx(C,{trigger:e.jsx(o,{variant:"ghost",size:"sm",children:e.jsx(M,{className:"w-4 h-4 text-destructive"})}),onConfirm:()=>g.mutate(s.id),title:"Remove team member?",description:"This person will be removed from the website."})]})]})]},s.id)),l.length===0&&e.jsx("p",{className:"text-sm text-muted-foreground text-center py-8 col-span-full",children:"No team members yet. Add your first one above."})]})]})}export{D 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.