1import{y as ge,al as xe,z as H,am as be,b as te,j as e,N as Z,an as Se,L as re,B as ae,ao as Le,ap as Re,m as ue,aq as Pe,ar as Ue,a as je,R as Ne,r as a,as as Te,at as Ae,au as Be,av as Ee,aw as ke,ax as Ge,ay as Me,az as Fe,aA as Ve,G as _e,aB as He,u as ze,t as Oe,aC as Ze,n as le,aD as Qe,V as $e,aE as ce,ae as Ye}from"./index-BZAaBzkS.js";import{H as qe}from"./Helmet-Bd3kEmBI.js";import{t as ve}from"./zod-DY6IdoX3.js";import{u as we}from"./index.esm-B-xIoWWs.js";import{A as oe}from"./AnchorLink-BczZffyO.js";import{P as We}from"./PublicLayout-BQvhXedy.js";import Je from"./AddStudentScreenRebuilt-B7n83S40.js";import{E as Xe}from"./ExclaimationIcon-0TyBzClM.js";import{N as Ce}from"./NeedHelpLink-BFbek5ZX.js";import{a as De,b as es,c as ss,d as ts,e as as,g as os}from"./StudentsQueries-B3XkAEVg.js";import{u as ne}from"./AccountQueries-B_uLnNXZ.js";import{C as ie}from"./useStudentDetailsData-tZ2jNC-r.js";import{f as ns}from"./faQuestionCircle-BoiG10MJ.js";import{O as Ie,N as is,S as de}from"./array-DXJL26BM.js";import{F as Ke}from"./formik.esm-Bo11rM7o.js";import{u as rs}from"./useGetUserProfile-sRaZlBSY.js";import{F as fe}from"./Field-B2XZNPup.js";import{F as se}from"./FieldValidationMessage-CTgtB8JX.js";import{C as ls}from"./ConfirmAlert-BI5vMG94.js";import{u as X}from"./useMutation-Rq5Lo8x3.js";import{a as cs,b as ds,u as ms,c as us,d as ps}from"./BrandBusinessQueries-awhDo_pQ.js";import{D as me}from"./Dropdown-BK-F1zqf.js";import{u as he}from"./useQuery-zQBOn3mQ.js";import{u as ye}from"./useLazyQuery-B5nuih9K.js";import{u as fs}from"./useMutation-DGbKPAyb.js";import{c as hs}from"./UserBffApi-DGajDQJj.js";import{u as ys,c as gs}from"./UserQueries-BuRbC51U.js";import"./PoweredByFlexischools-B0b02h_u.js";import"./usePostStudentFormData-DAihypnn.js";import"./httpClients-Bm2oLk4H.js";import"./FlxQueries-gQOFLa3V.js";import"./flx-logo-BzQXSPHe.js";import"./FeatureFlagList-D9OsNZ-V.js";import"./Portal-D2rZj_Ae.js";import"./SlideInModal-CVygqgVD.js";import"./useClearableState-BUA-gs_c.js";import"./faChevronRight-Bs7taHS-.js";import"./AppShellWrapper-Bd2Oyv7n.js";import"./AppShell-DhREaT-D.js";import"./OpenInApp-qQVY2utg.js";import"./faTimes-BnpiXKKO.js";import"./faUserCircle-HNqAqIh5.js";import"./useQuery-DjyDcgfd.js";import"./_getTag-BQ3D3QVa.js";import"./IconButton-D4mlHSTQ.js";import"./InfoIcon-DjFa9kVz.js";import"./CloseIconButton-Cnbnb0ZZ.js";import"./useIsomorphicLayoutEffect-BgcqTBKd.js";const Q=be(),xs=ge({email:H().min(1,"Please enter email address").email({message:"Invalid email address"}),password:H().min(Q==null?void 0:Q.PasswordMinLength,Q.PasswordRegexErrorMessage).regex(new RegExp(Q==null?void 0:Q.PasswordRegexPattern),Q.PasswordRegexErrorMessage).refine(s=>!/[<>]/.test(s),{message:"Password cannot contain < or > characters."}),confirmPassword:H().min(1,"Please confirm your password."),termsAndConditions:xe()}).refine(s=>s.password===s.confirmPassword,{message:"Password do not match",path:["confirmPassword"]}).refine(s=>s.termsAndConditions,{message:"You need to accept the terms and conditions.",path:["termsAndConditions"]});function bs({onSubmit:s,isSubmitting:i,email:n,errorMessage:c}){var N,j,y,m,p,S;const{register:d,handleSubmit:r,formState:{errors:o}}=we({mode:"onBlur",resolver:ve(xs),defaultValues:{email:n,password:"",confirmPassword:"",termsAndConditions:!1}}),{brandConfiguration:{name:t,termsAndConditions:T}}=te();return e.jsx("div",{className:"justify-center",children:e.jsxs("form",{className:"grid gap-6",onSubmit:r(s),children:[e.jsx(Z,{...d("email"),type:"email",id:"email",label:"Email address",disabled:!0}),e.jsx(Z,{type:"password",id:"password",label:"Password",htmlProps:{autoComplete:"off"},...d("password"),hasError:!!((N=o==null?void 0:o.password)!=null&&N.message),supportingText:(j=o==null?void 0:o.password)==null?void 0:j.message,disabled:i}),e.jsx(Z,{type:"password",id:"confirm-password",label:"Confirm password",htmlProps:{autoComplete:"off"},...d("confirmPassword"),hasError:!!((y=o==null?void 0:o.confirmPassword)!=null&&y.message),supportingText:(m=o==null?void 0:o.confirmPassword)==null?void 0:m.message,disabled:i}),e.jsx("div",{className:"justify-center p-4 -ml-8 -mr-8 bg-neutral-50 text-neutral-400",children:e.jsxs("div",{children:[e.jsxs("div",{className:"flex py-4",children:[e.jsxs("div",{className:"min-w-[30px] flex items-center justify-center",children:[e.jsx("label",{htmlFor:"terms-conditions",className:"sr-only",children:"Terms and conditions"}),e.jsx(Se,{id:"terms-conditions",...d("termsAndConditions"),disabled:i})]}),e.jsxs("div",{className:"pl-4",children:["I have read and agree to be bound by"," ",e.jsxs(oe,{to:T,target:"_blank",children:[t," Terms and Conditions of Use"]})]})]}),!!((p=o==null?void 0:o.termsAndConditions)!=null&&p.message)&&e.jsx("span",{role:"alert",className:"text-xs text-error-500",children:(S=o==null?void 0:o.termsAndConditions)==null?void 0:S.message})]})}),i&&e.jsx(re,{loading:!0,size:10}),c.length>0&&e.jsx("div",{children:e.jsx("div",{className:"justify-center text-md text-error-500 break-all",children:c})}),e.jsx("div",{className:"py-6",children:e.jsx(ae,{type:"submit",size:"custom",colour:"primary_v2",className:"w-full h-[71px]","aria-label":"complete registration next",disabled:i,children:e.jsx("span",{className:"flex items-center font-bold text-2xl",children:"Submit"})})})]})})}function Ss({handleStudentAdded:s}){return e.jsxs("div",{className:"justify-center",children:[e.jsx("div",{className:"flex flex-col text-center p-2 text-md",children:e.jsx("span",{className:"p-4",children:'To complete registration, please link at least one student to your account. Fill in their details below and click "submit".'})}),e.jsx(Je,{isRegoForm:!0,onAddStudentAfterRego:s})]})}const $=be(),js=ge({email:H().min(1,"Please enter email address").email({message:"Invalid email address"}),password:H().min($==null?void 0:$.PasswordMinLength,$.PasswordRegexErrorMessage).regex(new RegExp($==null?void 0:$.PasswordRegexPattern),$.PasswordRegexErrorMessage).refine(s=>!/[<>]/.test(s),{message:"Password cannot contain < or > characters."}),confirmPassword:H().min(1,"Please confirm your password."),title:H().min(1,"Please select one of these options."),firstName:H().min(1,"Please enter your first name."),lastName:H().min(1,"Please enter your last name."),phoneNumber:H().min(1,"Please enter your mobile or landline number.").regex(new RegExp(Le),"Please enter a valid phone number."),termsAndConditions:xe()}).refine(s=>s.password===s.confirmPassword,{message:"Password do not match",path:["confirmPassword"]}).refine(s=>s.termsAndConditions,{message:"You need to accept the terms and conditions.",path:["termsAndConditions"]});function Ns({onSubmit:s,isSubmitting:i,email:n,titleOptions:c,errorMessage:d}){var y,m,p,S,l,I,K,L,g,G,E,x,A,C;const{register:r,handleSubmit:o,formState:{errors:t}}=we({mode:"onBlur",resolver:ve(js),defaultValues:{email:n,password:"",confirmPassword:"",title:"",firstName:"",lastName:"",phoneNumber:"",termsAndConditions:!1}}),{brandConfiguration:{showPDS_CFSG_Link:T,name:N,termsAndConditions:j}}=te();return e.jsx("div",{className:"justify-center",children:e.jsxs("form",{className:"grid gap-6",onSubmit:o(s),children:[e.jsx(Z,{...r("email"),type:"email",id:"email",label:"Email address",disabled:!0}),e.jsx(Z,{type:"password",id:"password",label:"Password",htmlProps:{autoComplete:"off"},...r("password"),hasError:!!((y=t==null?void 0:t.password)!=null&&y.message),supportingText:(m=t==null?void 0:t.password)==null?void 0:m.message,disabled:i}),e.jsx(Z,{type:"password",id:"confirm-password",label:"Confirm password",htmlProps:{autoComplete:"off"},...r("confirmPassword"),hasError:!!((p=t==null?void 0:t.confirmPassword)!=null&&p.message),supportingText:(S=t==null?void 0:t.confirmPassword)==null?void 0:S.message,disabled:i}),e.jsx(Re,{options:c,id:"title",label:"Title",...r("title"),hasError:!!((l=t==null?void 0:t.t
1itle)!=null&&l.message),supportingText:(I=t==null?void 0:t.title)==null?void 0:I.message,disabled:i}),e.jsx(Z,{type:"first name",id:"first-name",label:"First name",...r("firstName"),hasError:!!((K=t==null?void 0:t.firstName)!=null&&K.message),supportingText:(L=t==null?void 0:t.firstName)==null?void 0:L.message,disabled:i}),e.jsx(Z,{type:"last name",id:"last-name",label:"Last name",...r("lastName"),hasError:!!((g=t==null?void 0:t.lastName)!=null&&g.message),supportingText:(G=t==null?void 0:t.lastName)==null?void 0:G.message,disabled:i}),e.jsx(Z,{type:"phone number",id:"phone-number",label:"Phone number",...r("phoneNumber"),hasError:!!((E=t==null?void 0:t.phoneNumber)!=null&&E.message),supportingText:(x=t==null?void 0:t.phoneNumber)==null?void 0:x.message,disabled:i}),e.jsxs("div",{className:"justify-center p-4 -ml-8 -mr-8 bg-neutral-50 text-neutral-400",children:[e.jsx("div",{className:ue("justify-center",{hidden:!T}),children:e.jsxs("div",{className:"flex py-4",children:[e.jsx("div",{className:"min-w-[30px] flex items-center justify-center",children:e.jsx(Xe,{})}),e.jsxs("div",{className:"pl-4",children:["Please consider our"," ",e.jsx(oe,{to:Pe,target:"_blank",children:"combined financial services guide and product disclosure statement"})," ","and our"," ",e.jsx(oe,{to:Ue,target:"_blank",children:"target market determination"})," ","before creating your account."]})]})}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex py-4",children:[e.jsxs("div",{className:"min-w-[30px] flex items-center justify-center",children:[e.jsx("label",{htmlFor:"terms-conditions",className:"sr-only",children:"Terms and conditions"}),e.jsx(Se,{id:"terms-conditions",...r("termsAndConditions"),disabled:i})]}),e.jsxs("div",{className:"pl-4",children:["I have read and agree to be bound by"," ",e.jsxs(oe,{to:j,target:"_blank",children:[N," Terms and Conditions of Use"]})]})]}),!!((A=t==null?void 0:t.termsAndConditions)!=null&&A.message)&&e.jsx("span",{role:"alert",className:"text-xs text-error-500",children:(C=t==null?void 0:t.termsAndConditions)==null?void 0:C.message})]})]}),i&&e.jsx(re,{loading:!0,size:10}),d.length>0&&e.jsx("div",{children:e.jsx("div",{className:"justify-center text-md text-error-500 break-all",children:d})}),e.jsx("div",{className:"py-6",children:e.jsx(ae,{type:"submit",size:"custom",colour:"primary_v2",className:"w-full h-[71px]","aria-label":"complete registration next",disabled:i,children:e.jsx("span",{className:"flex items-center font-bold text-2xl",children:"Submit"})})})]})})}function vs({supportSiteLink:s,hidden:i}){const n=je();function c(){n(`/${Ne.login}`)}return e.jsxs("div",{className:ue("justify-center",{hidden:i}),children:[e.jsx("div",{className:"flex flex-col text-center p-4 text-md",children:e.jsx("span",{className:"p-4",children:"This link is invalid or expired. If you have completed registration, please sign in with your email and password. If you need further assistance, you can reach our customer service team using the link below."})}),e.jsx("div",{className:"flex justify-center pb-6",children:e.jsx(ae,{size:"custom",className:"w-full h-[71px]",colour:"primary_v2",onClick:c,children:e.jsx("span",{className:"flex items-center font-bold text-2xl",children:"Return to sign in"})})}),e.jsx(Ce,{supportSiteLink:s})]})}function ws({brandName:s,handleLaunchAppClick:i,mobileAppSupported:n,hidden:c,supportSiteLink:d}){return e.jsxs("div",{className:ue("justify-center",{hidden:c}),children:[e.jsx("div",{className:"flex flex-col text-center p-4 text-md",children:e.jsxs("span",{className:"p-4",children:["You can now log into the ",s," ",n&&"app or "," website to begin placing orders."]})}),e.jsx("div",{className:"flex justify-center pb-6",children:e.jsx(ae,{size:"custom",className:"w-full h-[71px]",colour:"primary_v2",onClick:i,children:e.jsx("span",{className:"flex items-center font-bold text-2xl",children:n?"Launch app":"Return to sign in"})})}),e.jsx(Ce,{supportSiteLink:d})]})}var Y=(s=>(s[s.RegistrationComplete=0]="RegistrationComplete",s[s.UserSetting=1]="UserSetting",s))(Y||{});const Cs="data:image/svg+xml,%3csvg%20id='Layer_1'%20data-name='Layer%201'%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%2060%2060'%3e%3cdefs%3e%3cstyle%3e.cls-1{fill:%23fff;}%3c/style%3e%3c/defs%3e%3ctitle%3euser-circle%3c/title%3e%3cpath%20class='cls-1'%20d='M30,12.23A11.23,11.23,0,1,0,41.22,23.45,11.22,11.22,0,0,0,30,12.23Zm0,16.83a5.61,5.61,0,1,1,5.61-5.61A5.62,5.62,0,0,1,30,29.06ZM30,1A29,29,0,1,0,59,30,29,29,0,0,0,30,1Zm0,52.39a23.25,23.25,0,0,1-15.22-5.66,10.07,10.
107,0,0,1,8.14-4.62A23.74,23.74,0,0,0,30,44.23a23.41,23.41,0,0,0,7.07-1.12,10.12,10.12,0,0,1,8.14,4.62A23.24,23.24,0,0,1,30,53.39Zm19-9.84a15.51,15.51,0,0,0-12.29-6.07c-1.19,0-3,1.13-6.73,1.13s-5.55-1.13-6.74-1.13A15.54,15.54,0,0,0,11,43.55,23.18,23.18,0,0,1,6.61,30a23.39,23.39,0,1,1,46.77,0A23.18,23.18,0,0,1,49,43.55Z'/%3e%3c/svg%3e",Is=()=>Ie().shape({dailySpendLimit:is().typeError("Please enter a number").moreThan(-1,"Please enter a positive value.")}),Ks=({studentDetails:s,isInEditMode:i,shouldSaveComponent:n,setShouldSaveComponent:c,calledFrom:d,setRegoSaveDetails:r,setStudentDetails:o,componentErrors:t,setComponentErrors:T})=>{const{brandConfiguration:{allowIndividualDailySpendLimit:N}}=te(),j=a.useRef(null),[y,m]=a.useState(i),p=()=>{j.current&&j.current.handleSubmit()};a.useEffect(()=>{m(i)},[i]),a.useEffect(()=>{n===!0&&p()},[n]);const[S,l]=a.useState(!1),[I,K]=a.useState(null),[L,g]=a.useState(null),[G,E]=a.useState(""),[x,A]=a.useState(null),[,C]=a.useState(s&&s.schoolKey),[R]=a.useState({cardDistributionId:null,cardDomainId:null,cardDomainKey:null,cardTypeId:null,cardTypeKey:null}),{data:P}=rs(s&&s.userKey),{data:M}=ne(G),{data:k}=ne(s&&s.userKey),{data:U}=ne(s&&s.userKey);a.useEffect(()=>{M?A(M.getUserAccount):k?A(k.getUserAccount):U&&A(U.getUserAccount)},[M,k,U]),a.useEffect(()=>{s&&C(s.schoolKey),P!=null&&P.parentKey&&E(P.parentKey)},[s,P==null?void 0:P.parentKey]);const{data:f}=De(R.cardTypeKey),V=a.useCallback(b=>{l(b===ie.UserManuallyEnter||b===ie.PreLinkedToUserID)},[]);a.useEffect(()=>{s.cardInfo&&s.cardInfo.cardDistributionId&&V(s.cardInfo.cardDistributionId)},[s,V]);const[ee]=X(es,{onCompleted:()=>{m(!1),o({...s,dailySpendLimit:L})},errorPolicy:"all"}),[D]=X(ss,{onCompleted:()=>{m(!1),o({...s,cardNumber:I})},errorPolicy:"all"}),[u]=X(ts,{onCompleted:()=>{m(!1),o({...s,cardNumber:I})},errorPolicy:"all"}),[v]=X(as,{onCompleted:()=>{m(!1),o({...s,cardNumber:I})},onError:()=>{},errorPolicy:"all"}),w=b=>{b.preventDefault(),ls({title:Ee,line1:f&&f.getCardType.instructions,line2:Be,hasCloseButton:!0})},q=b=>{const{studentKey:F,studentId:W,dailySpendLimit:J,cardNumber:_}=b,h=J!==""&&J!==void 0&&parseInt(J)>=0?J:-1;h&&h!==s.dailySpendLimit&&(g(h),ee({variables:{userKey:F,userId:Number(W.toString()),dailySpendLimit:Number(parseFloat(h.toString()).toFixed(2))}})),_&&!s.cardNumber?(K(_),x&&v({variables:{studentKey:F,studentId:W,cardNumber:_.trim(),accountKey:x.accountKey,accountId:x.accountId,distributionEntityId:"0",distributionMethodId:s.cardInfo.cardDistributionId,cardDomainKey:s.cardInfo.cardDomainKey,cardDomainId:s.cardInfo.cardDomainId,cardTypeKey:s.cardInfo.cardTypeKey,cardTypeId:s.cardInfo.cardTypeId,schoolKey:s.schoolKey}})):_&&s.cardNumber?(K(_),x&&D({variables:{studentKey:F,oldCardNumber:s.cardNumber,accountKey:x.accountKey,accountId:x.accountId,newCardNumber:_,distributionEntityId:"0",distributionMethodId:s.cardInfo.cardDistributionId,cardDomainKey:s.cardInfo.cardDomainKey,cardDomainId:s.cardInfo.cardDomainId,cardTypeKey:s.cardInfo.cardTypeKey,cardTypeId:s.cardInfo.cardTypeId,schoolKey:s.schoolKey}})):(K(null),x&&s.cardNumber&&u({variables:{studentKey:F,studentCardKey:s.cardKey,distributionMethodId:s.cardInfo.cardDistributionId}}))},B=b=>b?b===-1?"":parseFloat(b.toString()).toFixed(2):b===0?parseFloat(b.toString()).toFixed(2):"",z=b=>{r({dailySpendLimit:b.dailySpendLimit?b.dailySpendLimit:-1,accountKey:x&&x.accountKey,accountId:x&&x.accountId,cardNumber:b.cardNumber,cardInfo:s.cardInfo})};return s?e.jsxs("div",{className:"flex w-full",children:[e.jsx("div",{className:"w-11 h-11 flex items-center justify-center p-2",children:e.jsx("img",{src:Cs,alt:"building",className:"w-8 bg-primary-500 rounded"})}),(S||N)&&e.jsx(Ke,{enableReinitialize:!0,initialValues:{studentId:s.userId,studentKey:s.userKey,cardNumber:s.cardNumber?s.cardNumber:"",email:s.email,dailySpendLimit:B(s.dailySpendLimit)},onSubmit:b=>{d===Y.RegistrationComplete?z(b):q(b),c(!1)},ref:j,validationSchema:Is,children:b=>{const{values:F,errors:W,touched:J,handleChange:_,handleBlur:h}=b;return e.jsxs("form",{className:"w-full p-2",children:[S&&e.jsxs("div",{className:"py-2",children:[e.jsx(fe,{onChange:O=>{_(O),t&&(T(null),r(null))},onBlur:h,value:F.cardNumber,type:"cardNumber",name:"cardNumber",id:"cardNumber",labelVisible:!0,label:Te,disabled:!x||!y,controlled:!0,fontIcon:ns.faQuestionCircle,onClickIcon:O=>w(O)}),y&&t&&(t==null?void 0:t.cardError)&&e.jsx(se,{id:"cardNumberError",children:t.cardError})]}),N&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"py-2",children:[e.jsx(fe,{onChange:_,onBlur:h,value:y?F.dailySpendLimit:F.dailySpendLimit===""?"":"$ "+B(F.dailySpendLimit),type:"dailySpendLimit",name:"dailySpendLimit",id:"dailySpendLimit",labelVisible:!0,label:Ae,disabled:!y,controlled:!0}),y&&J.dailySpendLimit&&W.dailySpendLimit&&e.jsx(se,{id:"dailySpendLimitError",children:W.dailySpendLimit})]}),W&&c(!1)]})]})}})]}):null},Ls="data:image/svg+xml,%3csvg%20id='Layer_1'%20data-name='Layer%201'%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%2060%2060'%3e%3cdefs%3e%3cstyle%3e.cls-1{fill:%23fff;}%3c/style%3e%3c/defs%3e%3ctitle%3eschool%3c/title%3e%3cpath%20class='cls-1'%20d='M34.35,38.7h-8.7a1.44,1.44,0,0,0-1.45,1.45v11.6a1.44,1.44,0,0,0,1.45,1.45h8.7a1.45,1.45,0,0,0,1.45-1.45V40.15A1.45,1.45,0,0,0,34.35,38.7ZM30,17.68a8,8,0,1,0,8,8A8,8,0,0,0,30,17.68Zm4.35,10.15a.73.73,0,0,1-.73.72H29.27a.72.72,0,0,1-.72-.72V22a.72.72,0,0,1,.72-.73h1.45a.73.73,0,0,1,.73.73v3.62h2.17a.73.73,0,0,1,.73.73ZM56.1,24.2H47.4V19.37A2.91,2.91,0,0,0,46.1,17L31.6,7.29a2.87,2.87,0,0,0-3.21,0L13.89,17a2.91,2.91,0,0,0-1.29,2.42V24.2H3.9A2.9,2.9,0,0,0,1,27.1V51.75A1.44,1.44,0,0,0,2.45,53.2H3.9a1.45,1.45,0,0,0,1.45-1.45V28.55H12.6V53.2H17V20.14L30,11.44l13,8.7V53.2H47.4V28.55h7.25v23.2A1.44,1.44,0,0,0,56.1,53.2h1.45A1.45,1.45,0,0,0,59,51.75V27.1A2.9,2.9,0,0,0,56.1,24.2Z'/%3e%3c/svg%3e",Rs=()=>Ie().shape({site:de().test("site-match",Me,function(){return this.parent.site&&this.parent.site!=="-1"}),locationGroup:de().test("LocationGroup-match",Ge,function(){return this.parent.locationGroup&&this.parent.locationGroup!=="-1"}),location:de().test("Location-match",ke,function(){return this.parent.location&&this.parent.location!=="-1"})}),Ps=({studentDetails:s,isInEditMode:i,shouldSaveComponent:n,setShouldSaveComponent:c,calledFrom:d,setRegoSaveDetails:r})=>{const o=a.useRef(null),[t,T]=a.useState(i),N=()=>{o.current&&o.current.handleSubmit()};a.useEffect(()=>{T(i)},[i]),a.useEffect(()=>{n===!0&&N()},[n]);
1const[j,y]=a.useState(s&&s.businessDetails),[m,p]=a.useState(s&&s.businessDetails&&s.businessDetails.businessSites),[S,l]=a.useState(null),[I,K]=a.useState(null),[L,g]=a.useState(null),[G,E]=a.useState(null),[x,A]=a.useState(null),[C,R]=a.useState(null),[P,M]=a.useState(!1),{data:k}=he(cs,{onCompleted:()=>{},onError:()=>{},variables:{siteKey:I},skip:!I}),{data:U}=he(ds,{onCompleted:()=>{},onError:()=>{},variables:{locationGroupKey:L},skip:!L}),[f]=X(ms,{onCompleted:()=>{},onError:()=>{}});a.useEffect(()=>{var u;s&&d===Y.UserSetting&&(E(s.locationKey),g(s.locationGroupKey),K(s.businessSiteKey),M(!0)),d===Y.RegistrationComplete&&(y(s.businessDetails),p((u=s==null?void 0:s.businessDetails)==null?void 0:u.businessSites))},[s,d]),a.useEffect(()=>{m&&(m.length===1&&K(m[0].businessSiteKey),l(m.map(u=>({name:u.businessSiteName,value:u.businessSiteKey}))))},[m]),a.useMemo(()=>{k&&(k.getBusinessLocationGroups.length===1&&g(k.getBusinessLocationGroups[0].locationGroupKey),A(k.getBusinessLocationGroups.map(u=>({name:u.locationGroupName,value:u.locationGroupKey}))))},[k]),a.useMemo(()=>{U&&(U.getBusinessLocations.length===1&&E(U.getBusinessLocations[0].locationKey),R(U.getBusinessLocations.map(u=>({name:u.locationName,value:u.locationKey}))))},[U]);const V=(u,v,w)=>{v(u),w(u.target.value)},ee=u=>{const v=U&&U.getBusinessLocations.find(w=>w.locationKey===u.location).locationId;v&&r({userKey:s.userKey,userId:s.userId,locationKey:u.location,locationId:v,businessKey:s.schoolKey})},D=u=>{const v=U&&U.getBusinessLocations.find(w=>w.locationKey===u.location).locationId;v&&f({variables:{userKey:s.userKey,locationId:v,locationKey:u.location}})};return e.jsxs("div",{className:"flex w-full",children:[e.jsx("div",{className:"w-11 h-11 flex items-center justify-center p-2",children:e.jsx("img",{src:Ls,alt:"building",className:"w-8 bg-primary-500 rounded"})}),(d===Y.RegistrationComplete&&S||d===Y.UserSetting&&L)&&e.jsx(Ke,{enableReinitialize:!0,initialValues:{site:P?I:S&&S.length===1?S[0].value:"",locationGroup:P?L:"",location:P?G:""},onSubmit:u=>{d===Y.RegistrationComplete?ee(u):D(u),c(!1)},ref:o,validationSchema:Rs,children:u=>{const{values:v,errors:w,handleChange:q,handleBlur:B}=u;return e.jsxs("form",{className:"w-full p-2",children:[e.jsxs("div",{className:"py-2",children:[e.jsx(me,{name:"site",id:"site",options:S,onChange:z=>{V(z,q,g),v.locationGroup="",v.location=""},onBlur:B,labelVisible:!0,label:j==null?void 0:j.businessName,value:v.site,disabled:!t}),t&&w.site&&e.jsx(se,{id:"siteError",children:w.site})]}),e.jsxs("div",{className:"py-2",children:[e.jsx(me,{name:"locationGroup",id:"locationGroup",options:x,onChange:z=>{V(z,q,g),v.location=""},onBlur:B,labelVisible:!0,label:Fe,value:v.locationGroup,disabled:!t}),t&&w.locationGroup&&e.jsx(se,{id:"locationGroupError",children:w.locationGroup})]}),e.jsxs("div",{className:"py-2",children:[e.jsx(me,{name:"location",id:"location",options:C,onChange:z=>{V(z,q,E)},onBlur:B,labelVisible:!0,label:Ve,value:v.location,disabled:!t}),t&&w.location&&e.jsx(se,{id:"locationError",children:w.location})]}),w&&c(!1)]})}})]})},Us=_e(),Ts=({userKey:s,userId:i,userDetails:n,setUserDetails:c,isEditable:d,setIsEditable:r,isBusinessUser:o,calledFrom:t,setRegoFormSubmitted:T})=>{const[N,j]=a.useState(!1),[y,m]=a.useState(!1),[p,S]=a.useState(null),[l,I]=a.useState(null),[K,L]=a.useState(null),[g,G]=a.useState(!1),[E,x]=a.useState(!1),[A,{loading:C}]=X(us,{onCompleted:()=>{T(!0)},onError:f=>{L({cardError:He(f)[0]})}}),{data:R}=ne(s),[P,{data:M}]=ye(ps,{onError:()=>{},onCompleted:f=>{const V={...n,schoolKey:f.getUserBusiness.businessKey,businessDetails:f.getUserBusiness,cardInfo:{cardDomainId:f.getUserBusiness.cardDomainId,cardDomainKey:f.getUserBusiness.cardDomainKey,cardTypeId:f.getUserBusiness.cardTypeId,cardTypeKey:f.getUserBusiness.cardTypeKey,cardDistributionId:f.getUserBusiness.cardDistributionMethodId}};c(V),x(!0)}});a.useEffect(()=>{o&&(g&&l||!g)&&p&&(r==null||r(!1),A({variables:{userKey:p.userKey,userId:p.userId,locationKey:p.locationKey,locationId:p.locationId,dailySpendLimit:l&&l.dailySpendLimit?Number(parseFloat(l.dailySpendLimit.toString()).toFixed(2)):-1,distributionEntityId:"0",distributionMethodId:l?l.cardInfo.cardDistributionId:M.getUserBusiness.cardDistributionMethodId,accountKey:l?l.accountKey:R.getUserAccount.accountKey,accountId:l?l.accountId:R.getUserAccount.accountId,businessKey:p&&p.businessKey,cardNumber:l?l.cardNumber:"",cardDomainKey:l&&l.cardInfo.cardDomainKey,cardDomainId:l&&l.cardInfo.cardDomainId,cardTypeKey:l&&l.cardInfo.cardTypeKey,cardTypeId:l&&l.cardInfo.cardTypeId}}))},[l,p,A,o,g,r,R,M==null?void 0:M.getUserBusiness.cardDistributionMethodId]);const[k]=ye(os,{onCompleted:f=>{c({...n,cardInfo:{cardDomainId:f.getSchool.cardDomainId,cardDomainKey:f.getSchool.cardDomainKey,cardTypeId:f.getSchool.cardTypeId,cardTypeKey:f.getSchool.cardTypeKey,cardDistributionId:f.getSchool.cardDistributionMethodId}})}});a.useEffect(()=>{if(o&&s){P({variables:{userKey:s}});return}n&&n.schoolKey&&k({variables:{schoolKey:n.schoolKey}})},[n,s,P,k,o]),a.useEffect(()=>{N&&(g&&y||!g)&&(r==null||r(!1))},[N,y,g,r]),a.useEffect(()=>{n&&n.cardInfo&&(Us.brandConfiguration.allowIndividualDailySpendLimit||n.cardInfo.cardDistributionId===ie.UserManuallyEnter||n.cardInfo.cardDistributionId===ie.PreLinkedToUserID)&&G(!0)},[n]),a.useEffect(()=>{!N&&!y&&(r==null||r(!1))},[N,y,r]),a.useEffect(()=>{s&&c({userKey:s,userId:i})},[s,c,i]);const U=()=>{const f=()=>{j(!0),m(!0)};return e.jsx("div",{className:"w-full flex pt-2 justify-center",children:e.jsx("div",{className:"py-6 min-w-[350px] w-full lg:max-w-[442px]",children:e.jsx(ae,{colour:"primary_v2",type:"submit",size:"custom",className:"w-full h-[71px]",onClick:()=>f(),disabled:C,children:e.jsx("span",{className:"flex items-center font-bold text-xl font-manrope",children:"Save"})})})})};return e.jsxs("div",{className:"flex flex-col rounded h-full text-neutral-500 justify-center items-center w-full",children:[o&&E&&e.jsx(Ps,{setDisplayComponent:null,studentDetails:n,setStudentDetails:c,isInEditMode:d,shouldSaveComponent:N,setShouldSaveComponent:j,calledFrom:t,setRegoSaveDetails:S}),g?e.jsx(Ks,{setDisplayComponent:null,studentDetails:n,setStudentDetails:c,isInEditMode:d,shouldSaveComponent:y,setShouldSaveComponent:m,calledFrom:t,setRegoSaveDetails:I,componentErrors:K,setComponentErrors:L}
1):null,d&&U(),C&&e.jsx(re,{loading:C})]})};function As({userKey:s,tocaUserId:i,isBusinessUser:n,handleSubmitted:c}){const[d,r]=a.useState({});return e.jsxs("div",{className:"justify-center",children:[e.jsx("div",{className:"flex flex-col text-center p-2 text-md",children:e.jsx("span",{className:"p-4",children:"To complete registration, please provide the following details."})}),e.jsx(Ts,{userKey:s,userId:i,isEditable:!0,userDetails:d,setUserDetails:r,isBusinessUser:n,calledFrom:Y.RegistrationComplete,setRegoFormSubmitted:c})]})}function Bs(){const s=je(),[i,n]=a.useState(!1),[c,d]=a.useState(!1),[r,o]=a.useState(!1),[t,T]=a.useState(!1),[N,j]=a.useState(!1),[y,m]=a.useState(!1),[p,S]=a.useState(!0),[l,I]=a.useState(""),[K,L]=a.useState(""),[g,G]=a.useState(""),[E,x]=a.useState(null),[A,C]=a.useState(""),[R,P]=a.useState(!0),M=Qe,k=ze(),f=new URLSearchParams(k.search).get("code"),{brandConfiguration:{name:V,supportSiteLink:ee,mobileAppSupported:D,launchAppLink:u,userAsParent:v}}=te(),w=!v,{error:q,data:B}=ys(f);a.useEffect(()=>{B&&B.verifyUser&&(I(B.verifyUser.emailAddress),G(B.verifyUser.userKey),x(B.verifyUser.userId),P(B.verifyUser.isParent),m(!1),S(!1),Oe.get(Ze)||le.setUserKey(B.verifyUser.userKey),T(!0))},[B]);const[z]=X(gs,{onCompleted:h=>{h.completeUserRegistration&&d(!0)},onError:h=>{C(Ye(h))},errorPolicy:"none"}),{mutate:pe}=fs({mutationFn:h=>hs(g,h),onMutate:()=>{m(!0)},onSuccess:()=>{le.scrollToTop(),n(!0),T(!1)},onError:()=>{C("There was an error. Please try again.")},onSettled:()=>{m(!1)}});a.useEffect(()=>{c&&K!==""&&(async()=>{try{const{isSignedIn:O}=await $e(l,K);if(!O){C("Something went wrong.");return}le.scrollToTop(),w?j(!0):(n(!0),ce()),T(!1),m(!1)}catch(O){console.error(O),C("Something went wrong.")}})()},[c,K,R,v,w,l]);const b=h=>{pe({password:h.password})};async function F(h){m(!0);try{L(h.password);const O={userKey:g,email:l,password:h.password,title:h.title,firstName:h.firstName,lastName:h.lastName,contactNumber:h.phoneNumber,dateOfBirth:null};await z({variables:{completeUserRegistrationInput:O}})}catch{C("There was an error. Please try again.")}m(!1)}return{hasCompletedRego:i,showAddStudent:r,showUserSettings:N,showRegoForm:t,isSubmitting:y,isLoading:p,verifyUserError:q,email:l,titleOptions:M,userKey:g,tocaUserId:E,isUserParent:R,brandName:V,supportSiteLink:ee,isBusinessUser:w,mobileAppSupported:D,errorMessage:A,handleSubmitCompleteRego:F,handleStudentAdded:()=>{o(!1),n(!0),ce()},handleUserSettingsSubmitted:()=>{o(!1),j(!1),n(!0),ce()},handleLaunchAppClick:()=>{D?window.open(u,"_blank"):s(`/${Ne.login}`)},handleInternationalSubmitCompleteRego:b}}function Rt(){const{showRegoForm:s,showAddStudent:i,verifyUserError:n,hasCompletedRego:c,isSubmitting:d,isLoading:r,email:o,titleOptions:t,userKey:T,tocaUserId:N,isUserParent:j,isBusinessUser:y,showUserSettings:m,brandName:p,supportSiteLink:S,mobileAppSupported:l,errorMessage:I,handleSubmitCompleteRego:K,handleStudentAdded:L,handleUserSettingsSubmitted:g,handleLaunchAppClick:G,handleInternationalSubmitCompleteRego:E}=Bs(),{brandConfiguration:{isFlexiInternational:x}}=te();function A(R){K({password:R.password,title:R.title,firstName:R.firstName,lastName:R.lastName,phoneNumber:R.phoneNumber})}const C=n?"Invalid link":s?"Complete registration":i?"Add student":c?"Registration successful":"Complete registration!";return e.jsxs(We,{titleSection:C,children:[e.jsx(vs,{brandName:p,supportSiteLink:S,hidden:!n}),e.jsx(qe,{children:e.jsxs("title",{children:[p," - Complete registration"]})}),!n&&e.jsxs(e.Fragment,{children:[r&&e.jsxs("div",{children:[e.jsx("div",{className:"flex justify-center",children:e.jsx("div",{className:"flex text-center p-4",children:"Please wait while we fetch your details"})}),e.jsx("div",{children:e.jsx(re,{loading:!0,size:10})})]}),!r&&e.jsxs(e.Fragment,{children:[i&&e.jsx(Ss,{handleStudentAdded:L}),m&&e.jsx(As,{userKey:T,tocaUserId:N,handleSubmitted:g,isBusinessUser:y}),s&&(x?e.jsx(bs,{onSubmit:E,isSubmitting:d,email:o,errorMessage:I}):e.jsx(Ns,{onSubmit:A,isSubmitting:d,email:o,titleOptions:t,errorMessage:I,isUserParent:j}))]}),e.jsx(ws,{brandName:p,hidden:!c,supportSiteLink:S,handleLaunchAppClick:G,mobileAp
1pSupported:l})]})]})}export{Rt 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.