1import{r as e,j as a}from"./react-vendor.B75MsAI9.js";import{u as r,t,cv as s,cw as i,Q as o,o as l,cx as d,M as n,cy as c,w as u,bJ as p,cz as m,cA as h,T as f,cB as g,aQ as _,L as v,cC as x,bI as N,bG as b,cs as w,J as j,O as y,cD as T,cE as C,z as $,H as P,bH as S,bF as O}from"./AuthModalContainer.CwDh3qj_.js";import{d as U}from"./index.W3QIN98f.js";import{S as k}from"./SelectField.CyNICQh1.js";import{S as R}from"./Sizer.Dllv_Vpb.js";const D=({isVisible:D,viewport:I,parentClassName:E,userProfile:F,userId:L,resourceDetails:M,isFromFlp:V,mandatory:z,flpGrade:W,isUploadingUserProfile:A,autoCompleteData:G})=>{const H=r(),J=t(),K=s,Q=K.userType.map(e=>e.value),[B,q]=e.useState(""),[X,Y]=e.useState(""),[Z,ee]=e.useState(""),[ae,re]=e.useState(""),[te,se]=e.useState(""),[ie,oe]=e.useState(!1),[le,de]=e.useState("Select"),[ne,ce]=e.useState(""),[ue,pe]=e.useState(!1),[me,he]=e.useState(!1),[fe,ge]=e.useState(!1),[_e,ve]=e.useState(!1),[xe,Ne]=e.useState({}),be=e=>{const{event:a,category:r}=e;window.dataLayer.push({event:a,category:r||u.userRegistration,label:"profile_setup_modal",item_type:null,item_id:null,item_value:null,user_id:L})};e.useEffect(()=>{F&&F.role&&F.role.profileType&&(q(F.role.profileType),Y(Q.indexOf(F.role.profileType)),he(!0),oe(F.role.isOtherProfileDescrition),F.role.isOtherProfileDescrition&&(de("Other"),ce(F.role.profileDescription),pe(!0)),"ed-org"===F.role.profileType?re(F.role.profileDescription):"ed-tech"===F.role.profileType&&se(F.role.profileDescription),be({event:"nag_profile_initiated"}))},[F]);const we=e.useCallback(U(500,e=>{B&&B!==i.teacher&&S&&J(S({user_type:B,searchValue:e}))}),[B]),je=e.useCallback(()=>{const e=e=>e&&""!==e.trim();let a=!!B;switch(B){case i.teacher:case i.creator:case i.parent:case i.librarian:case i.storyteller:case i.student:break;case i.edOrg:a=a&&e(ae);break;case i.edTech:a=a&&e(te);break;default:a=a&&(ue?e(ne):"Select"!==le)}ge(a)},[B,ae,te,le,ne,ue]);e.useEffect(()=>{je()},[B,ae,te,le,ne,ue,je]);const ye=(e,a)=>{ve(!0),Ne(a=>({...a,[e]:""})),"schoolName"===e&&ee(a),"edOrgName"===e&&re(a),"edTechName"===e&&se(a),"otherReason"===e&&ce(a),we(a)},Te=e=>{de(e),pe("Other"===e)},Ce=()=>{J(p()),q(""),Y(""),ee(""),re(""),se(""),de("Select"),ce(""),pe(!1),he(!1)};if(!D)return null;const $e="pb-new-user-profile-modal",Pe=o($e,E),Se=a.jsx("div",{className:`${$e}__button-group`,children:K.userType.map((e,r)=>a.jsx(l,{parentClassName:B===e.value?`${$e}__button--user-type ${$e}__button-user-type--active`:`${$e}__button--user-type`,noPaddingLeft:!0,label:e.displayText,onClick:()=>{return a=e.value,t=r,q(a),Y(t),he(!0),ee(""),re(""),se(""),de("Select"),ce(""),pe(!1),ve(!1),void Ne({});var a,t}},e.value))}),Oe=a.jsx("div",{className:I.medium?`${$e}__image-wrapper`:`${$e}__mobile-image-wrapper`,children:a.jsx("img",{className:`${$e}__image`,src:I.medium?d.image:d.mobileImage,alt:"user-profile"})});return a.jsx("div",{className:$e,children:a.jsx(n,{onClose:z?null:Ce,fillViewport:!I.medium,noContentPadding:!0,noDimensionRestrictionsWithMaxWidth:!0,overflowVisible:!0,children:a.jsx("form",{className:`${$e}__form-content`,onKeyPress:e=>{e.charCode===m.return&&fe&&(e.preventDefault(),e.stopPropagation())},children:a.jsx(c,{parentClassName:`${$e}__halver`,backgroundUrl:d.backgroundImage,backgroundLoginImg:!1,alignLeft:!1,children:a.jsxs("div",{className:Pe,id:"new-profile-modal",children:[!I.medium&&Oe,a.jsx("div",{className:`${$e}__form-heading`,children:H("UserProfileModal.title")}),a.jsxs("div",{children:[Se,!me&&a.jsx("div",{className:`${$e}__select-user-description-wrapper`,children:a.jsx("div",{className:`${$e}__select-user-description-primary-heading`,children:H("UserProfile.user-select-text-1")})}),me&&(()=>{const e=[{description:H("UserProfile.teacher-description"),id:"schoolName",value:Z,detail:H("UserProfile.school-affiliated-to")},{description:H("UserProfile.parent-description"),id:"parent"},{description:H("UserProfile.student-description"),id:"student"},{description:H("UserProfile.creator-description"),id:"creator"},{description:H("UserProfile.ed-org-description"),id:"edOrgName",value:ae,detail:H("UserProfile.ed-org-affiliated-to")},{description:H("UserProfile.ed-tech-description"),id:"edTechName",value:te,detail
1:H("UserProfile.ed-tech-affiliated-to")},{description:H("UserProfile.librarian-description"),id:"librarian"},{description:H("UserProfile.storyteller-description"),id:"storyteller"},{description:H("UserProfile.other-description"),id:"otherReason",value:le}][X];return e?a.jsxs("div",{className:`${$e}__content-wrapper`,children:[a.jsx("div",{className:I.medium?`${$e}__content-description`:`${$e}__mobile-content-description`,children:e.description}),X===s.userType.findIndex(e=>"others"===e.value)?a.jsxs("div",{className:`${$e}__content-detail`,children:[a.jsx(R,{maxWidth:I.medium?"l":null,children:a.jsx(k,{parentClassName:`${$e}__select-language`,value:le,id:e.id,onChange:Te,options:h})}),ue&&a.jsx("div",{className:`${$e}__textfield-other-wrapper`,children:a.jsx(f,{id:"other-reason",type:"text",parentClassName:`${$e}__textfield`,label:H("UserProfile.other-label"),onChange:e=>ye("otherReason",e.target.value),value:ne,error:xe.otherReason,autoComplete:"off",regularLabel:!0,autoFocus:!0})})]}):a.jsx("div",{className:`${$e}__content-detail`,children:(X===s.userType.findIndex(e=>"ed-org"===e.value)||X===s.userType.findIndex(e=>"ed-tech"===e.value))&&a.jsxs("div",{children:[a.jsx("label",{className:`${$e}__textfield-label`,children:e.detail}),_e&&G&&G.length>0?a.jsx(g,{parentClassName:`${$e}__dropdown`,toggleEl:a.jsx(f,{parentClassName:`${$e}__textfield`,id:e.id,onChange:a=>ye(e.id,a.target.value),value:"ed-org"===e.value?ae:"ed-tech"===e.value?te:e.value,error:B===i.edOrg?xe.edOrgName:B===i.edTech?xe.edTechName:xe[e.id],customError:!!(B===i.edOrg?xe.edOrgName:B===i.edTech?xe.edTechName:xe[e.id]),autoComplete:"off",autoFocus:!0}),children:a.jsx(_,{children:G.map((r,t)=>a.jsx("li",{children:a.jsx(v,{theme:"regular",onClick:()=>{return a=e.id,ye(a,r),void ve(!1);var a},children:r})},t))})}):a.jsx(f,{parentClassName:`${$e}__textfield`,id:e.id,onChange:a=>ye(e.id,a.target.value),value:"ed-org"===e.value?ae:"ed-tech"===e.value?te:e.value,error:B===i.edOrg?xe.edOrgName:B===i.edTech?xe.edTechName:xe[e.id],customError:!!(B===i.edOrg?xe.edOrgName:B===i.edTech?xe.edTechName:xe[e.id]),autoComplete:"off",autoFocus:!0})]})})]}):null})()]}),a.jsx("div",{className:`${$e}__button-wrapper`,children:a.jsx(l,{parentClassName:`${$e}__done-button`,variant:"primary",label:H("global.done"),disabled:!fe,loading:A,onClick:async()=>{if(!fe)return;let e=null,a=null;const r=()=>{};if(B===i.edOrg?(a="edOrgName",e=await x("edOrgName",ae,r,H,e=>J(O({value:e})))):B===i.edTech?(a="edTechName",e=await x("edTechName",te,r,H,e=>J(O({value:e})))):"others"===B&&ue&&(a="otherReason",e=await x("otherReason",ne,r,H,e=>J(O({value:e})))),e&&!e.valid)return"edOrgName"===a?re(""):"edTechName"===a?se(""):"otherReason"===a&&ce(""),void Ne(r=>{const t={...r};return t[a]=e.message,t});e&&e.valid&&a&&Ne(e=>{const r={...e};return delete r[a],r});const t={teacher:Z,"ed-org":ae,"ed-tech":te,others:ue?ne:le}[B],s=await J(N({user_type:B,description:t,user_id:L}));if(s.ok){const{lang:e,ps:a,grade:r}=(()=>{const e=new URLSearchParams(window.location.search);return{lang:e.get("language")||"en",ps:e.get("ps"),grade:V?W:window.location.pathname.includes("/foundational-literacy-programme/resource")?M.gradeNumber:e.get("grade")||"1"}})();await J(b({slug:L,profileType:w.USER})),await J(j({payload:!1})),be({event:"completed_profile_pick"}),window.location.pathname===y.home()&&window.location.reload(),window.location.pathname.includes("/foundational-literacy-programme/grades")||window.location.pathname.includes("/foundational-literacy-programme/resource")||V?(J(T({userId:L,locale:e,grade:r,ps:a})),J(C())):"/"===window.location.pathname.replace(`/${$}`,"")?window.location.reload():J(P({type:"success",content:H("UserProfile.data-added-success")})),localStorage.setItem("user-profile-submission","user-profile"+Math.random()),Ce()}else J(P({type:"danger",content:s.data.errorMessage}))}})})]})})})})})};export{D as default}; 2//# sourceMappingURL=NewUserProfileModal.Da4tMTmq.js.map
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.