1/*! For license information please see 8231.11c32986.chunk.js.LICENSE.txt */ 2"use strict";(self.webpackChunkstudent_management_app=self.webpackChunkstudent_management_app||[]).push([[8231],{8231:(e,t,s)=>{s.r(t),s.d(t,{default:()=>N});var a=s(9950),n=s(73814),l=s(56600),r=s(36493),d=s(51748),i=s(56790),o=s(47288),c=s(13061),m=s(39032),x=s(73142),u=s(28165),p=s(48805),h=s(40732),b=s(67714),f=s(99845),v=s(44414);const g=[["fullName","Full name","text"],["email","Email","email"],["phoneNumber","Phone","tel"],["countryOfOrigin","Country of origin","text"],["programName","Program","text"],["intendedStartDate","Intended start date","date"]],y=e=>{var t;const s=(null===e||void 0===e||null===(t=e.toDate)||void 0===t?void 0:t.call(e))||(e?new Date(e):null);return s&&!Number.isNaN(s.getTime())?s.toLocaleString("en-US",{dateStyle:"medium",timeStyle:"short"}):"\u2014"},j=e=>String(e||"pending").replaceAll("_"," ").replace(/\b\w/g,e=>e.toUpperCase());function N(){var e,t,s,N;const{enrollmentId:w}=(0,n.g)(),C=(0,n.Zp)(),{showToast:A}=(0,b.d)(),{showConfirm:k}=(0,f.M)(),[$,S]=(0,a.useState)(null),[M,E]=(0,a.useState)({}),[I,z]=(0,a.useState)(!0),[F,_]=(0,a.useState)(""),[L,B]=(0,a.useState)(!1),[H,O]=(0,a.useState)(!1),[P,D]=(0,a.useState)(""),[R,T]=(0,a.useState)(""),U=(0,a.useRef)(!1);(0,a.useEffect)(()=>(0,l.aQ)((0,l.H9)(l.db,"enrollments",w),e=>{if(!e.exists())return _("Enrollment not found."),void z(!1);const t={id:e.id,...e.data()};S(t),E(Object.fromEntries(g.map(e=>{let[s]=e;return[s,t[s]||""]}))),z(!1),"approved"!==String(t.status||"").toLowerCase()||t.studentId||U.current||(U.current=!0,(0,l.Ij)("reconcileApprovedEnrollment",{enrollmentId:w}).catch(e=>{U.current=!1,console.error("Could not reconcile approved enrollment:",e)}))},e=>{console.error("Could not load enrollment:",e),_("Could not load this enrollment."),z(!1)}),[w]);const V=["confirmation_pending","partially_paid"].includes(null===$||void 0===$?void 0:$.paymentStatus),Z=["zelle","cash","already_paid"].includes(null===$||void 0===$?void 0:$.paymentMethod),W=V&&Z,q=(0,a.useMemo)(()=>"approved"===(null===$||void 0===$?void 0:$.status)?"bg-emerald-100 text-emerald-800":"rejected"===(null===$||void 0===$?void 0:$.status)?"bg-red-100 text-red-800":"bg-amber-100 text-amber-800",[null===$||void 0===$?void 0:$.status]),Q=async e=>{if(await k(`${j(e)} this enrollment?`,{title:`${j(e)} Enrollment`,confirmText:j(e)})){D(e);try{if(await(0,l.mZ)((0,l.H9)(l.db,"enrollments",w),{status:e,updatedAt:(0,l.O5)()}),"approved"===e){const e=await(0,l.Ij)("reconcileApprovedEnrollment",{enrollmentId:w});A(e.studentId?"Enrollment approved and student activated":"Enrollment approved; activation is being finalized","success")}else A(`Enrollment ${e}`,"success")}catch(t){console.error("Could not update enrollment status:",t),A("Could not update enrollment status","error")}finally{D("")}}};return I?(0,v.jsx)("div",{className:"flex min-h-[50vh] items-center justify-center",children:(0,v.jsx)(h.A,{})}):F?(0,v.jsxs)("div",{className:"mx-auto max-w-3xl p-8",children:[(0,v.jsxs)("button",{onClick:()=>C("/dashboard/enrollments"),className:"mb-6 inline-flex items-center gap-2 text-sm font-semibold text-slate-600",children:[(0,v.jsx)(r.A,{className:"h-4 w-4"})," Back to enrollments"]}),(0,v.jsx)("div",{className:"rounded-xl border border-red-200 bg-red-50 p-6 text-red-800",children:F})]}):(0,v.jsxs)("div",{className:"mx-auto max-w-6xl px-4 py-6 sm:px-6 lg:px-8",children:[(0,v.jsxs)("button",{onClick:()=>C("/dashboard/enrollments"),className:"mb-5 inline-flex items-center gap-2 text-sm font-semibold text-slate-600 hover:text-slate-900",children:[(0,v.jsx)(r.A,{className:"h-4 w-4"})," Back to enrollments"]}),(0,v.jsxs)("div",{className:"overflow-hidden rounded-2xl border border-slate-200 bg-white shadow-sm",children:[(0,v.jsxs)("div",{className:"border-b border-slate-200 bg-slate-50 px-6 py-5 sm:flex sm:items-center sm:justify-between",children:[(0,v.jsxs)("div",{children:[(0,v.jsx)("p",{className:"text-xs font-bold uppercase tracking-wider text-emerald-700",children:"Enrollment details"}),(0,v.jsx)("h1",{className:"mt-1 text-2xl font-bold text-slate-900",children:$.fullName||"Unnamed enrollment"}),(0,v.jsxs)("p",{className:"mt-1 text-sm text-slate-500",children:["ID: ",$.id]})]}),(0,v.jsxs)("div",{className:"mt-4 flex flex-wrap gap-2 sm:mt-0",children:[(0,v.jsx)("span",{className:`rounded-full px-3 py-1.5 text-xs font-bold ${q}`,children:j($.status)}),(0,v.jsx)("span",{className:"rounded-full px-3 py-1.5 text-xs font-bold "+(["paid","waived"].includes($.paymentStatus)?"bg-emerald-100 text-emerald-800":"bg-amber-100 text-amber-800"),children:j($.paymentStatus||"pending payment")})]})]}),(0,v.jsxs)("div",{className:"grid gap-6 p-6 lg:grid-cols-3",children:[(0,v.jsxs)("section",{className:"lg:col-span-2",children:[(0,v.jsxs)("div",{className:"mb-4 flex items-center justify-between",children:[(0,v.jsx)("h2",{className:"text-lg font-bold text-slate-900",children:"Student and program information"}),L?(0,v.jsxs)("button",{onClick:()=>{B(!1),E(Object.fromEntries(g.map(e=>{let[t]=e;return[t,$[t]||""]})))},className:"inline-flex items-center gap-1 text-sm font-semibold text-slate-600",children:[(0,v.jsx)(i.A,{className:"h-4 w-4"})," Cancel"]}):(0,v.jsx)(p.$,{variant:"outline",icon:d.A,onClick:()=>B(!0),children:"Edit"})]}),(0,v.jsx)("div",{className:"grid gap-4 sm:grid-cols-2",children:g.map(e=>{let[t,s,a]=e;return(0,v.jsxs)("label",{className:"block",children:[(0,v.jsx)("span",{className:"mb-1.5 block text-xs font-bold uppercase tracking-wide text-slate-500",children:s}),L?(0,v.jsx)("input",{type:a,value:M[t]||"",onChange:e=>E(s=>({...s,[t]:e.target.value})),className:"w-full rounded-lg border border-slate-300 px-3 py-2.5 text-sm focus:border-emerald-500 focus:outline-none focus:ring-2 focus:ring-emerald-100"}):(0,v.jsx)("div",{className:"min-h-[42px] rounded-lg bg-slate-50 px-3 py-2.5 text-sm text-slate-900",children:$[t]||"\u2014"})]},t)})}),(0,v.jsxs)("label",{className:"mt-4 block",children:[(0,v.jsx)("span",{className:"mb-1.5 block text-xs font-bold uppercase tracking-wide text-slate-500",children:"Internal notes"}),L?(0,v.jsx)("textarea",{rows:"4",value:null!==(e=null!==(t=M.notes)&&void 0!==t?t:$.notes)&&void 0!==e?e:"",onChange:e=>E(t=>({...t,notes:e.target.value})),className:"w-full rounded-lg border border-slate-300 px-3 py-2.5 text-sm focus:border-emerald-500 focus:outline-none focus:ring-2 focus:ring-emerald-100"}):(0,v.jsx)("div",{className:"min-h-[90px] whitespace-pre-wrap rounded-lg bg-slate-50 px-3 py-2.5 text-sm text-slate-900",children:$.notes||"No notes added."})]}),L&&(0,v.jsx)("div",{className:"mt-4",children:(0,v.jsx)(p.$,{variant:"primary",icon:H?o.A:c.A,disabled:H,onClick:async()=>{O(!0);try{await(0,l.mZ)((0,l.H9)(l.db,"enrollments",w),{...M,updatedAt:(0,l.O5)()}),B(!1),A("Enrollment details updated","success")}catch(e){console.error("Could not update enrollment:",e),A("Could not update enrollment details","error")}finally{O(!1)}},children:H?"Saving\u2026":"Save changes"})})]}),(0,v.jsxs)("aside",{className:"space-y-5",children:[(0,v.jsxs)("div",{className:"rounded-xl border border-slate-200 p-5",children:[(0,v.jsx)("h2",{className:"font-bold text-slate-900",children:"Payment"}),(0,v.jsxs)("dl",{className:"mt-4 space-y-3 text-sm",children:[(0,v.jsxs)("div",{children:[(0,v.jsx)("dt",{className:"text-slate-500",children:"Status"}),(0,v.jsx)("dd",{className:"font-semibold text-slate-900",children:j($.paymentStatus)})]}),(0,v.jsxs)("div",{children:[(0,v.jsx)("dt",{className:"text-slate-500",children:"Method"}),(0,v.jsx)("dd",{className:"font-semibold text-slate-900",children:j($.paymentMethod||"not recorded")})]}),(0,v.jsxs)("div",{children:[(0,v.jsx)("dt",{className:"text-slate-500",children:"Amount"}),(0,v.jsx)("dd",{className:"font-semibold text-slate-900",children:Number.isFinite(Number($.amountCents))?`$${(Number($.amountCents)/100).toFixed(2)}`:"\u2014"})]}),(0,v.jsxs)("div",{children:[(0,v.jsx)("dt",{className:"text-slate-500",children:"Received"}),(0,v.jsxs)("dd",{className:"font-semibold text-emerald-700",children:["$",(($.receivedAmountCents||$.paymentAmountCents||0)/100).toFixed(2)]})]}),(0,v.jsxs)("div",{children:[(0,v.jsx)("dt",{className:"text-slate-500",children:"Remaining balance"}),(0,v.jsxs)("dd",{className:"font-semibold text-slate-900",children:["$",((null!==(s=$.remainingAmou
2ntCents)&&void 0!==s?s:Math.max(0,($.amountCents||0)-($.receivedAmountCents||$.paymentAmountCents||0)))/100).toFixed(2)]})]})]}),W&&(0,v.jsxs)("div",{className:"mt-5",children:[(0,v.jsx)("label",{className:"mb-1.5 block text-xs font-bold uppercase tracking-wide text-slate-500",children:"Amount received"}),(0,v.jsxs)("div",{className:"relative",children:[(0,v.jsx)("span",{className:"absolute left-3 top-2.5 text-slate-500",children:"$"}),(0,v.jsx)("input",{type:"number",min:"0.01",step:"0.01",max:(null!==(N=$.remainingAmountCents)&&void 0!==N?N:$.amountCents||0)/100,value:R,onChange:e=>T(e.target.value),className:"w-full rounded-lg border border-slate-300 py-2.5 pl-7 pr-3 text-sm focus:border-emerald-500 focus:outline-none focus:ring-2 focus:ring-emerald-100",placeholder:"0.00"})]}),(0,v.jsx)(p.$,{className:"mt-3 w-full",variant:"primary",icon:"payment"===P?o.A:m.A,disabled:Boolean(P)||!R,onClick:async()=>{var e;const t=Number(R),s=(null!==(e=$.remainingAmountCents)&&void 0!==e?e:Math.max(0,($.amountCents||0)-($.receivedAmountCents||$.paymentAmountCents||0)))/100;if(!Number.isFinite(t)||t<=0)return A("Enter the amount received","warning");if(t>s)return A(`Amount cannot exceed the remaining balance of $${s.toFixed(2)}`,"warning");if(await k(`Confirm receipt of $${t.toFixed(2)}? ${t<s?`A balance of $${(s-t).toFixed(2)} will remain.`:"This will complete payment and email the official paid receipt."}`,{title:"Confirm Payment",confirmText:"Confirm payment"})){D("payment");try{var a,n;const e=(null===(a=window.crypto)||void 0===a||null===(n=a.randomUUID)||void 0===n?void 0:n.call(a).replaceAll("-","_"))||`payment_${Date.now()}`,s=await(0,l.Ij)("confirmOfflineClassPayment",{reservationId:w,amountReceived:t,confirmationId:e});T(""),A(s.fullyPaid?"Full payment confirmed and paid receipt sent":`Partial payment recorded. Remaining balance: $${(s.remainingAmountCents/100).toFixed(2)}`,"success")}catch(r){console.error("Could not confirm payment:",r),A(r.message||"Could not confirm payment","error")}finally{D("")}}},children:"payment"===P?"Confirming\u2026":"Confirm amount received"})]})]}),(0,v.jsxs)("div",{className:"rounded-xl border border-slate-200 p-5",children:[(0,v.jsx)("h2",{className:"font-bold text-slate-900",children:"Enrollment record"}),(0,v.jsxs)("dl",{className:"mt-4 space-y-3 text-sm",children:[(0,v.jsxs)("div",{children:[(0,v.jsx)("dt",{className:"text-slate-500",children:"Submitted"}),(0,v.jsx)("dd",{className:"font-semibold text-slate-900",children:y($.submittedAt)})]}),(0,v.jsxs)("div",{children:[(0,v.jsx)("dt",{className:"text-slate-500",children:"Last updated"}),(0,v.jsx)("dd",{className:"font-semibold text-slate-900",children:y($.updatedAt)})]}),(0,v.jsxs)("div",{children:[(0,v.jsx)("dt",{className:"text-slate-500",children:"Confirmation"}),(0,v.jsx)("dd",{className:"font-semibold text-slate-900",children:$.confirmationCode||"\u2014"})]})]})]}),(0,v.jsxs)("div",{className:"rounded-xl border border-slate-200 p-5",children:[(0,v.jsx)("h2",{className:"font-bold text-slate-900",children:"Actions"}),(0,v.jsxs)("div",{className:"mt-4 grid gap-2",children:[$.studentId&&(0,v.jsx)(p.$,{variant:"primary",onClick:()=>C(`/dashboard/student/${$.studentId}`),children:"Open active student profile"}),"approved"!==$.status&&(0,v.jsx)(p.$,{variant:"primary",icon:"approved"===P?o.A:x.A,disabled:Boolean(P),onClick:()=>Q("approved"),children:"Approve enrollment"}),"rejected"!==$.status&&(0,v.jsx)(p.$,{variant:"outline",icon:"rejected"===P?o.A:u.A,disabled:Boolean(P),onClick:()=>Q("rejected"),children:"Reject enrollment"})]})]})]})]})]})]})}},13061:(e,t,s)=>{s.d(t,{A:()=>a});const a=(0,s(7101).A)("Save",[["path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z",key:"1c8476"}],["path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7",key:"1ydtos"}],["path",{d:"M7 3v4a1 1 0 0 0 1 1h7",key:"t51u73"}]])},28165:(e,t,s)=>{s.d(t,{A:()=>a});const a=(0,s(7101).A)("CircleX",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]])},36493:(e,t,s)=>{s.d(t,{A:()=>a});const a=(0,s(7101).A)("ArrowLeft",[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]])},40732:(e,t,s)=>{s.d(t,{A:()=>n});s(9950);var a=s(44414);const n=e=>{let{size:t="medium",color:s="blue"}=e;const n={small:"w-4 h-4",medium:"w-8 h-8",large:"w-12 h-12"}[t],l={blue:"text-blue-600",gray:"text-gray-600",white:"text-white"}[s];return(0,a.jsx)("div",{className:"flex justify-center items-center",children:(0,a.jsxs)("svg",{className:`animate-spin ${n} ${l}`,xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[(0,a.jsx)("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),(0,a.jsx)("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]})})}},47288:(e,t,s)=>{s.d(t,{A:()=>a});const a=(0,s(7101).A)("LoaderCircle",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]])},48805:(e,t,s)=>{s.d(t,{$:()=>n});s(9950);var a=s(44414);const n=e=>{let{children:t,variant:s="primary",size:n="default",isLoading:l=!1,disabled:r=!1,icon:d,onClick:i,type:o="button",className:c="",...m}=e;const x=r||l?"opacity-50 cursor-not-allowed":"";return(0,a.jsxs)("button",{type:o,className:`inline-flex items-center justify-center font-medium rounded-md focus:outline-none focus:ring-2 focus:ring-offset-2 transition-colors duration-200 ${{primary:"bg-primary-600 text-white hover:bg-primary-700 focus:ring-primary-500",secondary:"bg-gray-100 text-gray-700 hover:bg-gray-200 focus:ring-gray-500",danger:"bg-red-600 text-white hover:bg-red-700 focus:ring-red-500",success:"bg-green-600 text-white hover:bg-green-700 focus:ring-green-500",outline:"border border-gray-300 bg-white text-gray-700 hover:bg-gray-50 focus:ring-primary-500"}[s]} ${{small:"px-3 py-1.5 text-sm",default:"px-4 py-2 text-sm",large:"px-6 py-3 text-base"}[n]} ${x} ${c}`,disabled:r||l,onClick:i,...m,children:[l&&(0,a.jsxs)("svg",{className:"animate-spin -ml-1 mr-2 h-4 w-4 text-current",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[(0,a.jsx)("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),(0,a.jsx)("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]}),d&&!l&&(0,a.jsx)(d,{className:"h-5 w-5 mr-2","aria-hidden":"true"}),t]})}},51748:(e,t,s)=>{s.d(t,{A:()=>a});const a=(0,s(7101).A)("PenLine",[["path",{d:"M12 20h9",key:"t2du7b"}],["path",{d:"M16.376 3.622a1 1 0 0 1 3.002 3.002L7.368 18.635a2 2 0 0 1-.855.506l-2.872.838a.5.5 0 0 1-.62-.62l.838-2.872a2 2 0 0 1 .506-.854z",key:"1ykcvy"}]])},73142:(e,t,s)=>{s.d(t,{A:()=>a});const a=(0,s(7101).A)("CircleCheckBig",[["path",{d:"M21.801 10A10 10 0 1 1 17 3.335",key:"yps3ct"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]])}}]);
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.