1import{r as c,j as e,L as b,b0 as j,y as n,aO as i}from"./index-CzMEFmtw.js";import{P as v,a as N,C as x}from"./ui-BklIU2Vp.js";import{M as w}from"./MediaPicker-D2IJuFJa.js";import{a as g}from"./blog-DP5q8ac2.js";import{P as y}from"./plus-DZqQktxt.js";import{S as _}from"./save-Bu384Y2v.js";import{T as A}from"./trash-2-gzkfqCHP.js";import"./file-video-DCRmgGhD.js";import"./image-DUijihr1.js";import"./upload-C1EWCH4L.js";const u="w-full h-10 px-3 rounded-lg border border-gray-200 text-sm bg-white text-gray-900 placeholder:text-gray-400 focus:outline-none focus:border-[#F9A01B]";function M(){const[l,m]=c.useState([]),[d,s]=c.useState(!0),a=async()=>{s(!0);const{data:t}=await n.from("blog_authors").select("*").order("name");m(t??[]),s(!1)};c.useEffect(()=>{a()},[]);const r=async()=>{var h;const t=(h=prompt("Author name:"))==null?void 0:h.trim();if(!t)return;const{error:o}=await n.from("blog_authors").insert({name:t,slug:g(t)});if(o)return i.error(o.message);a()},p=async t=>{const{error:o}=await n.from("blog_authors").update({name:t.name,slug:t.slug||g(t.name),avatar_url:t.avatar_url,bio:t.bio}).eq("id",t.id);if(o)return i.error(o.message);i.success("Saved"),a()},f=async t=>{if(!confirm("Delete this author? Posts will keep their content but lose the author link."))return;const{error:o}=await n.from("blog_authors").delete().eq("id",t);if(o)return i.error(o.message);a()};return e.jsxs(v,{children:[e.jsx(N,{title:"Blog authors",actions:e.jsxs(e.Fragment,{children:[e.jsxs(b,{to:"/admin/blog",className:"h-9 px-3 rounded-lg border border-gray-300 text-sm font-semibold flex items-center gap-1.5 hover:bg-gray-50",children:[e.jsx(j,{className:"w-4 h-4"})," Back"]}),e.jsxs("button",{onClick:r,className:"h-9 px-3 rounded-lg bg-[#F9A01B] text-white text-sm font-semibold flex items-center gap-1.5",children:[e.jsx(y,{className:"w-4 h-4"})," Add author"]})]})}),d?e.jsx("div",{className:"text-sm text-gray-500",children:"Loadingâ¦"}):l.length===0?e.jsx(x,{className:"p-10 text-center text-sm text-gray-500",children:"No authors yet. Add one to get started."}):e.jsx("div",{className:"space-y-3",children:l.map(t=>e.jsx(C,{initial:t,onSave:p,onDelete:()=>f(t.id)},t.id))})]})}function C({initial:l,onSave:m,onDelete:d}){const[s,a]=c.useState(l);return e.jsxs(x,{className:"p-4 grid md:grid-cols-[auto_1fr_1fr_auto] gap-3 items-start",children:[e.jsx("div",{className:"w-14",children:e.jsx(w,{value:s.avatar_url,onChange:r=>a({...s,avatar_url:r})})}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("input",{className:u,value:s.name,onChange:r=>a({...s,name:r.target.value}),placeholder:"Name"}),e.jsx("input",{className:u,value:s.slug,onChange:r=>a({...s,slug:g(r.target.value)}),placeholder:"slug"})]}),e.jsx("textarea",{rows:3,className:u+" h-auto py-2",value:s.bio??"",onChange:r=>a({...s,bio:r.target.value}),placeholder:"Short bio"}),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsxs("button",{onClick:()=>m(s),className:"h-9 px-3 rounded-lg bg-gray-900 text-white text-sm font-semibold flex items-center gap-1.5",children:[e.jsx(_,{className:"w-4 h-4"})," Save"]}),e.jsxs("button",{onClick:d,className:"h-9 px-3 rounded-lg text-sm font-semibold text-red-600 hover:bg-red-50 flex items-center gap-1.5",children:[e.jsx(A,{className:"w-4 h-4"})," Delete"]})]})]})}export{M 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.