1import{F as U,r as p,j as e,L as D,C as O,a as k,I as P}from"./index-OxudDnLK.js";import{B as w}from"./button-DKXgCN7g.js";import{I as L}from"./ImageUploadField-Llqs09dj.js";import{T as _}from"./textarea-DFr7vgJM.js";import{a as f}from"./toast-service-B0j-nRBP.js";import{L as C}from"./loader-circle-Kyus1vNT.js";const S="https://ahoy-winter-unrelated.ngrok-free.dev/api",j="[email protected]";console.log(`membership email: ${j}`);const R=()=>({role:"proposer",sponsorName:"",membershipNumber:"",email:"",phone:"",knownDuration:"",howMet:"",clubFriends:"",hobbies:"",currentOrPastClubs:"",pastClubs:"",expelledOrSuspended:"",refusedAdmission:"",reasonForMembership:"",activeMemberReason:"",integrityAndFinancialStanding:"",otherInfo:"",signedDate:new Date().toISOString().slice(0,10)});function Q(){const{applicationNumber:s}=U.useParams(),[l,c]=p.useState(null),[r,m]=p.useState(!1),[t,A]=p.useState(R),[g,N]=p.useState({url:null,file:null}),[y,v]=p.useState(!1);p.useEffect(()=>{(async()=>{m(!1);try{const d=await(await fetch(`${S}/membership/applications/${encodeURIComponent(s)}`,{headers:{"ngrok-skip-browser-warning":"true"}})).json();if(d.success){c(d.data);return}}catch{try{const o=JSON.parse(localStorage.getItem("ukc_applications")||"{}");c(o[s]??null)}catch{c(null)}}finally{m(!0)}})()},[s]);const n=(a,o)=>A(d=>({...d,[a]:o})),F=async a=>{if(a.preventDefault(),!t.sponsorName||!t.email||!t.knownDuration||!t.howMet){f.error("Please complete the required sponsor details.");return}v(!0);const o=await E(g),d={...t,pastClubsMembershipCard:o},I={...l??{},applicationNumber:s,application_number:l?.application_number??s},M={target_email:j,targetEmail:j,application:I,applicationNumber:s,application_number:s,form:d,sponsorForm:d,sponsor:d,...d};try{const h=await(await fetch(`${S}/membership/applications/sponsor-email`,{method:"POST",headers:{"Content-Type":"application/json","ngrok-skip-browser-warning":"true"},body:JSON.stringify(M)})).json();if(!h.success)throw new Error(h.message||"Unable to submit sponsor form.");f.success("Sponsor questionnaire submitted.")}catch{const x=`ukc_sponsor_forms_${s}`,h=JSON.parse(localStorage.getItem(x)||"[]");h.push({applicationNumber:s,role:t.role,sponsorName:t.sponsorName,email:t.email,submittedAt:new Date().toISOString()}),localStorage.setItem(x,JSON.stringify(h)),f.success("Sponsor questionnaire reference saved locally.")}finally{v(!1)}};return e.jsx("main",{className:"min-h-screen bg-background pt-32 pb-20",children:e.jsxs("div",{className:"mx-auto max-w-5xl px-6 lg:px-10",children:[e.jsx("div",{className:"mb-4 text-[11px] uppercase tracking-[0.35em] text-gold",children:"Letter of Introduction"}),e.jsxs("div",{className:"flex flex-col gap-5 md:flex-row md:items-start md:justify-between",children:[e.jsxs("div",{children:[e.jsxs("h1",{className:"font-serif text-4xl leading-tight text-forest md:text-5xl",children:["Sponsor Application ",s]}),e.jsx("p",{className:"mt-3 max-w-3xl text-foreground/70",children:"All sponsors are required to fill in one of these forms. No application will be considered unless supported by both proposer and seconder questionnaires."})]}),e.jsx(w,{asChild:!0,variant:"outline",className:"shrink-0",children:e.jsx(D,{to:"/membership/$applicationNumber/status",params:{applicationNumber:s},children:"View Status"})})]}),e.jsx("div",{className:"mt-8 rounded-xl border bg-card p-6 shadow-sm",children:r?e.jsxs("div",{className:"flex items-center gap-2 text-sm text-emerald-700",children:[e.jsx(O,{size:16}),"Applicant: ",T(l)]}):e.jsxs("div",{className:"flex items-center gap-2 text-forest",children:[e.jsx(C,{size:16,className:"animate-spin"}),"Loading applicant details..."]})}),e.jsxs("form",{onSubmit:F,className:"mt-6 space-y-6",children:[e.jsxs("section",{className:"rounded-xl border bg-card p-6 shadow-sm",children:[e.jsx(b,{title:"Sponsor Role"}),e.jsx("div",{className:"mt-4 grid gap-3 md:grid-cols-2",children:["proposer","seconder"].map(a=>e.jsxs("label",{className:"flex cursor-pointer items-center gap-3 rounded-lg border p-4 transition hover:border-gold hover:bg-secondary/40 has-[:checked]:border-gold has-[:checked]:bg-secondary/60",children:[e.jsx("input",{type:"radio",name:"role",value:a,checked:t.role===a,onChange:o=>n("role",o.target.value),className:"size-4 accent-forest"}),e.jsx("span",{className:"text-sm font-medium capitalize",children:a})]},a))}),e.jsxs("p",{className:"mt-4 text-sm text-muted-foreground",children:["The membership committee reminds the ",t.role," that endorsement of an applicant is a responsibility that should guard one's character as a UKC member."]})]}),e.jsxs("section",{className:"rounded-xl border bg-card p-6 shadow-sm",children:[e.jsx(b,{title:"Sponsor Details"}),e.jsxs("div",{className:"mt-4 grid gap-4 md:grid-cols-2",children:[e.jsx(u,{label:`${q(t.role)} Name`,value:t.sponsorName,onChange:a=>n("sponsorName",a),required:!0}),e.jsx(u,{label:"Membership Number",value:t.membershipNumber,onChange:a=>n("membershipNumber",a)}),e.jsx(u,{label:"Email",type:"email",value:t.email,onChange:a=>n("email",a),required:!0}),e.jsx(u,{label:"Phone",type:"tel",value:t.phone,onChange:a=>n("phone",a)})]})]}),e.jsxs("section",{className:"rounded-xl border bg-card p-6 shadow-sm",children:[e.jsx(b,{title:"Questionnaire"}),e.jsxs("div",{className:"mt-4 grid gap-5",children:[e.jsx(i,{label:"How long have you known the candidate and how well do you know him/her?",value:t.knownDuration,onChange:a=>n("knownDuration",a),required:!0}),e.jsx(i,{label:"How did you come to know the candidate?",value:t.howMet,onChange:a=>n("howMet",a),required:!0}),e.jsx(i,{label:"Does the proposed member have friends among the UKC club? List at least two members known to the applicant.",value:t.clubFriends,onChange:a=>n("clubFriends",a)}),e.jsx(i,{label:"What are the interests or hobbies of the applicant?",value:t.hobbies,onChange:a=>n("hobbies",a)}),e.jsx(i,{label:"What other clubs has the applicant belonged to?",value:t.currentOrPastClubs,onChange:a=>n("currentOrPastClubs",a)}),e.jsx(i,{label:"What clubs has the applicant belonged to in the past? Attach a copy of membership card if in any club.",value:t.pastClubs,onChange:a=>n("pastClubs",a)}),e.jsx(L,{label:"Past Club Membership Card",imageUrl:g.url,imageFile:g.file,onImageUrlChange:a=>N(o=>({...o,url:a})),onImageFileChange:a=>N(o=>({...o,file:a}))}),e.jsx(i,{label:"Has the applicant ever been expelled or suspended by United Kenya Club or any other club in Kenya?",value:t.expelledOrSuspended,onChange:a=>n("expelledOrSuspended",a)}),e.jsx(i,{label:"Has the applicant ever been refused admission to a club?",value:t.refusedAdm
1ission,onChange:a=>n("refusedAdmission",a)}),e.jsx(i,{label:"Does the applicant have any particular reason for the desire to become a member of the United Kenya Club?",value:t.reasonForMembership,onChange:a=>n("reasonForMembership",a)}),e.jsx(i,{label:"Why do you want the applicant to become a member, and do you think he/she will be an active member?",value:t.activeMemberReason,onChange:a=>n("activeMemberReason",a)}),e.jsx(i,{label:"Are you satisfied as to the applicant integrity and financial standing?",value:t.integrityAndFinancialStanding,onChange:a=>n("integrityAndFinancialStanding",a)}),e.jsx(i,{label:"Any other information which might be helpful for the Balloting Committee?",value:t.otherInfo,onChange:a=>n("otherInfo",a)})]})]}),e.jsxs("section",{className:"rounded-xl border bg-card p-6 shadow-sm",children:[e.jsx(b,{title:"Signature"}),e.jsxs("div",{className:"mt-4 grid gap-4 md:grid-cols-2",children:[e.jsx(u,{label:"Signed By",value:t.sponsorName,onChange:a=>n("sponsorName",a),required:!0}),e.jsx(u,{label:"Date",type:"date",value:t.signedDate,onChange:a=>n("signedDate",a),required:!0})]})]}),e.jsx("div",{className:"flex justify-end",children:e.jsxs(w,{type:"submit",disabled:y,className:"gap-2",children:[y&&e.jsx(C,{size:14,className:"animate-spin"}),"Submit Sponsor Form"]})})]})]})})}function b({title:s}){return e.jsx("h2",{className:"font-serif text-2xl text-forest",children:s})}function u({label:s,value:l,onChange:c,type:r="text",required:m=!1}){return e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs(k,{children:[s,m&&e.jsx("span",{className:"text-destructive",children:" *"})]}),e.jsx(P,{type:r,value:l,onChange:t=>c(t.target.value),required:m})]})}function i({label:s,value:l,onChange:c,required:r=!1}){return e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs(k,{children:[s,r&&e.jsx("span",{className:"text-destructive",children:" *"})]}),e.jsx(_,{rows:4,value:l,onChange:m=>c(m.target.value),required:r})]})}function T(s){return s?s.applicantName??s.applicant_name??s.userName??s.user_name??[s.personal?.surname,s.personal?.otherNames].filter(Boolean).join(" ")??"Applicant":"Application details pending"}function q(s){return s.replace(/\b\w/g,l=>l.toUpperCase())}const z=s=>new Promise((l,c)=>{const r=new FileReader;r.onload=()=>l(String(r.result)),r.onerror=()=>
1c(r.error),r.readAsDataURL(s)});async function E(s){return{url:s.url,fileName:s.file?.name??null,fileType:s.file?.type??null,fileSize:s.file?.size??null,dataUrl:s.file?await z(s.file):null}}export{Q 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.