1import{av as B,u as G,r as d,j as e,L as i,aw as H,ax as q,ay as J,az as K,aA as O}from"./main-Bo0oayNO.js";function U(){const{series:M,pagination:c,counts:g}=B.useLoaderData(),{status:r,page:x,search:n}=B.useSearch(),m=G(),[y,v]=d.useState(null),[k,w]=d.useState(null),[S,I]=d.useState(n),[a,p]=d.useState([]),[C,D]=d.useState(!1),[L,$]=d.useState(!1),[N,T]=d.useState("title"),[j,P]=d.useState("asc"),l=r==="trash",f=t=>{N===t?P(j==="asc"?"desc":"asc"):(T(t),P("asc"))},b=({field:t})=>e.jsx("span",{className:"ml-1 inline-block",children:N===t?j==="asc"?e.jsx("svg",{className:"w-4 h-4 inline",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 15l7-7 7 7"})}):e.jsx("svg",{className:"w-4 h-4 inline",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})}):e.jsx("svg",{className:"w-4 h-4 inline opacity-30",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M7 16V4m0 0L3 8m4-4l4 4m6 0v12m0 0l4-4m-4 4l-4-4"})})}),R=async(t,s)=>{const o=l?`Permanently delete series "${s}"? This cannot be undone.`:`Move series "${s}" to trash?`;if(confirm(o)){v(t);try{l?await K({data:t}):await O({data:t}),m({to:"/admin/series",search:{status:r,page:1,search:n}})}finally{v(null)}}},F=async(t,s)=>{if(confirm(`Restore series "${s}"?`)){w(t);try{await J({data:t}),m({to:"/admin/series",search:{status:r,page:1,search:n}})}finally{w(null)}}},V=t=>{t.target.checked?p(u.map(s=>s.id)):p([])},W=t=>{p(s=>s.includes(t)?s.filter(o=>o!==t):[...s,t])},A=async()=>{if(a.length===0)return;const t=l?`Permanently delete ${a.length} series? This cannot be undone.`:`Move ${a.length} series to trash?`;if(confirm(t)){D(!0);try{await q({data:a}),p([]),m({to:"/admin/series",search:{status:r,page:1,search:n}})}finally{D(!1)}}},E=async()=>{if(a.length!==0&&confirm(`Restore ${a.length} series?`)){$(!0);try{await H({data:a}),p([]),m({to:"/admin/series",search:{status:r,page:1,search:n}})}finally{$(!1)}}},z=t=>{t.preventDefault(),m({to:"/admin/series",search:{status:r,page:1,search:S}})},u=[...M].sort((t,s)=>{let o,h;switch(N){case"title":o=t.title.toLowerCase(),h=s.title.toLowerCase();break;case"slug":o=t.slug.toLowerCase(),h=s.slug.toLowerCase();break;case"postCount":o=t.postCount,h=s.postCount;break;case"status":o=t.status,h=s.status;break}return o<h?j==="asc"?-1:1:o>h?j==="asc"?1:-1:0});return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold text-gray-900",children:l?"Trash":"Series"}),e.jsx("p",{className:"text-gray-600",children:l?"Deleted series":"Group related posts into content series"})]}),!l&&e.jsxs(i,{to:"/admin/series/new",className:"btn-primary",children:[e.jsx("svg",{className:"w-4 h-4 mr-2",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 4v16m8-8H4"})}),"New Series"]})]}),e.jsxs("div",{className:"flex gap-4 border-b border-gray-200",children:[e.jsxs(i,{to:"/admin/series",search:{status:"all",page:1,search:""},className:`pb-2 px-1 text-sm font-medium border-b-2 ${r==="all"?"border-primary-500 text-primary-600":"border-transparent text-gray-500 hover:text-gray-700"}`,children:["All (",g.all,")"]}),e.jsxs(i,{to:"/admin/series",search:{status:"draft",page:1,search:""},className:`pb-2 px-1 text-sm font-medium border-b-2 ${r==="draft"?"border-primary-500 text-primary-600":"border-transparent text-gray-500 hover:text-gray-700"}`,children:["Draft (",g.draft,")"]}),e.jsxs(i,{to:"/admin/series",search:{status:"published",page:1,search:""},className:`pb-2 px-1 text-sm font-medium border-b-2 ${r==="published"?"border-primary-500 text-primary-600":"border-transparent text-gray-500 hover:text-gray-700"}`,children:["Published (",g.published,")"]}),e.jsxs(i,{to:"/admin/series",search:{status:"trash",page:1,search:""},className:`pb-2 px-1 text-sm font-medium border-b-2 ${r==="trash"?"border-primary-500 text-primary-600":"border-transparent text-gray-500 hover:text-gray-700"}`,children:["Trash (",g.trash,")"]})]}),e.jsxs("div",{className:"flex gap-4 items-center",children:[e.jsxs("form",{onSubmit:z,className:"relative flex-1 max-w-md",children:[e.jsx("svg",{className:"absolute left-3 top-1/2 -translate-y-1/2 w-5 h-5 text-gray-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"})}),e.jsx("input",{type:"text",placeholder:"Search series...",value:S,onChange:t=>I(t.target.value),className:"input pl-10"})]}),a.length>0&&e.jsxs(e.Fragment,{children:[l&&e.jsx("button",{onClick:E,disabled:L,className:"btn-secondary",children:L?"Restoring...":`Restore ${a.length} selected`}),e.jsx("button",{onClick:A,disabled:C,className:"btn-danger",children:C?"Deleting...":l?`Delete ${a.length} permanently`:`Delete ${a.length} selected`})]})]}),e.jsx("div",{className:"card overflow-hidden",children:e.jsxs("table",{className:"min-w-full divide-y divide-gray-200",children:[e.jsx("thead",{className:"bg-gray-50",children:e.jsxs("tr",{children:[e.jsx("th",{className:"px-6 py-3 w-4",children:e.jsx("input",{type:"checkbox",checked:u.length>0&&u.every(t=>a.includes(t.id)),onChange:V,className:"rounded-sm border-gray-300 text-primary-600 focus:ring-primary-500"})}),e.jsxs("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider cursor-pointer hover:text-gray-700",onClick:()=>f("title"),children:["Title",e.jsx(b,{field:"title"})]}),e.jsxs("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider cursor-pointer hover:text-gray-700",onClick:()=>f("slug"),children:["Slug",e.jsx(b,{field:"slug"})]}),e.jsxs("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider cursor-pointer hover:text-gray-700",onClick:()=>f("postCount"),children:["Posts",e.jsx(b,{field:"postCount"})]}),e.jsxs("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider cursor-pointer hover:text-gray-700",onClick:()=>f("status"),children:["Status",e.jsx(b,{field:"status"})]}),e.jsx("th",{className:"px-6 py-3 text-right text-xs font-medium text-gray-500 uppercase tracking-wider",children:"Actions"})]})}),e.jsx("tbody",{className:"bg-white divide-y divide-gray-200",children:u.length===0?e.jsx("tr",{children:e.jsx("td",{colSpan:6,className:"px-6 py-12 text-center text-gray-500",children:n?"No series match your search.":l?"Trash is empty.":"No series found. Create your first series!"})}):u.map(t=>e.jsxs("tr",{className:"hover:bg-gray-50",children:[e.jsx("td",{className:"px-6 py-4",children:e.jsx("input",{type:"checkbox",checked:a.includes(t.id),onChange:()=>W(t.id),className:"rounded-sm border-gray-300 text-primary-600 focus:ring-primary-500"})}),e.jsxs("td",{className:"px-6 py-4",children:[e.jsx(i,{to:"/admin/series/$id",params:{id:t.id},className:"text-gray-900 font-medium hover:text-primary-600",children:t.title}),t.description&&e.jsx("p",{className:"text-sm text-gray-500 truncate max-w-xs",children:t.description})]}),e.jsx("td",{className:"px-6 py-4 text-sm text-gray-600",children:t.slug}),e.jsx("td",{className:"px-6 py-4 text-sm text-gray-600",children:t.postCount}),e.jsx("td",{className:"px-6 py-4",children:e.jsx("span",{className:`inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium ${t.status==="published"?"bg-green-100 text-green-800":"bg-yellow-100 text-yellow-800"}`,children:t.status})}),e.jsx("td",{className:"px-6 py-4 text-right space-x-2",children:l?e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:()=>F(t.id,t.title),disabled:k===t.id,className:"text-primary-600 hover:text-primary-900 text-sm font-medium disabled:opacity-50",children:k===t.id?"Restoring...":"Restore"}),e.jsx("button",{onClick:()=>R(t.id,t.title),disabled:y===t.id,className:"text-red-600 hover:text-red-900 text-sm font-medium disabled:opacity-50",children:y===t.id?"Deleting...":"Delete Permanently"})]}):e.jsxs(e.Fragment,{children:[e.jsx(i,{to:"/admin/series/$id",params:{id:t.id},className:"text-primary-600 hover:text-primary-900 text-sm font-medium",children:"Edit"}),e.jsx("button",{onClick:()=>R(t.id,t.title),disabled:y===t.id,className:"text-red-600 hover:text-red-900 text-sm font-medium disabled:opacity-50",children:y===t.id?"Deleting...":"Delete"})]})})]},t.id))})]})}),c.totalPages>1&&e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("p",{className:"text-sm text-gray-600",children:["Page ",c.page," of ",c.totalPages," (",c.total," total)"]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(i,{to:"/admin/series",search:{status:r,page:1,search:n},className:`px-3 py-1 text-sm border rounded hover:bg-gray-50 ${x===1?"opacity-50 pointer-events-none":""}`,children:"First"}),e.jsx(i,{to:"/admin/series",search:{status:r,page:Math.max(1,x-1),search:n},className:`px-3 py-1 text-sm border rounded hover:bg-gray-50 ${x===1?"opacity-50 pointer-events-none":""}`,children:"Previous"}),e.jsxs("span",{className:"px-3 py-1 text-sm",children:["Page ",x," of ",c.totalPages]}),e.jsx(i,{to:"/admin/series",search:{status:r,page:Math.min(c.totalPages,x+1),search:n},className:`px-3 py-1 text-sm border rounded hover:bg-gray-50 ${x===c.totalPages?"opacity-50 pointer-events-none":""}`,children:"Next"}),e.jsx(i,{to:"/admin/series",search:{status:r,page:c.totalPages,search:n},className:`px-3 py-1 text-sm border rounded hover:bg-gray-50 ${x===c.totalPages?"opacity-50 pointer-events-none":""}`,children:"Last"})]})]})]})}export{U as component};
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.