1import{_ as ce}from"./Button.d440f86c.js";import{_ as pe}from"./FormInput.515e311a.js";import{_ as Fe}from"./Spinner.vue.f31c9bdb.js";import{l as Ce,T as Ee}from"./ui.165de282.js";import{d as G,q as A,x as Ie,o as p,h,F as ae,B as oe,t as M,C as W,b as y,w as q,m as a,J as ie,i as re,c as z,j as Q,f as Pe,I as ne,u as me,O as te,P as le,s as ke,v as ue,k as xe,l as qe,r as P,a0 as $e,g as Se,n as Be,z as Me,_ as Le}from"./entry.6a43b9f0.js";import{_ as Ue}from"./ShadowBox.vue.c439f190.js";import{_ as Re}from"./PasswordRule.vue.fd797d08.js";import{_ as Ve}from"./client-only.5ae86b34.js";import{u as Te}from"./masterList.10ae10dc.js";import"./_plugin-vue_export-helper.c27b6911.js";import"./arrow_drop_up.efadab59.js";import"./check.400ede29.js";const Oe={key:0,class:"mb-24 body-2-d text-error font-bold"},Ae={class:"flex items-center flex-col-reverse md:flex-row"},Ne=G({__name:"EditDynamicForm",props:{formId:{},fields:{},loading:{type:Boolean},backendErrors:{},buttonText:{},cancelButtonText:{},buttonDisabled:{type:Boolean}},emits:["submit","handleCancel","submit-invalid","chooseSelectOption"],setup(N,{emit:e}){const I=N,r=A(null);function u(i){let k=Object.keys(i);I.fields.filter(g=>k.includes(g.model)&&g.type=="dropdown").forEach(g=>{i[g.model]=i[g.model][g.model]}),e("submit",i)}var _=Ce(function(i){u(i)},Ee);function Y(i){e("handleCancel",i)}function L(i){e("submit-invalid",i)}return(i,k)=>{const $=pe,g=ce,m=Fe,D=Ie("FormKit");return p(),h("div",null,[i.backendErrors?(p(),h("div",Oe,[(p(!0),h(ae,null,oe(i.backendErrors,(x,S)=>(p(),h("p",{class:"mb-8",key:S},M(x),1))),128))])):W("",!0),y(D,{ref_key:"form",ref:r,type:"form",id:i.formId,actions:!1,onSubmit:a(_),onSubmitInvalid:L,class:"text-center","incomplete-message":!1,config:{validationVisibility:"submit"}},{default:q(()=>[(p(!0),h(ae,null,oe(i.fields,({label:x,model:S,value:Z,errorMessages:f,validations:v,type:F,hideError:U,validationVisibility:X,hint:n,placeholder:C,onBlur:E,options:j,disabled:K})=>(p(),h("div",{class:"relative",key:S},[y($,{type:F||"text",label:x,inputKey:S,value:Z,validations:v,messages:f,hideError:U,validationVisibility:X,hint:n,placeholder:C,options:j,disabled:K,onBlur:H=>E?E(a(r)):null},null,8,["type","label","inputKey","value","validations","messages","hideError","validationVisibility","hint","placeholder","options","disabled","onBlur"])]))),128)),ie(i.$slots,"default"),ie(i.$slots,"actionButtons",{},()=>[re("div",Ae,[y(g,{type:"tertiary",desktopSize:"m",mobileSize:"s",value:i.cancelButtonText,onClick:k[0]||(k[0]=x=>Y(a(r))),class:"md:mr-24 w-full md:w-auto px-32 py-16",reset:""},null,8,["value"]),i.loading?(p(),z(m,{key:0,class:"w-20 h-20"})):(p(),z(D,{key:1,type:"submit",classes:{input:"primary s md:m w-full md:w-auto px-32 py-16 mt-24",wrapper:"text-center",outer:"w-full md:w-auto mb-16 md:mb-24"}},{default:q(()=>[Q(M(i.buttonText),1)]),_:1}))])])]),_:3},8,["id","onSubmit"])])}}}),Ye=["value"],He={key:2,class:"w-full text-black body-2-d font-medium break-all"},ze=G({__name:"ViewFormInput",props:{label:{},value:{},type:{},hint:{},options:{}},setup(N){const e=N,I=Pe(()=>e.value?e.value:"-");return(r,u)=>{const _=pe;return p(),h("div",{class:ne(["md:basis-9/12 text-right xl:text-left",{"basis-1/2 xl:pl-32":r.type!="radio"}])},[r.type==="password"?(p(),h("input",{key:0,class:"bg-white w-full border-none text-black body-2-d font-medium px-0",type:"password",value:r.value,disabled:""},null,8,Ye)):r.type==="radio"?(p(),z(_,{key:1,type:r.type,label:r.label,value:r.value,hint:r.hint,options:r.options,inputKey:"readOnly",disabled:!0,validations:null},null,8,["type","label","value","hint","options"])):(p(),h("p",He,M(a(I)),1))],2)}}}),De={key:0,class:"basis-1/2 md:basis-3/12 bg-white body-2-d text-black-700 font-normal"},je=G({__name:"ViewDynamicForm",props:{fields:{}},setup(N){return(e,I)=>{const r=ze;return p(),h("div",null,[(p(!0),h(ae,null,oe(e.fields,u=>(p(),h("div",{class:ne(["flex flex-row flex-wrap basis-full items-center pt-24 border-solid border-black-300",{"border-b":u.type!=="radio","pb-16":u.type!=="radio"}]),key:u.label},[u.type!=="radio"?(p(),h("label",De,M(u.label),1)):W("",!0),y(r,{label:u.label,type:u.type,value:u.value,options:u.options,hint:u.hint}
1,null,8,["label","type","value","options","hint"])],2))),128))])}}}),Ke={class:"flex justify-between heading-3-m md:heading-4-d text-black"},Ge=G({__name:"Card",props:{title:{},formId:{},loading:{type:Boolean},viewFields:{},editFields:{},editFormErrors:{}},emits:["handleSubmit","handleOption","handleSubmitInvalid","handleBackToViewForm"],setup(N,{emit:e}){const I=me();let r=A(!1);const u=I.t("profile.button.edit"),_=I.t("profile.button.confirm"),Y=I.t("profile.button.cancel"),L=()=>{r.value=!0},i=m=>{e("handleSubmit",m,$)},k=m=>{e("handleSubmitInvalid",m)},$=()=>{r.value=!1,e("handleBackToViewForm")},g=m=>{e("handleOption",m)};return(m,D)=>{const x=ce,S=Ne;return p(),z(Ue,{class:"w-full"},{default:q(()=>[re("header",Ke,[Q(M(m.title)+" ",1),te(y(x,{value:a(u),type:"secondary",desktopSize:"s",mobileSize:"xs",class:"w-fit px-24 py-16 hidden md:inline-flex",onClick:L},{value:q(()=>[Q(M(a(u)),1)]),_:1},8,["value"]),[[le,!a(r)]])]),te(y(je,{fields:m.viewFields},null,8,["fields"]),[[le,!a(r)]]),a(r)?(p(),z(S,{key:0,class:"mt-24 md:mt-48 w-full md:w-9/12",formId:m.formId,fields:m.editFields,backendErrors:m.editFormErrors,buttonText:a(_),cancelButtonText:a(Y),loading:m.loading,onChooseSelectOption:g,onSubmit:i,onSubmitInvalid:k,onHandleCancel:$},{default:q(()=>[ie(m.$slots,"default")]),_:3},8,["formId","fields","backendErrors","buttonText","cancelButtonText","loading"])):W("",!0),te(y(x,{value:a(u),type:"secondary",desktopSize:"s",mobileSize:"xs",class:ne(["w-full px-24 py-16 md:hidden",{"mt-24":m.formId!=="notification-form"}]),onClick:L},{value:q(()=>[Q(M(a(u)),1)]),_:1},8,["value","class"]),[[le,!a(r)]])]),_:3})}}}),Je={class:"heading-1-m md:heading-1-d text-black mx-16 md:mx-0"},Qe={key:0,class:"basis-full md:basis-8/12"},dt=G({__name:"information",setup(N){const e=me(),I=ke(),{currentLocale:r}=ue(I),u=xe(),{useAsyncGqlRetry:_}=u,Y=Te(),{locationList:L,genderList:i,occupationList:k,birthYearList:$,experienceList:g,interestList:m}=ue(Y),{fetchProfileFilters:D,fetchPreferenceFilters:x}=Y,S=Be(),{i18nNavigatePath:Z}=qe();let f=A(),v=P({profile:!1,password:!1,information:!1,notification:!1});const F=P({minimumLength:null,specialCharacter:null,number:null,consecutiveCharacter:null}),U=l=>{F.minimumLength=l,F.specialCharacter=l,F.number=l,F.consecutiveCharacter=l},X=async l=>{U(!0),E.value=null;const s=l.node;Me(s).forEach((d,c)=>{if(c.name=="newPassword"){const w=c.value;let o=!1;d.map(T=>{switch(T.key){case"rule_length":F.minimumLength=!1,o=!0;break;case"rule_required":U(!1),o=!0;break;case"rule_matches":const O=/\d+/g;w.match(O)==null&&(F.number=!1,o=!0);const ee=/[\[\]!"#%&'()*+,-.\/:;<=>?@{}$|^_`~\\"]/g;w.match(ee)==null&&(F.specialCharacter=!1,o=!0);const _e=/.*(.)\1\1/g;w.match(_e)&&(F.consecutiveCharacter=!1,o=!0),o||(E.value="isValid");break}})}})},n={emailRequired:e.t("errorMessage.emailRequired"),emailInvalid:e.t("errorMessage.emailInvalid"),mobileRequired:e.t("errorMessage.mobileRequired"),mobileInvalid:e.t("errorMessage.mobileInvalid"),emailIsUsed:e.t("profile.pii.validation.emailIsUsed"),mobileIsUsed:e.t("profile.pii.validation.mobileIsUsed"),currentPasswordRequired:e.t("profile.password.validation.currentPasswordRequired"),currentPasswordInvalid:e.t("profile.password.validation.currentPasswordInvalid"),passwordRequired:e.t("profile.password.validation.passwordRequired"),confirmPasswordRequired:e.t("errorMessage.confirmPasswordRequired"),newPasswordNotMatch:e.t("errorMessage.newPasswordNotMatch"),isValid:e.t("errorMessage.passwordInvalidCharacter"),sameAsCurrent:e.t("errorMessage.passwordSameAsExisting"),minimumLengthInvalid:e.t("profile.password.validation.minimumLengthInvalid"),wrongCurrentPassword:e.t("profile.password.validation.currentPasswordInvalid"),required:e.t("errorMessage.isRequiredField"),general:e.t("errorMessage.general")},C=A(null),E=A(null),j=A(null),K=A(null),H=P({name:{label:e.t("profile.pii.name.label"),value:null,type:"text"},loginCredential:{label:e.t("profile.pii.loginCredential"),value:null,type:"text"},email:{label:e.t("profile.pii.email"),value:null,type:"email"},phone:{label:e.t("profile.pii.phone"),value:null,type:"text"}}),R=P({name:{type:"text",label:e.t("profile.pii.name.label"),model:"name",validations:null,value:null,disabled:!0,hint:e.t("profile.pii.name.hint")},loginCredential:{type:"text",label:e.t("profile.pii.loginCredential"),model:"loginCredential",validations:null,value:null,disabled:!0},email:{type:"text",label:e.t("profile.pii.email"),model:"email",errorMessages:{required:n.emailRequired,matches:n.emailInvalid},validations:[["matches",S.DEV?/^([\w\.\d\+\-]+@\w+\.[\w\.\d\+\-]+)$/:/^([\w\.\d\-]+@\w+\.[\w\.\d\+\-]+)$/]],value:null,disabled:!0},phone:{type:"tel",label:e.t("profile.pii.phone"),placeholder:null,hint:null,model:"mobile",errorMessages:{required:n.mobileRequired,matches:n.mobileInvalid},validations:[["matches",/^([2-9][0-9]{7})$/]],value:null,disabled:!0}}),ve=P({password:{label:e.t("profile.password.password"),value:"12345678a!",type:"password",model:"",validations:null}}),J=P({currentPassword:{type:"password",label:e.t("profile.password.currentPassword.label"),placeholder:e.t("profile.password.currentPassword.placeholder"),model:"currentPassword",errorMessages:{required:n.currentPasswordRequired,length:n.minimumLengthInvalid},validations:[["required"],["*length","8"]],value:null,disabled:!1},newPassword:{type:"text",label:e.t("profile.password.newPassword.label"),placeholder:e.t("profile.password.newPassword.placeholder"),model:"newPassword",errorMessages:{required:n.passwordRequired,length:n.minimumLengthInvalid,matches:n.isValid},validations:[["required"],["*length","8"],["*matches",/^(?!.*(.)\1\1)(?=.*\d)(?=.*[\[\]!"#%&'()*+,-.\/:;<=>?@{}$|^_`~\\"])[a-zA-Z\d\[\]!#%&'()*+,-.\/:;<=>?@{}$|^_`~\\"]{8,}$/]],value:null,disabled:!1,hideError:!0,onBlur:X},confirmPassword:{type:"text",label:e.t("profile.password.confirmPassword.label"),placeholder:e.t("profile.password.confirmPassword.placeholder"),model:"newPassword_confirm",errorMessages:{required:n.confirmPasswordRequired,confirm:n.newPasswordNotMatch},validations:[["required"],["*confirm"]],value:null,disabled:!1,onBlur:null}}),V=P({gender:{label:e.t("profile.pi.gender"),value:null,type:"text"},birthYear:{label:e.t("profile.pi.birthYear"),value:null,type:"text"},location:{label:e.t("profile.pi.district"),value:null,type:"text"},occupation:{label:e.t("profile.pi.occupation"),value:null,type:"text"},volunteerExperience:{label:e.t("profile.pi.volunteerExperience"),value:null,type:"text"},interests:{label:e.t("profile.pi.interests.label"),value:null,type:"text"}}),b=P({gender:{label:e.t("profile.pi.gender"),model:"gender",errorMessages:{required:n.required},validations:[["required"]],type:"dropdown",options:[],value:null,disabled:!1},birthYear:{label:e.t("profile.pi.birthYear"),model:"birthYear",errorMessages:{required:n.required},validations:[["required"]],type:"dropdown",options:[],value:null,disabled:!1},location:{label:e.t("profile.pi.district"),model:"district",errorMessages:{required:n.required},validations:[["required"]],type:"dropdown",options:[],value:null,disabled:!1},occupation:{label:e.t("profile.pi.occupation"),model:"occupation",errorMessages:{required:n.required},validations:[["required"]],type:"dropdown",options:[],value:null,disabled:!1},volunteerExperience:{label:e.t("profile.pi.volunteerExperience"),model:"volunteerExperience",errorMessages:{required:n.required},validations:[["required"]],type:"dropdown",options:[],value:null,disabled:!1},interests:{label:e.t("profile.pi.interests.label")+e.t("profile.pi.interests.hint"),model:"interests",errorMessages:{required:n.required,min:n.required},validations:[["required"],["min","1"]],type:"custom_checkbox",options:[],value:null,disabled:!1}}),se=P({notification:{type:"radio",value:"",label:e.t("profile.notification.jcvarUpdate"),options:[{value:"yes",label:e.t("profile.notification.yes"),attrs:{disabled:!0}},{value:"no",label:e.t("profile.notification.no"),attrs:{disabled:!0}}],hint:e.t("profile.notification.agreement")}}),de=P({notification:{type:"radio",value:"yes",disabled:!1,label:e.t("profile.notification.jcvarUpdate"),options:[{value:"yes",label:e.t("profile.notification.yes")},{value:"no",label:e.t("profile.notification.no")}],hint:e.t("profile.notification.agreement"),model:"notification",validations:null}}),B=l=>Object.values(l);$e(()=>f,async(l,s)=>{const t=l.value;if(t){R.name.value=H.name.value=t.name,R.loginCredential.value=H.loginCredential.value=t.loginCredential=="EMAIL"?e.t("profile.pii.email"):e.t("profile.pii.phone"),R.email.value=H.email.value=t.email,R.phone.value=H.phone.value=t.mobile,R.email.disabled=t.loginCredential=="EMAIL",R.phone.disabled=t.loginCredential=="MOBILE",b.birthYear.value=V.birthYear.value=t.birthYear,b.gender.value=t.gender,V.gender.value=e.t(`masterList.gender.${t.gender}`),b.location.value=t.location,V.location.value=e.t(`masterList.location.${t.location}`),b.occupation.value=t.occupation,V.occupation.value=e.t(`masterList.occupation.${t.occupation}`),b.volunteerExperience.value=t.yearsOfExp,V.volunteerExperience.value=e.t(`masterList.experience.${t.yearsOfExp}`),b.interests.value=t.interests;let d="";
1t.interests.forEach((c,w)=>{d+=w==0?"":", ",d+=e.t(`masterList.interests.${c}`)}),V.interests.value=d,se.notification.value=t.edmFlag?"yes":"no",de.notification.value=t.edmFlag?"yes":"no"}},{deep:!0});const fe=l=>{b[l.model].value=l.value.value},be=async(l,s)=>{v.profile=!0;let t,d;const{email:c,mobile:w}=l;if(c==f.value.email&&w==f.value.mobile){v.profile=!1,s();return}f.value.loginCredential==="EMAIL"&&(w==""?t="mobile":d="mobile"),f.value.loginCredential==="MOBILE"&&(c==""?t="email":d="email");try{if(t){const{data:o,error:T}=await _("volunteerRemoveContact",{contactField:t},{initialCache:!1});if(o.value){if(!o.value.volunteerRemoveContact.success)throw o.value.volunteerRemoveContact.message;f.value=o.value.volunteerRemoveContact.volunteer}else throw T.value.gqlErrors[0].message}else{C.value=null;const{data:o,error:T}=await _("volunteerUpdateContact",{updateContactInput:{method:d,language:r.value,loginAccount:l[d].toLowerCase()}},{initialCache:!1});if(o.value)if(o.value.volunteerUpdateContact.success)window.location.href=`${Z("profile/verification")}?credential=${encodeURIComponent(o.value.volunteerUpdateContact.requestAccount)}&method=${o.value.volunteerUpdateContact.method}`;else throw o.value.volunteerUpdateContact.message;else throw T.value.gqlErrors[0].message}s()}catch(o){o=="Email format is wrong"?C.value="emailInvalid":o=="Phone number format is wrong"?C.value="mobileInvalid":o=="Email address is not available"||o=="Email address is already signed up"?C.value="emailIsUsed":o=="Phone number is not available"||o=="Phone number is already signed up"||o=="Login credential cannot be edit"?C.value="mobileIsUsed":C.value="general"}v.profile=!1},we=async(l,s)=>{v.password=!0;const{currentPassword:t,newPassword:d}=l;try{const{data:c,error:w}=await _("volunteerUpdatePassword",{currentPassword:t,newPassword:d},{initialCache:!1});if(c.value){if(!c.value.volunteerUpdatePassword.success)throw c.value.volunteerUpdatePassword.message;f.value=c.value.volunteerUpdatePassword.volunteer}else throw w.value.gqlErrors[0].message;J.currentPassword.value=null,J.newPassword.value=null,J.confirmPassword.value=null,U(null),s()}catch(c){switch(c){case"Current password is not correct":E.value="wrongCurrentPassword";break;case"Password is the same as current password":E.value="sameAsCurrent";break;case"Your password contains unaccepted character(s)":E.value="isValid";break;default:E.value="general";break}}v.password=!1},he=async l=>{l.value.newPassword||U(!1)},ge=async(l,s)=>{v.information=!0;const{gender:t,birthYear:d,district:c,occupation:w,volunteerExperience:o,interests:T}=l;try{const{data:O,error:ee}=await _("volunteerUpdateProfile",{volunteerInformationInput:{gender:t,birthYear:parseInt(d),interests:T,occupation:w,location:c,experience:o}},{initialCache:!1});if(O.value){if(!O.value.volunteerUpdateProfile.success)throw O.value.volunteerUpdateProfile.message;f.value=O.value.volunteerUpdateProfile.volunteer}else throw ee.value.gqlErrors[0].message;s()}catch{j.value="general"}v.information=!1},ye=async(l,s)=>{v.notification=!0;const{notification:t}=l;if(t==(f.value.edmFlag?"yes":"no")){v.notification=!1,s();return}try{const{data:d,error:c}=await _("volunteerUpdateNotification",{notification:t!=="no"},{initialCache:!1});if(d.value){if(!d.value.volunteerUpdateNotification.success)throw d.value.volunteerUpdateNotification.message;f.value=d.value.volunteerUpdateNotification.volunteer}else throw c.value.gqlErrors[0].message;s()}catch{K.value="general"}v.notification=!1};return Se(async()=>{await new Promise(s=>setTimeout(s,100));const l=await _("getVolunteerProfile",{},{initialCache:!1});f.value=l?.data?.value?l.data.value.getCurrentVolunteer:null,(g.value.length==0||m.value.length==0)&&await x(),b.volunteerExperience.options=g.value,b.interests.options=m.value,(L.value.length==0||i.value.length==0||k.value.length==0||$.value.length==0)&&await D(),b.location.options=L.value,b.gender.options=i.value,b.occupation.options=k.value,b.birthYear.options=$.value}),(l,s)=>{const t=Ge,d=Re,c=Ve,w=Le;return p(),z(w,{name:"profile"},{default:q(()=>[re("h1",Je,M(l.$t("profile.title")),1),y(c,null,{default:q(()=>[a(f)?(p(),h("div",Qe,[y(t,{formId:"profile-form",loading:a(v).profile,title:l.$t("profile.pii.title"),viewFields:B(a(H)),editFields:B(a(R)),editFormErrors:[n[a(C)]],onHandleSubmit:be,onHandleBackToViewForm:s[0]||(s[0]=o=>C.value=null)},null,8,["loading","title","viewFields","editFields","editFormErrors"]),y(t,{formId:"password-form",loading:a(v).password,title:l.$t("profile.password.title"),viewFields:B(a(ve)),editFields:B(a(J)),editFormErrors:[n[a(E)]],onHandleSubmit:we,onHandleSubmitInvalid:he,onHandleBackToViewForm:s[1]||(s[1]=o=>{E.value=null,U(null)})},{default:q(()=>[y(d,{ruleStatus:a(F)},null,8,["ruleStatus"])]),_:1},8,["loading","title","viewFields","editFields","editFormErrors"]),y(t,{formId:"information-form",loading:a(v).information,title:l.$t("profile.pi.title"),viewFields:B(a(V)),editFields:B(a(b)),editFormErrors:[n[a(j)]],onHandleOption:fe,onHandleSubmit:ge,onHandleBackToViewForm:s[2]||(s[2]=o=>j.value=null)},null,8,["loading","title","viewFields","editFields","editFormErrors"]),y(t,{formId:"notification-form",loading:a(v).notification,title:l.$t("profile.notification.title"),viewFields:B(a(se)),editFields:B(a(de)),editFormErrors:[n[a(K)]],onHandleSubmit:ye,onHandleBackToViewForm:s[3]||(s[3]=o=>K.value=null)},null,8,["loading","title","viewFields","editFields","editFormErrors"])])):W("",!0)]),_:1})]),_:1})}}});
1export{dt 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.