PageSourceSearch

https://pmhfullrebuild.base44.app/assets/AdminCourses-BceiBT2B.js

js pmhfullrebuild.base44.app collected 2026-10-03 03:09:24 UTC 5,185 bytes, 6 lines download raw bytes

1import{c as N,r as n,j as e,h as w,L as p,A as x,w as y,d as h}from"./index-DUpcj-SV.js";import{P as C}from"./plus-R8j7osQd.js";import{B as k}from"./book-open-CelMuqiJ.js";/**
2 * @license lucide-react v0.475.0 - ISC
3 *
4 * This source code is licensed under the ISC license.
5 * See the LICENSE file in the root directory of this source tree.
6 */const A=[["rect",{width:"20",height:"5",x:"2",y:"3",rx:"1",key:"1wp1u1"}],["path",{d:"M4 8v11a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8",key:"1s80jp"}],["path",{d:"M10 12h4",key:"a56b0p"}]],_=N("Archive",A);function L({courses:r}){const[a,o]=n.useState(!1);return r.length?e.jsxs("section",{className:"mt-14 border-t border-pmh-border pt-10",children:[e.jsxs("button",{onClick:()=>o(t=>!t),"aria-expanded":a,className:"w-full flex items-center gap-4 bg-white border border-pmh-border rounded-card p-5 text-left hover:border-pmh-border-hover transition-colors",children:[e.jsx("div",{className:"w-11 h-11 rounded-lg bg-pmh-bg-alt border border-pmh-border flex items-center justify-center flex-shrink-0",children:e.jsx(_,{className:"w-5 h-5 text-pmh-muted"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h2",{className:"text-[15px] font-bold text-pmh-navy",children:"Archived courses"}),e.jsxs("span",{className:"text-[12px] text-pmh-muted",children:[r.length," retired ",r.length===1?"programme":"programmes",", kept for reference"]})]}),e.jsx(w,{className:`w-5 h-5 text-pmh-border-hover flex-shrink-0 transition-transform ${a?"rotate-180":""}`})]}),a&&e.jsx("div",{className:"mt-3 space-y-3 pl-0 sm:pl-6",children:r.map(t=>e.jsxs(p,{to:`/admin/courses/${t.id}`,className:"group flex items-center gap-4 bg-pmh-bg-alt border border-pmh-border rounded-card px-5 py-4 hover:border-pmh-border-hover transition-colors",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h3",{className:"text-[14px] font-semibold text-pmh-navy group-hover:text-pmh-orange transition-colors truncate",children:t.title}),e.jsxs("span",{className:"text-[12px] text-pmh-muted",children:["/",t.slug]})]}),e.jsx("span",{className:"text-[11px] font-semibold uppercase tracking-[0.1em] text-pmh-muted flex-shrink-0",children:"Archived"}),e.jsx(x,{className:"w-4 h-4 text-pmh-border-hover group-hover:text-pmh-orange transition-colors flex-shrink-0"})]},t.id))})]}):null}const S=r=>r.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"");function M(){const[r,a]=n.useState(!0),[o,t]=n.useState([]),[u,l]=n.useState(!1),[i,d]=n.useState(""),c=async()=>{a(!0);const s=(await h.entities.Course.list()).sort((j,v)=>(j.sort_order||0)-(v.sort_order||0));t(s),a(!1)};n.useEffect(()=>{c()},[]);const f=async()=>{i.trim()&&(l(!0),await h.entities.Course.create({title:i.trim(),slug:S(i),status:"draft",is_private:!0,sort_order:o.length+1}),d(""),l(!1),c())},b=o.filter(s=>s.status!=="archived"),g=o.filter(s=>s.status==="archived"),m={live:"bg-pmh-orange",draft:"bg-pmh-border-hover",archived:"bg-pmh-muted"};return e.jsxs("div",{className:"min-h-screen bg-pmh-bg-warm flex flex-col",children:[e.jsx(y,{}),e.jsxs("main",{className:"flex-1 pmh-container py-12 md:py-16",children:[e.jsx("p",{className:"pmh-eyebrow mb-3",children:"Course Management"}),e.jsx("h1",{className:"pmh-h1",children:"Courses"}),e.jsx("div",{className:"w-10 h-[2px] bg-pmh-orange mt-6"}),e.jsxs("div",{className:"mt-10 bg-white border border-pmh-border rounded-card p-6 max-w-[640px]",children:[e.jsx("h2",{className:"pmh-h3",children:"Create a new course"}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-3 mt-4",children:[e.jsx("input",{value:i,onChange:s=>d(s.target.value),placeholder:"Course title",className:"pmh-input flex-1"}),e.jsxs("button",{onClick:f,disabled:u||!i.trim(),className:"pmh-btn pmh-btn-primary px-5 py-3 text-[13px] font-semibold inline-flex items-center gap-2 justify-center",children:[e.jsx(C,{className:"w-4 h-4"})," Create"]})]})]}),e.jsx("div",{className:"mt-12",children:r?e.jsx("div",{className:"flex items-center justify-center py-16",children:e.jsx("div",{className:"w-7 h-7 border-4 border-pmh-border border-t-pmh-navy rounded-full animate-spin"})}):e.jsx("div",{className:"space-y-3",children:b.map(s=>e.jsxs(p,{to:`/admin/courses/${s.id}`,className:"group flex items-center gap-4 bg-white border border-pmh-border rounded-card p-5 hover:border-pmh-orange/50 transition-colors",children:[e.jsx("div",{className:"w-11 h-11 rounded-lg bg-pmh-navy flex items-center justify-center flex-shrink-0",children:e.jsx(k,{className:"w-5 h-5 text-pmh-orange"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h3",{className:"text-[15px] font-bold text-pmh-navy group-hover:text-pmh-orange transition-colors truncate",children:s.title}),e.jsxs("span",{className:"text-[12px] text-pmh-muted",children:["/",s.slug]})]}),e.jsxs("span",{className:"inline-flex items-center gap-2 text-[11px] font-semibold uppercase tracking-[0.1em] text-pmh-muted flex-shrink-0",children:[e.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${m[s.status]||m.draft}`}),s.status]}),e.jsx(x,{className:"w-5 h-5 text-pmh-border-hover group-hover:text-pmh-orange transition-colors flex-shrink-0"})]},s.id))})}),!r&&e.jsx(L,{courses:g})]})]})}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.