1import{g as E,w as V,F as t,u as C,a0 as R,x as k,r as N,_ as L,cM as H,j as e,Z as O,ar as g,bk as q,t as B,f as S,e as G,eU as U,e6 as K,hL as Q,hM as W,K as X,N as Z,hN as j,v as z,hw as J,hQ as b,V as Y}from"./index-Ba5x2QVK.js";import{m as $}from"./mask-C_75mL8D.js";import{i as ee}from"./index-BrEeQElA.js";import{a as se,c as ae}from"./index-1fWfMvbH.js";import{i as te}from"./isSystemError-DDyjMtQT.js";import{D as re,C as oe}from"./index-exxK9ZiN.js";import{R as ne}from"./index-DukL8iXu.js";import{d as ie}from"./selector-C3WOBBh4.js";const{Text:r}=B,le=()=>{const{isMobileView:o}=E(),s=V(),[n]=t.useForm(),{t:i}=C("financialConsents"),y=R(),A=k(),l=y.state?.isMHAAvailable,[v,F]=N.useState(!1),p=L(ie),{data:a,error:c,isFetching:I,refetch:x}=se(void 0,{refetchOnMountOrArgChange:!0}),M=te(c?.message),[T,{isLoading:d}]=ae(),[P,u]=H(!1),_=()=>{F(ee({form:n})&&n.getFieldValue("tnc"))};N.useEffect(()=>{a&&n.setFieldsValue({nric:a?.CpfNumber?$(a.CpfNumber,"X",1,5):""})},[a,n]);const f=()=>{const m=n.getFieldsValue();return{Name:m.name??a?.Name,ResidencyStatus:m.residency??a?.ResidencyStatus}},h=()=>{A(J.setDataValues(f()))},w=async()=>{try{await T(f()).unwrap()&&!d&&s(b)}catch(m){const D=m;h(),s({pathname:b},{state:{error:D,isMHAAvailable:l,isPreviousMcaf:!1}})}finally{u()}};return I?e.jsx("div",{className:g("flex gap-5 flex-col",o&&"p-5"),children:e.jsx(O.Button,{active:!0,className:"h-28 w-full rounded-2xl"})}):e.jsx(q,{apiErrorProps:{code:c?.code,errorScreenProps:{errorCode:c?.code,errorMsg:"Please try again later",onRefresh:()=>{x()},stack:c?.code},message:c?.message},systemErrorProps:{isError:M,systemErrorScreenProps:{onRetry:()=>{x()}}},children:e.jsx(t,{form:n,initialValues:{...!l&&{name:p?.Name,residency:p?.ResidencyStatus}},layout:"vertical",onFieldsChange:_,children:e.jsxs("div",{className:g("rounded-xl bg-white p-4",o&&"rounded-none"),children:[e.jsxs("div",{className:"gap-4",children:[e.jsxs("div",{className:"flex flex-col",children:[e.jsx(r,{className:"font-semibold",children:i("form.header")}),e.jsx(r,{className:"text-secondary-gray",children:i("form.subHeader")})]}),e.jsx(t.Item,{name:"nric",required:!0,children:e.jsx(S,{className:"mt-4 lg:w-1/2",disabled:!!a?.CpfNumber,inputClassName:"h-20 [&_input]:mt-6 lg:h-14 lg:[&_input]:mt-auto",placeholder:"NRIC Birth Certificate / FIN / Special Pass / Foreign Passport Number",required:!0})}),!l&&e.jsxs(e.Fragment,{children:[e.jsx(t.Item,{name:"name",required:!0,children:e.jsx(S,{className:"lg:w-1/2",isShowBottomRequiredText:!0,placeholder:"Applicantâs Name",required:!0})}),e.jsx(t.Item,{label:e.jsx(r,{className:"text-base",children:i("form.residencyStatus")}),name:"residency",required:!0,children:e.jsx(G,{options:ne})})]}),e.jsx(t.Item,{name:"tnc",valuePropName:"checked",children:e.jsx(U,{children:e.jsx(r,{className:"text-base text-functional-iron",children:e.jsx(K,{components:{1:e.jsx(r,{className:"text-red-500"}),2:e.jsx(r,{className:"font-semibold text-secondary-blue",onClick:()=>{h(),s({pathname:W},{state:{isMHAAvailable:l,isPreviousMcaf:!1}})}}),3:e.jsx(r,{className:"font-semibold text-secondary-blue",onClick:()=>{h(),s({pathname:Q},{state:{isMHAAvailable:l,isPreviousMcaf:!1}})}})},i18nKey:i("tnc")})})})})]}),e.jsx(X,{className:"m-0"}),e.jsxs("div",{className:"mt-4 flex flex-col",children:[e.jsx(re,{name:"datasharing",url:"https://www.moh.gov.sg/mcaf?action=externallink"}),e.jsx(t.Item,{noStyle:!0,shouldUpdate:!0,children:e.jsx(Z,{cancelDisabled:d,cancelText:i("Cancel"),className:"json-checked mt-4",handleCancel:()=>{s(j)},handleSubmit:()=>{u()},isLoading:d,okDisabled:!v,okText:i("Submit")})})]}),e.jsx(z,{centered:!0,closable:!1,footer:null,open:P,children:e.jsx(oe,{handleCancel:()=>{u()},handleSubmission:w,isLoading:d})})]})})})},ge=()=>{const{t:o}=C("financialConsents"),s=[{path:j,title:o("header")},{title:o("consentDataSharing.header")}];return e.jsx(Y,{breadcrumbs:{portal:{breadcrumbsDetails:s}},title:o("consentDataSharing.header"),children:e.jsx(le,{})})};export{ge 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.