1import{a as m,j as e}from"./query-vendor-BB0JUlq_.js";import{e as F,d as M}from"./react-vendor-BIjsaQ6L.js";import{_ as T,a as O}from"./index-CVuSjWCq.js";import{g as G}from"./unsplash-gQ5iVEsL.js";import"./ui-vendor-CwH6wFZJ.js";function L({mode:n,onSuccess:h,campaignId:c,referringTeacherId:d,trialId:p}){const[t,r]=m.useState({name:"",email:"",password:"",confirmPassword:"",phone:"",dob:"",address:"",parentName:"",parentEmail:"",parentPhone:"",emergencyContacts:"",allergies:"",medications:"",instruments:[],band:"",marketingConsent:!1,experience:"",goals:"",availability:"",additionalInfo:""}),[b,j]=m.useState(""),[v,i]=m.useState(""),[y,o]=m.useState(!1),[N,P]=m.useState(null),[g,S]=m.useState(null);m.useEffect(()=>{(async()=>{const a=["music education","learning music","music school","piano lessons","guitar lessons"];let s=null;for(let l of a)if(s=await G(l),s)break;P(s)})(),n==="qr"&&d&&(async()=>{try{const{apiFetch:a}=await T(async()=>{const{apiFetch:l}=await import("./api-CyvozDRd.js");return{apiFetch:l}},[]),s=await a(`/api/admin/teachers/${d}`);s&&S(s)}catch(a){console.error("Failed to load teacher info:",a)}})()},[n,d]);const I=["Piano","Keyboard","Guitar","Bass Guitar","Drums","Voice","Singing"],_=()=>{b&&!t.instruments.includes(b)&&(r(a=>({...a,instruments:[...a.instruments,b]})),j(""))},q=a=>{r(s=>({...s,instruments:s.instruments.filter(l=>l!==a)}))},w=a=>{if(!a)return null;const s=new Date(a),l=new Date;let f=l.getFullYear()-s.getFullYear();const u=l.getMonth()-s.getMonth();return(u<0||u===0&&l.getDate()<s.getDate())&&f--,f},A=async a=>{if(a.preventDefault(),i(""),o(!0),n!=="admin"){if(!t.name||!t.email||!t.phone||!t.dob){i("Please fill in all required fields"),o(!1);return}if(!t.password){i("Please create a password for your account"),o(!1);return}if(t.password.length<8){i("Password must be at least 8 characters long"),o(!1);return}if(t.password!==t.confirmPassword){i("Passwords do not match"),o(!1);return}if(t.instruments.length===0){i("Please select at least one instrument"),o(!1);return}const s=w(t.dob);if(s!==null&&s<5){i("Students must be at least 5 years old"),o(!1);return}}else if(!t.name||!t.email){i("Name and email are required"),o(!1);return}try{const s=t.dob?w(t.dob):null,l={name:t.name,email:t.email,phone:t.phone,age:s,address:t.address,parent_name:t.parentName,parent_email:t.parentEmail,parent_phone:t.parentPhone,emergency_contacts:t.emergencyContacts,allergies:t.allergies,medications:t.medications,instruments:t.instruments,band:t.band,marketing_consent:t.marketingConsent,intake_status:n==="admin"?"active":"pending",intake_submitted_at:new Date().toISOString(),intake_source:n==="qr"?"qr":n==="trial"?"trial":n==="website"?"website":"admin"};n!=="admin"&&t.password&&(l.password=t.password),c&&(l.campaign_id=c),d&&(l.referring_teacher_id=d),p&&n==="trial"&&(l.trial_id=p);const u=await fetch(n==="admin"?"/api/admin/students":"/api/public/students",{method:"POST",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify(l)});if(!u.ok){const x=await u.json();throw new Error(x.error||"Failed to submit application")}const k=await u.json(),C=k.id||k.studentId;if(c&&C)try{const x=window.localStorage.getItem("marketing_session")||Math.random().toString(36).substring(7);await fetch(`/api/public/marketing/${c}/convert`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({studentId:C,sessionId:x})})}catch(x){console.error("Failed to track conversion:",x)}h&&h()}catch(s){console.error("Intake submission error:",s),i(s?.message||"Failed to submit application")}finally{o(!1)}},D={admin:"Add Student",website:"Student Application",trial:"Book Free Trial Lesson",qr:"Student Application"},E={admin:"Quick entry for new students",website:"Please complete this form to start your musical journey with In Tune Music Tuition",trial:"Fill out this form to book your free trial lesson",qr:"Please complete this form to start your musical journey with In Tune Music Tuition"};return e.jsx("div",{className:"min-h-screen py-8",style:{backgroundImage:N?`linear-gradient(rgba(2,6,23,0.5), rgba(2,6,23,0.5)), url(${N})`:void 0,backgroundSize:"cover"},children:e.jsx("div",{className:"container mx-auto px-4 max-w-4xl",children:e.jsxs("div",{className:"bg-card/95 rounded-lg p-8 shadow-lg",children:[e.jsxs("div",{className:"text-center mb-8",children:[e.jsx("h1",{className:"text-3xl font-bold",children:D[n]}
1),e.jsx("p",{className:"text-foreground/70 mt-2",children:E[n]}),n==="qr"&&g&&e.jsx("div",{className:"mt-4 p-3 bg-blue-50 dark:bg-blue-900/20 border border-blue-200 dark:border-blue-800 rounded-lg",children:e.jsxs("p",{className:"text-sm text-blue-900 dark:text-blue-100",children:["ð Referred by ",e.jsx("strong",{children:g.name})," (",g.instruments?.join(", ")||"Music Teacher",")"]})}),n==="trial"&&e.jsx("div",{className:"mt-4 p-3 bg-green-50 dark:bg-green-900/20 border border-green-200 dark:border-green-800 rounded-lg",children:e.jsx("p",{className:"text-sm text-green-900 dark:text-green-100",children:"ðµ Complete this form to book your free trial lesson"})})]}),e.jsxs("form",{onSubmit:A,className:"space-y-8",children:[e.jsxs("div",{className:"space-y-4",children:[e.jsx("h2",{className:"text-xl font-semibold border-b pb-2",children:"Personal Information"}),e.jsxs("div",{className:"grid md:grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-medium mb-2",children:["Full Name"," ",n!=="admin"&&e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx("input",{type:"text",value:t.name,onChange:a=>r(s=>({...s,name:a.target.value})),className:"w-full h-10 rounded-md border px-3",placeholder:"Enter your full name",required:n!=="admin"})]}),n!=="admin"&&e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-medium mb-2",children:["Date of Birth ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx("input",{type:"date",value:t.dob,onChange:a=>r(s=>({...s,dob:a.target.value})),className:"w-full h-10 rounded-md border px-3",max:new Date().toISOString().split("T")[0],required:!0})]})]}),e.jsxs("div",{className:"grid md:grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-medium mb-2",children:["Email Address"," ",n!=="admin"&&e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx("input",{type:"email",value:t.email,onChange:a=>r(s=>({...s,email:a.target.value})),className:"w-full h-10 rounded-md border px-3",placeholder:"[email protected]",required:n!=="admin"})]}),n!=="admin"&&e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-medium mb-2",children:["Phone Number ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx("input",{type:"tel",value:t.phone,onChange:a=>r(s=>({...s,phone:a.target.value})),className:"w-full h-10 rounded-md border px-3",placeholder:"+44 123 456 7890",required:!0})]})]}),n!=="admin"&&e.jsxs("div",{className:"grid md:grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-medium mb-2",children:["Create Password ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx("input",{type:"password",value:t.password,onChange:a=>r(s=>({...s,password:a.target.value})),className:"w-full h-10 rounded-md border px-3",placeholder:"At least 8 characters",minLength:8,required:!0}),e.jsx("p",{className:"text-xs text-foreground/60 mt-1",children:"You'll use this password to log in to your account"})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-medium mb-2",children:["Confirm Password ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx("input",{type:"password",value:t.confirmPassword,onChange:a=>r(s=>({...s,confirmPassword:a.target.value})),className:"w-full h-10 rounded-md border px-3",placeholder:"Re-enter your password",minLength:8,required:!0})]})]}),n!=="admin"&&e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium mb-2",children:"Address"}),e.jsx("textarea",{value:t.address,onChange:a=>r(s=>({...s,address:a.target.value})),className:"w-full rounded-md border px-3 py-2",rows:3,placeholder:"Your full address"})]})]}),n!=="admin"&&e.jsxs("div",{className:"space-y-4",children:[e.jsx("h2",{className:"text-xl font-semibold border-b pb-2",children:"Parent/Guardian Information"}),e.jsx("p",{className:"text-sm text-foreground/70",children:"Required if the student is under 18 years old"}),e.jsxs("div",{className:"grid md:grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium mb-2",children:"Parent/Guardian Name"}),e.jsx("input",{type:"text",value:t.parentName,onChange:a=>r(s=>({...s,parentName:a.target.value})),className:"w-full h-10 rounded-md border px-3",placeholder:"Full name"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium mb-2",children:"Parent/Guardian Phone"}),e.jsx("input",{type:"tel",value:t.parentPhone,onChange:a=>r(s=>({...s,parentPhone:a.target.value})),className:"w-full h-10 rounded-md border px-3",placeholder:"+44 123 456 7890"})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium mb-2",children:"Parent/Guardian Email"}),e.jsx("input",{type:"email",value:t.parentEmail,onChange:a=>r(s=>({...s,parentEmail:a.target.value})),className:"w-full h-10 rounded-md border px-3",placeholder:"[email protected]"})]})]}),n!=="admin"&&e.jsxs("div",{className:"space-y-4",children:[e.jsx("h2",{className:"text-xl font-semibold border-b pb-2",children:"Musical Information"}),e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-medium mb-2",children:["Instruments ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsxs("div",{className:"flex gap-2 mb-2",children:[e.jsxs("select",{value:b,onChange:a=>j(a.target.value),className:"flex-1 h-10 rounded-md border px-3",children:[e.jsx("option",{value:"",children:"Select an instrument"}),I.map(a=>e.jsx("option",{value:a,children:a},a))]}),e.jsx("button",{type:"button",onClick:_,className:"px-4 py-2 bg-primary text-primary-foreground rounded-md",children:"Add"})]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:t.instruments.map(a=>e.jsxs("span",{className:"inline-flex items-center gap-1 px-3 py-1 bg-primary/10 text-primary rounded-full text-sm",children:[a,e.jsx("button",{type:"button",onClick:()=>q(a),className:"ml-1 text-primary/70 hover:text-primary",children:"Ã"})]},a))})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium mb-2",children:"Previous Musical Experience"}),e.jsx("textarea",{value:t.experience,onChange:a=>r(s=>({...s,experience:a.target.value})),className:"w-full rounded-md border px-3 py-2",rows:3,placeholder:"Describe any previous musical experience, lessons, or self-study..."})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium mb-2",children:"Musical Goals"}),e.jsx("textarea",{value:t.goals,onChange:a=>r(s=>({...s,goals:a.target.value})),className:"w-full rounded-md border px-3 py-2",rows:3,placeholder:"What would you like to achieve through music lessons?"})]})]}),n!=="admin"&&e.jsxs("div",{className:"space-y-4",children:[e.jsx("h2",{className:"text-xl font-semibold border-b pb-2",children:"Medical Information"}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium mb-2",children:"Allergies"}),e.jsx("textarea",{value:t.allergies,onChange:a=>r(s=>({...s,allergies:a.target.value})),className:"w-full rounded-md border px-3 py-2",rows:2,placeholder:"List any allergies..."})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium mb-2",children:"Medications"}),e.jsx("textarea",{value:t.medications,onChange:a=>r(s=>({...s,medications:a.target.value})),className:"w-full rounded-md border px-3 py-2",rows:2,placeholder:"List any medications..."})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium mb-2",children:"Emergency Contacts"}),e.jsx("textarea",{value:t.emergencyContacts,onChange:a=>r(s=>({...s,emergencyContacts:a.target.value})),className:"w-full rounded-md border px-3 py-2",rows:3,placeholder:"Name and phone number of emergency contacts..."})]})]}),n!=="admin"&&e.jsxs("div",{className:"space-y-4",children:[e.jsx("h2",{className:"text-xl font-semibold border-b pb-2",children:"Additional Information"}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium mb-2",children:"Availability"}),e.jsx("textarea",{value:t.availability,onChange:a=>r(s=>({...s,availability:a.target.value})),className:"w-full rounded-md border px-3 py-2",rows:3,placeholder:"What days and times are you available for lessons?"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium mb-2",children:"Additional Information"}),e.jsx("textarea",{value:t.additionalInfo,onChange:a=>r(s=>({...s,additionalInfo:a.target.value})),className:"w-full rounded-md border px-3 py-2",rows:3,placeholder:"Any other information you'd like us to know..."})]})]}),n!=="admin"&&e.jsx("div",{className:"space-y-4",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("input",{type:"checkbox",id:"marketingConsent",checked:t.marketingConsent,onChange:a=>r(s=>({...s,marketingConsent:a.target.checked})),className:"mt-1"}),e.jsx("label",{htmlFor:"marketingConsent",className:"text-sm",children:"I consent to receiving marketing communications from In Tune Music Tuition about lessons, events, and special offers."})]})}),v&&e.jsx("div",{className:"text-sm text-red-600 bg-red-50 p-3 rounded",children:v}),e.jsx("div",{className:"flex justify-end pt-4",children:e.jsx("button",{type:"submit",disabled:y,className:"px-8 py-3 bg-primary text-primary-foreground rounded-md font-medium disabled:opacity-50",children:y?"Submitting...":n==="admin"?"Add Student":"Submit Application"})})]})]})})})}function V(){const[n]=F(),h=M();O();const c=n.get("campaign"),d=n.get("teacher"),p=n.get("trial");let t="website";c&&d?t="qr":p&&(t="trial");const r=()=>{h("/intake-confirmation")};return e.jsx(L,{mode:t,onSuccess:r,campaignId:c||void 0,referringTeacherId:d||void 0,trialId:p||void 0})}export{V 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.