1import{Q as C,u as F,r as s,j as e,c as j,a as y}from"./main-Cx62WSPe.js";import{A as v}from"./AdminHeader-D3PuqEvR.js";import{F as T,S as k}from"./FormCard-0iUgLRgA.js";import{A as E}from"./arrow-left-Do2dNtv-.js";const I=j({method:"GET"}).handler(y("6dfa013b8c4ca419238323fb498633d137ce28bced53a3ad6414add0fe33c023")),L=j({method:"POST"}).handler(y("0e7f75120e567c27b2133dda01e7b8baefec1efe87a93c712a6a60e532b6dd7f"));function D(){const{id:n}=C.useParams(),d=F(),l=n==="new",[a,c]=s.useState({name:"",title:"",bio:"",image:"",certifications:[],specialties:[],active:!0,order:0}),[N,w]=s.useState(!l),[m,u]=s.useState(!1),[b,x]=s.useState(""),[p,h]=s.useState(""),[f,g]=s.useState("");s.useEffect(()=>{l||I({data:{id:n}}).then(t=>{t&&(c({name:t.name||"",title:t.title||"",bio:t.bio||"",image:t.image||"",certifications:t.certifications||[],specialties:t.specialties||[],active:t.active??!0,order:t.order||0}),h((t.certifications||[]).join(", ")),g((t.specialties||[]).join(", "))),w(!1)})},[n,l]);function i(t,o){c(r=>({...r,[t]:o}))}async function S(t){t.preventDefault(),x(""),u(!0);const o={...a,certifications:p.split(",").map(r=>r.trim()).filter(Boolean),specialties:f.split(",").map(r=>r.trim()).filter(Boolean)};try{(await L({data:{id:l?void 0:n,values:o}})).success&&d({to:"/admin/trainers"})}catch(r){x(r instanceof Error?r.message:"Failed to save")}finally{u(!1)}}return N?e.jsxs("div",{children:[e.jsx(v,{title:"Loading..."}),e.jsx("div",{className:"p-6 text-center text-neutral-400",children:"Loading trainer data..."})]}):e.jsxs("div",{children:[e.jsx(v,{title:l?"New Trainer":`Edit: ${a.name}`,actions:e.jsxs("button",{type:"button",onClick:()=>d({to:"/admin/trainers"}),className:"inline-flex items-center gap-2 px-4 py-2 text-neutral-600 hover:text-neutral-800 text-sm font-medium rounded-lg hover:bg-neutral-100 transition-colors cursor-pointer",children:[e.jsx(E,{size:16}),"Back"]})}),e.jsxs("div",{className:"p-6 max-w-3xl",children:[b&&e.jsx("div",{className:"mb-5 p-3 bg-red-50 border border-red-200 rounded-lg text-sm text-red-600",children:b}),e.jsx("form",{onSubmit:S,children:e.jsx(T,{title:"Trainer Details",footer:e.jsxs("button",{type:"submit",disabled:m,className:"inline-flex items-center gap-2 px-5 py-2.5 bg-brand-primary-500 hover:bg-brand-primary-600 text-white text-sm font-semibold rounded-lg transition-colors disabled:opacity-50 cursor-pointer",children:[e.jsx(k,{size:16}),m?"Saving...":"Save Trainer"]}),children:e.jsxs("div",{className:"space-y-5",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-5",children:[e.jsxs("div",{children:[e.jsxs("label",{htmlFor:"name",className:"block text-sm font-semibold text-neutral-700 mb-2",children:["Name ",e.jsx("span",{className:"text-red-400",children:"*"})]}),e.jsx("input",{id:"name",type:"text",value:a.name,onChange:t=>i("name",t.target.value),required:!0,className:"w-full px-4 py-3 bg-neutral-50 border-2 border-neutral-200 rounded-xl text-neutral-700 text-sm transition-all hover:border-neutral-300 focus:border-brand-primary-500 focus:bg-white"})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"title",className:"block text-sm font-semibold text-neutral-700 mb-2",children:"Title"}),e.jsx("input",{id:"title",type:"text",value:a.title,onChange:t=>i("title",t.target.value),placeholder:"Head Coach",className:"w-full px-4 py-3 bg-neutral-50 border-2 border-neutral-200 rounded-xl text-neutral-700 text-sm transition-all hover:border-neutral-300 focus:border-brand-primary-500 focus:bg-white"})]})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"bio",className:"block text-sm font-semibold text-neutral-700 mb-2",children:"Bio"}),e.jsx("textarea",{id:"bio",value:a.bio,onChange:t=>i("bio",t.target.value),rows:4,className:"w-full px-4 py-3 bg-neutral-50 border-2 border-neutral-200 rounded-xl text-neutral-700 text-sm transition-all hover:border-neutral-300 focus:border-brand-primary-500 focus:bg-white resize-y"})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"image",className:"block text-sm font-semibold text-neutral-700 mb-2",children:"Image URL"}),e.jsx("input",{id:"image",type:"text",value:a.image,onChange:t=>i("image",t.target.value),className:"w-full px-4 py-3 bg-neutral-50 border-2 border-neutral-200 rounded-xl text-neutral-700 text-sm transition-all hover:border-neutral-300 focus:border-brand-primary-500 focus:bg-white"})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"certifications",className:"block text-sm font-semibold text-neutral-700 mb-2",children:"Certifications (comma-separated)"}),e.jsx("input",{id:"certifications",type:"text",value:p,onChange:t=>h(t.target.value),placeholder:"ÃTV Instructor, ITF Level 2",className:"w-full px-4 py-3 bg-neutral-50 border-2 border-neutral-200 rounded-xl text-neutral-700 text-sm transition-all hover:border-neutral-300 focus:border-brand-primary-500 focus:bg-white"})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"specialties",className:"block text-sm font-semibold text-neutral-700 mb-2",children:"Specialties (comma-separated)"}),e.jsx("input",{id:"specialties",type:"text",value:f,onChange:t=>g(t.target.value),placeholder:"Kids Tennis, Cardio Tennis",className:"w-full px-4 py-3 bg-neutral-50 border-2 border-neutral-200 rounded-xl text-neutral-700 text-sm transition-all hover:border-neutral-300 focus:border-brand-primary-500 focus:bg-white"})]}),e.jsxs("div",{className:"flex items-center gap-6",children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:"order",className:"block text-sm font-semibold text-neutral-700 mb-2",children:"Order"}),e.jsx("input",{id:"order",type:"number",value:a.order,onChange:t=>i("order",Number.parseInt(t.target.value)||0),min:0,className:"w-24 px-4 py-3 bg-neutral-50 border-2 border-neutral-200 rounded-xl text-neutral-700 text-sm transition-all hover:border-neutral-300 focus:border-brand-primary-500 focus:bg-white"})]}),e.jsx("div",{className:"pt-7",children:e.jsxs("label",{className:"inline-flex items-center gap-3 cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:a.active,onChange:t=>i("active",t.target.checked),className:"w-5 h-5 rounded border-2 border-neutral-300 text-brand-primary-500 focus:ring-brand-primary-500"}),e.jsx("span",{className:"text-sm font-medium text-neutral-700",children:"Active"})]})})]})]})})})]})]})}export{D 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.