mario-education 2.0.275-staging → 2.0.276-staging
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/UserProfileManagement-9W_2qjqE.cjs +1 -0
- package/dist/UserProfileManagement-C3JLSnE-.cjs +1 -0
- package/dist/UserProfileManagement-CUmEqTKw.js +1144 -0
- package/dist/UserProfileManagement-ShZEcvC3.js +1148 -0
- package/dist/containers/UserManagement/configs/constants.d.ts +2 -0
- package/dist/containers/UserManagement/configs/profileSchema.d.ts +2 -0
- package/dist/containers/UserManagement/hooks/useUserDetail.d.ts +2 -0
- package/dist/containers/UserManagement/views/Profile.d.ts +2 -0
- package/dist/index.js +1 -1
- package/dist/index.modern.js +1 -1
- package/package.json +2 -2
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),Se=require("reactstrap"),p=require("mario-core"),te=require("./constants-DfnEgLPg.cjs"),g=require("react"),ne=require("react-redux"),je=require("formik"),Re=require("yup"),w=require("@mui/material"),we=require("@mui/x-date-pickers"),Ee=require("moment"),x=require("./OutlinedInput-CkBYF9FZ.cjs"),Ne=require("./constants-9UnXcqo8.cjs"),Te=require("./DoneCheckInIcon-7Q31KvHI.cjs"),xe=require("./userService-DsbgpY7L.cjs"),Ae=require("./styles.module-CHKJJ8Zm.cjs"),ke=require("./AdapterMoment-B-q0UCj0.cjs"),he=require("./Visibility-DoYLYxbn.cjs"),ge=require("./IconButton-DwLaeSCN.cjs"),Ce=require("react-router-dom"),Pe=require("date-fns");function De(r){const n=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(r){for(const u in r)if(u!=="default"){const _=Object.getOwnPropertyDescriptor(r,u);Object.defineProperty(n,u,_.get?_:{enumerable:!0,get:()=>r[u]})}}return n.default=r,Object.freeze(n)}const T=De(Re),Le="_name_1koi9_205",Ue="_role_1koi9_217",Me="_item_1koi9_230",Ie="_gender_1koi9_323",$e="_gender__item_1koi9_328",t={"profile-value":"_profile-value_1koi9_77","input-error":"_input-error_1koi9_94","user-profile-container-admin":"_user-profile-container-admin_1koi9_122","user-profile-container-admin__left":"_user-profile-container-admin__left_1koi9_135","user-profile-container-admin__left--information":"_user-profile-container-admin__left--information_1koi9_146","image-user-container":"_image-user-container_1koi9_154","image-user-container__image":"_image-user-container__image_1koi9_169","image-user-container__edit-btn":"_image-user-container__edit-btn_1koi9_176","image-user-container__delete-btn":"_image-user-container__delete-btn_1koi9_190","name-role-container":"_name-role-container_1koi9_205",name:Le,role:Ue,"user-profile-container-admin__left--btn-control":"_user-profile-container-admin__left--btn-control_1koi9_224",item:Me,"item-active":"_item-active_1koi9_246","user-profile-container-admin__right":"_user-profile-container-admin__right_1koi9_274","edit-profile-container":"_edit-profile-container_1koi9_285","edit-profile-container__title":"_edit-profile-container__title_1koi9_290","edit-profile-container__form":"_edit-profile-container__form_1koi9_297","edit-profile-container__form--row":"_edit-profile-container__form--row_1koi9_302","edit-profile-container__form--field":"_edit-profile-container__form--field_1koi9_307",gender:Ie,gender__item:$e,"edit-profile-container__form--width-50":"_edit-profile-container__form--width-50_1koi9_334","edit-profile-container__form--width-30":"_edit-profile-container__form--width-30_1koi9_337","edit-profile-container__form--width-70":"_edit-profile-container__form--width-70_1koi9_340","edit-profile-container__form--btn-group":"_edit-profile-container__form--btn-group_1koi9_343","btn-save":"_btn-save_1koi9_349","btn-cancel":"_btn-cancel_1koi9_371"};var Z=(r=>(r.Info="info",r.ForgotPassword="forgotPassword",r.DownloadUserData="downloadUserData",r.ChangePassword="changePassword",r))(Z||{});const ce=[{value:"info",label:"Personal Information",icon:"/images/user/User.svg",isControl:!0},{value:"changePassword",label:"Change Password",icon:"/images/user/Lock.svg",isControl:!1},{value:"forgotPassword",label:"Send Forgot Password Link",icon:"/images/user/Lock.svg",isControl:!1},{value:"downloadUserData",label:"Download User Data",icon:"/images/user/Log-out.svg",isControl:!1}],_e=["Admin","Assistant","Teacher","Counselor","General ED teacher","SecondaryTeacher","Parent","Student"],Fe=_e,He=_e,Oe=_e.filter(r=>r!=="SecondaryTeacher"),qe=r=>r==="both"?["MS","ES"]:[r.toUpperCase()],Be=r=>r==="both"?"ES, MS":r.toUpperCase(),ue=(r,n,u)=>{if(u){if(V.includes(u))return"hs";if(J.includes(u))return"ms";if(Y.includes(u))return"es"}const _=(r||"").toUpperCase();if(_==="ES, MS")return"both";if(_==="ES")return"es";if(_==="HS")return"hs";if(_==="MS")return"ms";const m=(n||[]).includes("MS"),l=(n||[]).includes("ES");return(n||[]).includes("HS")&&!m&&!l?"hs":l&&!m?"es":"ms"},P={ADMIN:"Admin",TEACHER:"Teacher",ASSISTANT:"Assistant",EDUTEACHER:"General ED teacher",STUDENT:"Student",PARENT:"Parent"},Ve=[{value:!0,label:"Active"},{value:!1,label:"Inactive"}],de=["K","G","1","2","3","4","5","6","7","8","9","10","11","12",...te.isMalvernCollege?["12/13"]:[],"13",...te.isSaisSchool?["PCS"]:[]],Y=["K","G","1","2","3","4","5",...te.isMalvernCollege?["6"]:[]],J=[...te.isMalvernCollege?[]:["6"],"7","8"],V=["9","10","11","12",...te.isMalvernCollege?["12/13"]:[],"13",...te.isSaisSchool?["PCS"]:[]],ye=["Student"],Ge=T.object({firstName:T.string().required("First name is required"),lastName:T.string().required("Last name is required"),email:T.string().email("Email is invalid").required("Email is required"),appTypes:T.array().of(T.string()).min(1,"School tier is required"),msRoles:T.array().of(T.string()).test("ms-role-required","MS role is required",(r,n)=>{const u=ue(n.parent.preferredAppType,n.parent.appTypes,n.parent.gradeLevel);return u!=="ms"&&u!=="both"?!0:!!r&&r.length>0}),hsRoles:T.array().of(T.string()).test("hs-role-required","HS role is required",(r,n)=>ue(n.parent.preferredAppType,n.parent.appTypes,n.parent.gradeLevel)!=="hs"?!0:!!r&&r.length>0),esRoles:T.array().of(T.string()).test("es-role-required","ES role is required",(r,n)=>{const u=ue(n.parent.preferredAppType,n.parent.appTypes,n.parent.gradeLevel);return u!=="es"&&u!=="both"?!0:!!r&&r.length>0}),gradeLevel:T.string().nullable().test("grade-level-required","Grade level is required",(r,n)=>{const u=n.parent.msRoles||[],_=n.parent.esRoles||[],m=n.parent.hsRoles||[];return u.includes("Student")||_.includes("Student")||m.includes("Student")?!!r:!0})}),ze={currentPage:1,pageSize:100},Ye=(r,n)=>{const[u,_]=g.useState([]),[m,l]=g.useState(!1),[C,S]=g.useState(ze),[U,j]=g.useState(),f=ne.useDispatch(),F=g.useCallback(async()=>{l(!0);try{const o=(await xe.getRosterUsersApi(C)).data?.items||[];_(H(o))}catch{f(p.setAlert({type:"error",message:"Cannot get roster users"}))}l(!1)},[JSON.stringify(C)]),Q=g.useCallback(async()=>{if(!n)return;const i=u.find(o=>o.value===n);if(i){j(i);return}l(!0);try{const I=(await xe.getRosterUserBySourcedIdApi(n)).data;j({label:O(I),value:I.sourcedId})}catch(o){console.log("err:",o)}l(!1)},[n]),H=i=>i.map(o=>({label:O(o),value:o.sourcedId})),O=i=>{const o=[],{givenName:I,middleName:b,familyName:N,email:L,role:R}=i,h=[];return I&&h.push(I),b&&h.push(b),N&&h.push(N),h.length&&o.push(h.join(" ")),L&&o.push(L),`${o.join(" - ")}${R?` (${R})`:""}`},K=i=>{S(o=>({...o,searchString:i}))},M=g.useCallback(i=>{S({...C,...i})},[JSON.stringify(C)]);return g.useEffect(()=>{C.roles?.length&&F()},[JSON.stringify(C)]),g.useEffect(()=>{M({roles:r})},[JSON.stringify(r)]),g.useEffect(()=>{Q()},[n]),{users:u,isLoading:m,user:U,handleInputChange:K}},Je=({value:r,roles:n,onChange:u})=>{const{users:_,isLoading:m,user:l,handleInputChange:C}=Ye(n,r);return e.jsx(w.Select,{label:"Select user",value:l?.value||"",onChange:S=>{u(S.target.value)},onOpen:()=>C(""),disabled:m,className:`${Ae.styles["profile-value"]}`,variant:"outlined",children:m?e.jsx(w.MenuItem,{disabled:!0,children:e.jsx(w.CircularProgress,{size:20})}):_.length>0?_.map(S=>e.jsx(w.MenuItem,{value:S.value,children:`${S.label}`},S.value)):e.jsx(w.MenuItem,{disabled:!0,children:"No users found"})})},Ke=({userDetail:r,confirmData:n,goBack:u,teacherOptions:_,getDataTeachers:m,id:l,checkHasTeacher:C,setCheckHasTeacher:S,userHasData:U,currentRoles:j})=>{const{t:f}=p.useTranslation(),F=g.useRef(null),H=ne.useSelector(M=>M.common.user)?.hasEsSchool!==!1,{getLabel:O,system:K}=p.useGradeLabel();return e.jsxs("div",{className:t["edit-profile-container"],children:[e.jsx("div",{className:t["edit-profile-container__title"],children:`${l?"Edit User Profile":"Create User"}`}),e.jsx(je.Formik,{initialValues:r,enableReinitialize:!0,onSubmit:M=>{n(M)},validationSchema:Ge,children:M=>{const{values:i,setFieldValue:o,handleSubmit:I,errors:b,touched:N}=M,L=Object.keys(b);L.length&&document.querySelector(`input[name=${L[0]}]`)?.scrollIntoView({behavior:"smooth",block:"center"});const R=i?.appTypes||[],h=R.includes("MS"),pe=R.includes("ES"),ee=R.includes("HS"),se=i?.msRoles||[],X=i?.esRoles||[],E=se.includes(P.STUDENT)||X.includes(P.STUDENT),$=H?E&&(i?.preferredAppType==="HS"||i?.preferredAppType==="MS")?i.preferredAppType.toLowerCase():ue(i?.preferredAppType,R,i?.gradeLevel):E?i?.preferredAppType==="HS"?"hs":i?.preferredAppType==="MS"?"ms":i?.gradeLevel&&V.includes(i.gradeLevel)?"hs":"ms":"ms",re=$==="ms"||$==="hs"||$==="both",ie=$==="es"||$==="both",oe=E?$==="es"?de.filter(a=>Y.includes(a)):$==="hs"?de.filter(a=>V.includes(a)):de.filter(a=>J.includes(a)):de,me=a=>{const c=a.target.value;o("gradeLevel",c),E&&(V.includes(c)?(o("preferredAppType","HS"),l||o("appTypes",["HS"])):J.includes(c)?(o("preferredAppType","MS"),l||o("appTypes",["MS"])):Y.includes(c)&&(o("preferredAppType","ES"),l||o("appTypes",["ES"])))},le=(a,c)=>{if(!c)return;const q=qe(c),G=Be(c),z=v=>{const s=r?.gradeLevel;return v==="hs"?s&&V.includes(s)?s:V[0]:v==="ms"?s&&J.includes(s)?s:J[0]??"6":v==="es"?s&&Y.includes(s)?s:Y[0]:i?.gradeLevel};l?(o("preferredAppType",G),E&&(c==="hs"&&i?.gradeLevel&&V.includes(i.gradeLevel)||c==="ms"&&i?.gradeLevel&&J.includes(i.gradeLevel)||c==="es"&&i?.gradeLevel&&Y.includes(i.gradeLevel)||o("gradeLevel",z(c)))):(o("appTypes",q),o("preferredAppType",G),E&&(c==="es"&&o("msRoles",[]),c==="ms"&&o("esRoles",[]),m(c==="both"||c==="hs"?"MS":c.toUpperCase()),c==="hs"&&i?.gradeLevel&&V.includes(i.gradeLevel)||c==="ms"&&i?.gradeLevel&&J.includes(i.gradeLevel)||c==="es"&&i?.gradeLevel&&Y.includes(i.gradeLevel)||o("gradeLevel",z(c))))},fe=a=>c=>{const q=c.target.value,G=a==="MS"?"msRoles":a==="ES"?"esRoles":"hsRoles",z=a==="MS"?["esRoles","hsRoles"]:a==="ES"?["msRoles","hsRoles"]:["msRoles","esRoles"],v=F.current,s=U?.[a]??{};if(l&&(s.isHasTeacherData&&v==="Teacher"||s.isHasAssistantData&&v==="Assistant"||s.isHasCounselorData&&v==="Counselor"||s.isHasSecondaryTeacherData&&v==="SecondaryTeacher"||v==="Student"&&(s.isHasAssistantData||s.isHasCounselorData||s.isHasSecondaryTeacherData||s.isHasTeacherData))){alert("Please switch data before removing the role");return}const d=i?.[G]||[],D=q.some(A=>ye.includes(A))?v&&!d.includes(v)?[v]:[q.find(A=>ye.includes(A))].filter(Boolean):q,W=d.includes(P.STUDENT),B=D.includes(P.STUDENT);if(o(G,D),F.current=null,B){const A=a;o("preferredAppType",A),z.forEach(ve=>o(ve,[])),l||(o("appTypes",[A]),m(a==="ES"?"ES":"MS"))}else W&&!B&&z.forEach(A=>o(A,[]))},ae=a=>{const c=a==="MS"?"msRoles":a==="ES"?"esRoles":"hsRoles",q=a==="MS"?se:a==="ES"?X:i?.hsRoles||[],G=a==="MS"?Fe:a==="ES"?Oe:He,z=j?.[a]||[];return e.jsxs("div",{className:`${t["edit-profile-container__form--field"]} ${re&&ie?t["edit-profile-container__form--width-50"]:""}`,children:[e.jsxs("p",{children:[H&&e.jsx("span",{style:{display:"inline-block",fontSize:11,fontWeight:700,color:"#3b4ba8",backgroundColor:"#e9ecfb",borderRadius:4,padding:"1px 6px",marginRight:6,verticalAlign:"middle"},children:a}),H?a==="HS"?"High school roles":a==="MS"?"Middle school roles":"Elementary school roles":a==="HS"?"High school roles":a==="MS"?"Middle school roles":"Roles"," ",e.jsx("sup",{children:"*"})]}),e.jsx(w.Select,{variant:"outlined",multiple:!0,name:c,value:q,renderValue:v=>v.map(s=>s==="SecondaryTeacher"?"Support Teacher":s).join(", "),onChange:fe(a),className:`${t["profile-value"]}`,children:G.map(v=>{const s=j?.MS?.includes(P.STUDENT)||j?.ES?.includes(P.STUDENT)||j?.HS?.includes(P.STUDENT);return e.jsxs(w.MenuItem,{value:v,disabled:l?z.some(d=>["Student","Parent","General ED teacher"].includes(d))||["Parent"].includes(v)||!s&&v===P.STUDENT:["Parent"].includes(v)||E&&v!==P.STUDENT,onClick:()=>{F.current=v},children:[e.jsx(w.Checkbox,{checked:q.includes(v)}),e.jsx(w.ListItemText,{primary:v==="SecondaryTeacher"?"Support Teacher":v})]},v)})}),b[c]&&N[c]?e.jsx("div",{className:`${t["input-error"]}`,children:b[c]}):null]})};return e.jsxs("div",{className:t["edit-profile-container__form"],children:[e.jsxs("div",{className:t["edit-profile-container__form--row"],children:[e.jsxs("div",{className:`${t["edit-profile-container__form--field"]} ${t["edit-profile-container__form--width-50"]}`,children:[e.jsxs("p",{children:[f("first_name")," ",e.jsx("sup",{children:"*"})]}),e.jsx(w.TextField,{name:"firstName",variant:"outlined",value:i?.firstName||"",onChange:a=>o("firstName",a.target.value)}),b.firstName&&N.firstName?e.jsx("div",{className:`${t["input-error"]}`,children:b.firstName}):null]}),e.jsxs("div",{className:`${t["edit-profile-container__form--field"]} ${t["edit-profile-container__form--width-50"]}`,children:[e.jsxs("p",{children:[f("last_name")," ",e.jsx("sup",{children:"*"})]}),e.jsx(w.TextField,{name:"lastName",variant:"outlined",className:`${t["profile-value"]}`,value:i?.lastName||"",onChange:a=>o("lastName",a.target.value)}),b.lastName&&N.lastName?e.jsx("div",{className:`${t["input-error"]}`,children:b.lastName}):null]})]}),e.jsxs("div",{className:t["edit-profile-container__form--row"],children:[e.jsxs("div",{className:`${t["edit-profile-container__form--field"]} ${t["edit-profile-container__form--width-30"]}`,children:[e.jsxs("p",{children:[" ",f("date_of_birth")]}),e.jsx(we.LocalizationProvider,{dateAdapter:ke.AdapterMoment,children:e.jsx(we.DatePicker,{format:"Do MMM YYYY",value:i?.dateOfBirth&&!Ne.DATE_MIN_VALUE.includes(i?.dateOfBirth)?Ee(i?.dateOfBirth):null,onChange:a=>{if(a){const c=a.format("YYYY-MM-DD");o("dateOfBirth",c)}else o("dateOfBirth",null)},slotProps:{textField:{variant:"outlined",id:"time-picker",className:`${t["profile-value"]}`},openPickerButton:{"aria-label":"change date"}}})})]}),e.jsxs("div",{className:`${t["edit-profile-container__form--field"]} ${t["edit-profile-container__form--width-70"]}`,children:[e.jsxs("p",{children:[f("email")," ",e.jsx("sup",{children:"*"})]}),e.jsx(w.TextField,{name:"email",variant:"outlined",className:`${t["profile-value"]}`,value:i?.email||"",onChange:a=>o("email",a.target.value)}),b.email&&N.email?e.jsx("div",{className:`${t["input-error"]}`,children:b.email}):null]})]}),e.jsxs("div",{style:{border:"1px solid #e0e0e0",borderRadius:"12px",marginBottom:"24px",overflow:"hidden"},children:[H&&e.jsx("div",{style:{backgroundColor:"#f8f9fa",padding:"16px 24px",borderBottom:"1px solid #e0e0e0"},children:e.jsxs("div",{className:`${t["edit-profile-container__form--field"]}`,style:{marginBottom:0,width:"100%"},children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[e.jsxs("div",{children:[e.jsxs("p",{style:{marginBottom:4,fontWeight:600,fontSize:16},children:["School tier ",e.jsx("sup",{children:"*"})]}),e.jsx("p",{style:{fontSize:13,color:"#6c757d",marginTop:0,marginBottom:0},children:"Pick a tier. Roles are assigned per tier."})]}),e.jsxs(w.ToggleButtonGroup,{exclusive:!0,value:$,onChange:le,size:"small",sx:{border:"1px solid #e0e0e0",borderRadius:"30px",padding:"4px",backgroundColor:"#fff","& .MuiToggleButton-root":{border:"none",borderRadius:"30px !important",textTransform:"none",padding:"6px 20px",margin:"0",color:"#6c757d",fontWeight:500,fontSize:14,"&.Mui-selected":{backgroundColor:"#2b65d9",color:"#fff","&:hover":{backgroundColor:"#1d4ed8"}}}},children:[e.jsx(w.ToggleButton,{value:"ms",disabled:!!l&&!h&&!ee&&E,children:"Middle school"}),e.jsx(w.ToggleButton,{value:"hs",disabled:!!l&&!h&&!ee&&E,children:"High school"}),e.jsx(w.ToggleButton,{value:"es",disabled:!!l&&!pe&&E,children:"Elementary"}),!E&&e.jsx(w.ToggleButton,{value:"both",disabled:!1,children:"Both"})]})]}),b.appTypes&&N.appTypes?e.jsx("div",{className:`${t["input-error"]}`,children:b.appTypes}):null]})}),e.jsx("div",{style:{backgroundColor:"#fff",padding:"24px"},children:e.jsxs("div",{className:t["edit-profile-container__form--row"],style:{margin:0},children:[ie&&ae("ES"),$==="hs"?ae("HS"):re&&ae("MS")]})})]}),e.jsx("div",{className:t["edit-profile-container__form--row"],children:e.jsxs("div",{className:`${t["edit-profile-container__form--field"]} ${t["edit-profile-container__form--width-50"]}`,children:[e.jsx("p",{children:f("status")}),e.jsx("div",{className:`${t.gender}`,children:Ve.map(a=>e.jsxs("div",{className:`${t.gender__item}`,children:[e.jsx(w.Radio,{color:"primary",value:a.value,checked:i?.isActive===a.value,onChange:()=>o("isActive",a.value),disabled:!!l&&!!i?.isImportedFromIntegration}),a.label]},a.label))})]})}),E&&!l&&!!_&&e.jsx("div",{className:t["edit-profile-container__form--row"],children:e.jsxs("div",{className:`${t["edit-profile-container__form--field"]}`,children:[e.jsxs("p",{children:["Assign Teacher ",e.jsx("sup",{children:"*"})]}),e.jsx(w.Select,{multiple:!0,variant:"outlined",name:"teacherUserId",value:i?.teacherUserId||[],renderValue:a=>_.filter(c=>a.includes(c.value)).map(c=>c.label).join(", "),onChange:a=>{const c=a.target.value;o("teacherUserId",c),S(!!c.length)},className:`${t["profile-value"]}`,children:_?.map(a=>e.jsx(w.MenuItem,{value:a.value,children:a.label},a.value))}),!C&&e.jsx("div",{className:`${t["input-error"]}`,children:"Teacher is required"})]})}),E&&e.jsx("div",{className:t["edit-profile-container__form--row"],children:e.jsxs("div",{className:`${t["edit-profile-container__form--field"]} ${t["edit-profile-container__form--width-50"]}`,children:[e.jsxs("p",{children:[" ",K==="UK"?"Year":f("grade_level")," ",e.jsx("sup",{children:"*"})]}),e.jsxs(w.Select,{variant:"outlined",value:i?.gradeLevel??"",renderValue:a=>O(a),onChange:me,className:`${t["profile-value"]}`,children:[i?.gradeLevel&&!oe.includes(i.gradeLevel)&&e.jsx(w.MenuItem,{value:i.gradeLevel,sx:{display:"none"},children:O(i.gradeLevel)},"__current__"),oe.map(a=>e.jsx(w.MenuItem,{value:a,children:O(a)},a))]}),b.gradeLevel&&N.gradeLevel?e.jsx("div",{className:`${t["input-error"]}`,children:b.gradeLevel}):null]})}),!E&&(!!se.length||!!X.length)&&!!l&&e.jsx("div",{className:t["edit-profile-container__form--row"],children:e.jsxs("div",{className:`${t["edit-profile-container__form--field"]} ${t["edit-profile-container__form--width-50"]}`,children:[e.jsx("p",{children:f("Map from Roster")}),e.jsx(Je,{roles:[...se,...X],value:i.sourcedId,onChange:a=>o("sourcedId",a)})]})}),e.jsxs("div",{className:t["edit-profile-container__form--btn-group"],children:[e.jsx("button",{type:"button",className:t["btn-cancel"],onClick:()=>u(),children:f("cancel")}),e.jsxs("button",{type:"button",className:t["btn-save"],onClick:()=>I(),children:[e.jsx(Te.DoneCheckInIcon,{color:"#fff"}),f("save_changes")]})]})]})}})]})},k={"input-error":"_input-error_gmvmh_1","change-password-container":"_change-password-container_gmvmh_6","change-password-container__title":"_change-password-container__title_gmvmh_11","change-password-container__form":"_change-password-container__form_gmvmh_19","change-password-container__form--field":"_change-password-container__form--field_gmvmh_24","change-password-container__form--description":"_change-password-container__form--description_gmvmh_38","change-password-container__form--btn-group":"_change-password-container__form--btn-group_gmvmh_54","btn-save":"_btn-save_gmvmh_60","btn-cancel":"_btn-cancel_gmvmh_82"},We=T.object({oldPassword:T.string().required("Old password is required"),newPassword:T.string().required("New password is required"),confirmedNewPassword:T.string().oneOf([T.ref("newPassword"),void 0],"New password must match").required("Confirm your new password")}),Xe=({confirmChangePassword:r,goBack:n})=>{const{t:u}=p.useTranslation();return e.jsxs("div",{className:k["change-password-container"],children:[e.jsx("div",{className:k["change-password-container__title"],children:u("change_password")}),e.jsx(je.Formik,{initialValues:{oldPassword:"",newPassword:"",confirmedNewPassword:"",showOldPassword:!1,showNewPassword:!1,showConfirmNewPassword:!1},enableReinitialize:!0,onSubmit:_=>{r(_)},validateOnChange:!1,validateOnBlur:!1,validationSchema:We,children:_=>{const{values:m,setFieldValue:l,handleSubmit:C,errors:S,touched:U}=_,j=Object.keys(S);return j.length&&document.querySelector(`input[name=${j[0]}]`)?.scrollIntoView({behavior:"smooth",block:"center"}),e.jsxs("div",{className:k["change-password-container__form"],children:[e.jsxs("div",{className:`${k["change-password-container__form--field"]}`,children:[e.jsx("p",{children:u("old_password")}),e.jsx(x.FormControl,{variant:"outlined",className:`${k["input-field"]}`,children:e.jsx(x.OutlinedInput,{type:m.showOldPassword?"text":"password",value:m?.oldPassword,onChange:f=>l("oldPassword",f.target.value.trim()),endAdornment:e.jsx(x.InputAdornment,{position:"end",children:e.jsx(ge.IconButton,{"aria-label":"toggle password visibility",onClick:()=>l("showOldPassword",!m.showOldPassword),onMouseDown:f=>f.preventDefault(),children:m.showOldPassword?e.jsx(he.Visibility,{color:"primary"}):e.jsx(x.VisibilityOff,{color:"primary"})})})})}),S.oldPassword&&U.oldPassword&&e.jsx("div",{className:`${k["input-error"]}`,children:S.oldPassword})]}),e.jsxs("div",{className:`${k["change-password-container__form--field"]}`,children:[e.jsx("p",{children:u("new_password")}),e.jsx(x.FormControl,{variant:"outlined",className:`${k["input-field"]}`,children:e.jsx(x.OutlinedInput,{type:m.showNewPassword?"text":"password",value:m?.newPassword,onChange:f=>l("newPassword",f.target.value.trim()),endAdornment:e.jsx(x.InputAdornment,{position:"end",children:e.jsx(ge.IconButton,{"aria-label":"toggle password visibility",onClick:()=>l("showNewPassword",!m.showNewPassword),onMouseDown:f=>f.preventDefault(),children:m.showNewPassword?e.jsx(he.Visibility,{color:"primary"}):e.jsx(x.VisibilityOff,{color:"primary"})})})})}),S.newPassword&&U.newPassword&&e.jsx("div",{className:`${k["input-error"]}`,children:S.newPassword}),e.jsxs("div",{className:`${k["change-password-container__form--description"]}`,children:["Password must contain at least: 1 uppercase letter, 1 lowercase letter,",e.jsx("br",{})," 1 number, and 1 special character"]})]}),e.jsxs("div",{className:`${k["change-password-container__form--field"]}`,children:[e.jsx("p",{children:u("confirm_new_password")}),e.jsx(x.FormControl,{variant:"outlined",className:`${k["input-field"]}`,children:e.jsx(x.OutlinedInput,{type:m.showConfirmNewPassword?"text":"password",value:m?.confirmedNewPassword,onChange:f=>l("confirmedNewPassword",f.target.value.trim()),endAdornment:e.jsx(x.InputAdornment,{position:"end",children:e.jsx(ge.IconButton,{"aria-label":"toggle password visibility",onClick:()=>l("showConfirmNewPassword",!m.showConfirmNewPassword),onMouseDown:f=>f.preventDefault(),children:m.showConfirmNewPassword?e.jsx(he.Visibility,{color:"primary"}):e.jsx(x.VisibilityOff,{color:"primary"})})})})}),S.confirmedNewPassword&&U.confirmedNewPassword&&e.jsx("div",{className:`${k["input-error"]}`,children:S.confirmedNewPassword})]}),e.jsxs("div",{className:k["change-password-container__form--btn-group"],children:[e.jsx("button",{type:"button",className:k["btn-cancel"],onClick:()=>{n()},children:u("cancel")}),e.jsxs("button",{type:"button",className:k["btn-save"],onClick:()=>C(),children:[e.jsx(Te.DoneCheckInIcon,{color:"#fff"}),u("save_new_password")]})]})]})}})]})},Ze={id:"",firstName:"",lastName:"",email:"",dateOfBirth:Ne.DATE_MIN_VALUE,msRoles:[],esRoles:[],hsRoles:[],isActive:!0,profileImageFileName:"",teacherUserId:[],gradeLevel:"",currentGradeLevel:"",isImportedFromIntegration:!1,appTypes:["MS"],preferredAppType:"MS"},be="/admin/users/user-list",Qe="User detail",es=12,ss=20,rs=r=>{const n=ne.useDispatch(),u=Ce.useNavigate(),_=ne.useSelector(s=>s.common.user),m=ne.useSelector(s=>s.common?.defaultFontSize),[l,C]=g.useState(Ze),[S,U]=g.useState(null),[j,f]=g.useState(!1),[F,Q]=g.useState({MS:[],ES:[],HS:[]}),[H,O]=g.useState([]),[K,M]=g.useState(!1),[i,o]=g.useState(Z.Info),[I,b]=g.useState(!0),[N,L]=g.useState({}),R=async()=>{localStorage.setItem(window.location.href,"true"),f(!0)},h=()=>{M(!K)},pe=g.useMemo(()=>m==ss?"font-large":m==es?"font-small":"",[m]);g.useEffect(()=>{document.title=Qe,f(!1),localStorage.getItem(window.location.href)&&localStorage.removeItem(window.location.href)},[]),g.useEffect(()=>{r&&se(),!r&&le()},[r]);const ee=(s=[])=>s.includes("EduTeacher")?[...s.filter(d=>d!=="EduTeacher"),P.EDUTEACHER]:s,se=g.useCallback(async()=>{n(p.setLoading(!0));try{const s=await x.getByIdUser(r),d=(s.data.appTypeRaw||s.data.appType||"MS").toUpperCase(),y=d.includes("MS"),D=d.includes("ES"),W=d.includes("HS"),B=[];D&&B.push("ES"),y&&B.push("MS"),W&&B.push("HS"),B.length===0&&B.push("MS");let A=s.data.preferredAppType||d;((s.data.roles||[]).includes("Student")||(s.data.msRoles||[]).includes("Student")||(s.data.esRoles||[]).includes("Student"))&&s.data.gradeLevel&&(V.includes(s.data.gradeLevel)?A="HS":J.includes(s.data.gradeLevel)?A="MS":Y.includes(s.data.gradeLevel)&&(A="ES")),C({...s.data,dateOfBirth:Pe.format(new Date(s.data.dateOfBirth),p.DATE_FORMAT),msRoles:ee(s.data.msRoles),esRoles:ee(s.data.esRoles),hsRoles:ee(s.data.hsRoles),currentGradeLevel:s.data.gradeLevel,appTypes:B,preferredAppType:A}),Q({MS:s.data.msRoles??[],ES:s.data.esRoles??[],HS:s.data.hsRoles??[]}),document.title=s.data?.fullName,(y||W)&&X("MS"),D&&X("ES")}catch(s){n(p.setAlert({type:"danger",message:s.response?.data?.title||s.message}))}n(p.setLoading(!1))},[r]),X=g.useCallback(async s=>{n(p.setLoading(!0));try{const d=await x.userRoleHasDataApi(r,s);L(y=>({...y,[s]:d.data}))}catch(d){n(p.setAlert({type:"danger",message:d.response?.data?.title||d.message}))}n(p.setLoading(!1))},[r]),E=g.useCallback(s=>{u(s&&typeof s=="string"?be+`?query=${s}`:be)},[]),$=s=>["Student","Parent","EduTeacher"].includes(s),re=(s=[])=>s.includes(P.EDUTEACHER)?[...s.filter(d=>d!==P.EDUTEACHER),"EduTeacher"]:s,ie=g.useCallback(async s=>{const d=s.msRoles?.includes(P.STUDENT)||s.esRoles?.includes(P.STUDENT);if(d&&!r&&!s.teacherUserId){b(!1);return}d&&s.gradeLevel&&(V.includes(s.gradeLevel)?(s.preferredAppType="HS",s.hsRoles=s.msRoles?.length?s.msRoles:[P.STUDENT]):J.includes(s.gradeLevel)?s.preferredAppType="MS":Y.includes(s.gradeLevel)&&(s.preferredAppType="ES")),n(p.setLoading(!0));try{_?.hasEsSchool===!1&&(s.preferredAppType!=="HS"?(s.appTypes=["MS"],s.preferredAppType="MS"):s.appTypes=["HS"],s.esRoles=[]);const y=r?x.update:x.create;!r&&delete s.id,s.teacherUserId=d?s.teacherUserId:[],s.msRoles=re(s.msRoles),s.esRoles=re(s.esRoles),s.hsRoles=re(s.hsRoles),d&&s.preferredAppType==="HS"&&(s.hsRoles=s.msRoles?.length?s.msRoles:[P.STUDENT]),r||(s.profileImageFileName=S||"");const D=await y(s);D&&x.getByIdUser(D.data.id).then(W=>{E(W.data.fullName)}),r||alert("Password of "+D.data.email+` is "${D.data.password}"`),n(p.setAlert({type:"success",message:`${r?"Update":"Create"} user successfully`}))}catch(y){n(p.setAlert({type:"danger",message:y.response?.data?.title||y.message}))}n(p.setLoading(!1))},[r,S]),oe=async s=>{n(p.setLoading(!0));try{await x.changePassword(s),n(p.setAlert({type:"success",message:"Change password successfully"}))}catch(d){n(p.setAlert({type:"danger",message:d.response?.data?.title||d.message}))}n(p.setLoading(!1))},me=g.useCallback(async s=>{n(p.setLoading(!0));try{await x.forgotChangePassword(s),n(p.setAlert({type:"success",message:"Send forgot password link successfully"}))}catch(d){n(p.setAlert({type:"danger",message:d.response?.data?.title||d.message||"Error occured"}))}n(p.setLoading(!1))},[]),le=async s=>{try{const d=await x.getTeachers({sortBy:"Email"},s);d.data&&O((d.data.map?.(y=>({label:y.email,value:y.id}))||[]).sort((y,D)=>y.label.localeCompare(D.label)))}catch(d){n(p.setAlert({type:"danger",message:d.response?.data?.title||d.message}))}},fe=20097152,[ae,a]=g.useState(""),c=s=>{s.preventDefault();let d=new FileReader,y=s.target.files[0];if(y.size>fe){n(p.setAlert({type:"danger",message:"File can't be larger than 2MB"}));return}d.onloadend=async()=>{if(a(d.result),y){const D=new FormData,{name:W}=y;D.append("file",y,W);const A=(await x.systemProfileUpload(D))?.data?.key;r?await x.updateAvatarByAdminApi(l.id||"",A):U(A)}},y&&d.readAsDataURL(y)},q=async()=>{await x.updateAvatarByAdminApi(l.id||"",""),a("")},G=ae||p.getFileUrl(l?.profileImageFileName),z=l?.profileImageFileName||"";return{userDetail:l,getDataTeachers:le,backToList:E,confirmData:ie,file:S,setFile:U,edited:j,currentRoles:F,setEdited:f,setEditedTrue:R,confirmChangePassword:oe,forgotPasswordRequest:me,handleDisableRoles:$,classFontSize:pe,teacherOptions:H,handleToggleModel:h,openModel:K,user:_,activeTab:i,setActiveTab:o,imageSrc:G,imageUse:z,handleImageChange:c,handleDeleteAvatar:q,getFile:()=>{var s=window.location.origin+"/api/ExportDataUser/"+r;window.open(s)},checkHasTeacher:I,setCheckHasTeacher:b,userHasData:N}},ts="/images/image-default.png",as=()=>{const{id:r}=Ce.useParams(),{userDetail:n,getDataTeachers:u,backToList:_,confirmData:m,confirmChangePassword:l,forgotPasswordRequest:C,teacherOptions:S,user:U,activeTab:j,setActiveTab:f,imageSrc:F,handleImageChange:Q,handleDeleteAvatar:H,getFile:O,currentRoles:K,handleDisableRoles:M,checkHasTeacher:i,setCheckHasTeacher:o,userHasData:I}=rs(r),b=[{value:Z.Info,component:e.jsx(Ke,{id:r,goBack:_,userDetail:n,confirmData:m,teacherOptions:S,getDataTeachers:u,currentRoles:K,handleDisableRoles:M,checkHasTeacher:i,setCheckHasTeacher:o,userHasData:I})},{value:Z.ChangePassword,component:e.jsx(Xe,{confirmChangePassword:l,goBack:_})}],N=ce.find(h=>h.value===Z.ForgotPassword),L=ce.find(h=>h.value===Z.DownloadUserData),R=ce.find(h=>h.value===Z.ChangePassword);return e.jsxs("div",{className:t["user-profile-container-admin"],children:[e.jsxs("div",{className:t["user-profile-container-admin__left"],children:[e.jsxs("div",{className:t["user-profile-container-admin__left--information"],children:[e.jsxs("div",{className:t["image-user-container"],children:[e.jsx(Se.Input,{className:"d-none",type:"file",id:"uploadFile",onChange:Q,accept:"image/*"}),e.jsx("img",{src:F||p.getStaticFileUrl(ts),alt:"avatar",className:`${t["image-user-container__image"]}`}),e.jsx(Se.Label,{htmlFor:"uploadFile",role:"button",tabIndex:0,children:e.jsx("div",{className:t["image-user-container__edit-btn"],children:e.jsx("img",{src:p.getStaticFileUrl("/images/user/Edit.svg"),alt:"edit-avatar"})})}),r&&e.jsx("button",{type:"button",onClick:()=>H(),className:t["image-user-container__delete-btn"],children:e.jsx("img",{src:p.getStaticFileUrl("/images/user/DeleteAvatar.svg"),alt:"delete-avatar"})})]}),e.jsxs("div",{className:t["name-role-container"],children:[e.jsx("div",{className:t.name,children:`${n?.firstName||""} ${n?.lastName||""}`}),e.jsx("div",{className:t.role,children:Array.from(new Set([...n?.msRoles||[],...n?.esRoles||[]])).map(h=>h==="SecondaryTeacher"?"Support Teacher":h).join(", ")})]})]}),e.jsxs("div",{className:t["user-profile-container-admin__left--btn-control"],children:[ce.filter(h=>h.isControl).map(h=>e.jsxs("button",{type:"button",className:`${t.item} ${j===h.value?t["item-active"]:""}`,onClick:()=>f(h.value),children:[e.jsx("img",{src:p.getStaticFileUrl(h.icon),alt:h.icon}),h.label]},h.value)),!!r&&!!R&&U?.id===r&&e.jsxs("button",{type:"button",className:`${t.item} ${j===R.value?t["item-active"]:""}`,onClick:()=>f(R.value),children:[e.jsx("img",{src:p.getStaticFileUrl(R.icon),alt:R.icon}),R.label]},R.value),r&&N&&e.jsxs("button",{type:"button",className:`${t.item} ${j===N.value?t["item-active"]:""}`,onClick:()=>C({email:n?.email||""}),children:[e.jsx("img",{src:p.getStaticFileUrl(N.icon),alt:N.icon}),N.label]},N.value),r&&L&&e.jsxs("button",{type:"button",className:`${t.item} ${j===L.value?t["item-active"]:""}`,onClick:()=>O(),children:[e.jsx("img",{src:p.getStaticFileUrl(L.icon),alt:L.icon}),L.label]},L.value)]})]}),e.jsx("div",{className:t["user-profile-container-admin__right"],children:b.find(h=>h.value===j)?.component})]})};exports.default=as;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),we=require("reactstrap"),m=require("mario-core"),se=require("./constants-DfnEgLPg.cjs"),S=require("react"),te=require("react-redux"),Ne=require("formik"),De=require("yup"),T=require("@mui/material"),Te=require("@mui/x-date-pickers"),Ae=require("moment"),x=require("./OutlinedInput-CkBYF9FZ.cjs"),je=require("./constants-9UnXcqo8.cjs"),Re=require("./DoneCheckInIcon-7Q31KvHI.cjs"),xe=require("./userService-DsbgpY7L.cjs"),Ue=require("./styles.module-CHKJJ8Zm.cjs"),ke=require("./AdapterMoment-B-q0UCj0.cjs"),_e=require("./Visibility-DoYLYxbn.cjs"),Se=require("./IconButton-DwLaeSCN.cjs"),Ee=require("react-router-dom"),Pe=require("date-fns");function Le(t){const o=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const p in t)if(p!=="default"){const v=Object.getOwnPropertyDescriptor(t,p);Object.defineProperty(o,p,v.get?v:{enumerable:!0,get:()=>t[p]})}}return o.default=t,Object.freeze(o)}const j=Le(De),Me="_name_1koi9_205",Ie="_role_1koi9_217",$e="_item_1koi9_230",Fe="_gender_1koi9_323",He="_gender__item_1koi9_328",a={"profile-value":"_profile-value_1koi9_77","input-error":"_input-error_1koi9_94","user-profile-container-admin":"_user-profile-container-admin_1koi9_122","user-profile-container-admin__left":"_user-profile-container-admin__left_1koi9_135","user-profile-container-admin__left--information":"_user-profile-container-admin__left--information_1koi9_146","image-user-container":"_image-user-container_1koi9_154","image-user-container__image":"_image-user-container__image_1koi9_169","image-user-container__edit-btn":"_image-user-container__edit-btn_1koi9_176","image-user-container__delete-btn":"_image-user-container__delete-btn_1koi9_190","name-role-container":"_name-role-container_1koi9_205",name:Me,role:Ie,"user-profile-container-admin__left--btn-control":"_user-profile-container-admin__left--btn-control_1koi9_224",item:$e,"item-active":"_item-active_1koi9_246","user-profile-container-admin__right":"_user-profile-container-admin__right_1koi9_274","edit-profile-container":"_edit-profile-container_1koi9_285","edit-profile-container__title":"_edit-profile-container__title_1koi9_290","edit-profile-container__form":"_edit-profile-container__form_1koi9_297","edit-profile-container__form--row":"_edit-profile-container__form--row_1koi9_302","edit-profile-container__form--field":"_edit-profile-container__form--field_1koi9_307",gender:Fe,gender__item:He,"edit-profile-container__form--width-50":"_edit-profile-container__form--width-50_1koi9_334","edit-profile-container__form--width-30":"_edit-profile-container__form--width-30_1koi9_337","edit-profile-container__form--width-70":"_edit-profile-container__form--width-70_1koi9_340","edit-profile-container__form--btn-group":"_edit-profile-container__form--btn-group_1koi9_343","btn-save":"_btn-save_1koi9_349","btn-cancel":"_btn-cancel_1koi9_371"};var X=(t=>(t.Info="info",t.ForgotPassword="forgotPassword",t.DownloadUserData="downloadUserData",t.ChangePassword="changePassword",t))(X||{});const ue=[{value:"info",label:"Personal Information",icon:"/images/user/User.svg",isControl:!0},{value:"changePassword",label:"Change Password",icon:"/images/user/Lock.svg",isControl:!1},{value:"forgotPassword",label:"Send Forgot Password Link",icon:"/images/user/Lock.svg",isControl:!1},{value:"downloadUserData",label:"Download User Data",icon:"/images/user/Log-out.svg",isControl:!1}],ve=["Admin","Assistant","Teacher","Counselor","General ED teacher","SecondaryTeacher","Parent","Student"],Oe=ve,qe=ve,Be=ve.filter(t=>t!=="SecondaryTeacher"),Ve=t=>t==="both"?["MS","ES"]:[t.toUpperCase()],Ge=t=>t==="both"?"ES, MS":t.toUpperCase(),me=(t,o,p)=>{if(p){if(q.includes(p))return"hs";if(G.includes(p))return"ms";if(V.includes(p))return"es"}const v=(t||"").toUpperCase();if(v==="ES, MS")return"both";if(v==="ES")return"es";if(v==="HS")return"hs";if(v==="MS")return"ms";const h=(o||[]).includes("MS"),u=(o||[]).includes("ES");return(o||[]).includes("HS")&&!h&&!u?"hs":u&&!h?"es":"ms"},f={ADMIN:"Admin",TEACHER:"Teacher",ASSISTANT:"Assistant",EDUTEACHER:"General ED teacher",STUDENT:"Student",PARENT:"Parent"},ze=[{value:!0,label:"Active"},{value:!1,label:"Inactive"}],pe=["K","G","1","2","3","4","5","6","7","8","9","10","11","12",...se.isMalvernCollege?["12/13"]:[],"13",...se.isSaisSchool?["PCS"]:[]],V=["K","G","1","2","3","4","5",...se.isMalvernCollege?["6"]:[]],G=[...se.isMalvernCollege?[]:["6"],"7","8"],q=["9","10","11","12",...se.isMalvernCollege?["12/13"]:[],"13",...se.isSaisSchool?["PCS"]:[]],ye=["Student"],Ye=j.object({firstName:j.string().required("First name is required"),lastName:j.string().required("Last name is required"),email:j.string().email("Email is invalid").required("Email is required"),appTypes:j.array().of(j.string()).min(1,"School tier is required"),msRoles:j.array().of(j.string()).test("ms-role-required","MS role is required",(t,o)=>{const p=me(o.parent.preferredAppType,o.parent.appTypes,o.parent.gradeLevel);return p!=="ms"&&p!=="both"?!0:!!t&&t.length>0}),hsRoles:j.array().of(j.string()).test("hs-role-required","HS role is required",(t,o)=>me(o.parent.preferredAppType,o.parent.appTypes,o.parent.gradeLevel)!=="hs"?!0:!!t&&t.length>0),esRoles:j.array().of(j.string()).test("es-role-required","ES role is required",(t,o)=>{const p=me(o.parent.preferredAppType,o.parent.appTypes,o.parent.gradeLevel);return p!=="es"&&p!=="both"?!0:!!t&&t.length>0}),gradeLevel:j.string().nullable().test("grade-level-required","Grade level is required",(t,o)=>{const p=o.parent.msRoles||[],v=o.parent.esRoles||[],h=o.parent.hsRoles||[];return p.includes("Student")||v.includes("Student")||h.includes("Student")?!!t:!0})}),Je={currentPage:1,pageSize:100},Ke=(t,o)=>{const[p,v]=S.useState([]),[h,u]=S.useState(!1),[R,w]=S.useState(Je),[P,b]=S.useState(),g=te.useDispatch(),$=S.useCallback(async()=>{u(!0);try{const r=(await xe.getRosterUsersApi(R)).data?.items||[];v(F(r))}catch{g(m.setAlert({type:"error",message:"Cannot get roster users"}))}u(!1)},[JSON.stringify(R)]),Z=S.useCallback(async()=>{if(!o)return;const l=p.find(r=>r.value===o);if(l){b(l);return}u(!0);try{const M=(await xe.getRosterUserBySourcedIdApi(o)).data;b({label:H(M),value:M.sourcedId})}catch(r){console.log("err:",r)}u(!1)},[o]),F=l=>l.map(r=>({label:H(r),value:r.sourcedId})),H=l=>{const r=[],{givenName:M,middleName:y,familyName:N,email:U,role:E}=l,_=[];return M&&_.push(M),y&&_.push(y),N&&_.push(N),_.length&&r.push(_.join(" ")),U&&r.push(U),`${r.join(" - ")}${E?` (${E})`:""}`},z=l=>{w(r=>({...r,searchString:l}))},L=S.useCallback(l=>{w({...R,...l})},[JSON.stringify(R)]);return S.useEffect(()=>{R.roles?.length&&$()},[JSON.stringify(R)]),S.useEffect(()=>{L({roles:t})},[JSON.stringify(t)]),S.useEffect(()=>{Z()},[o]),{users:p,isLoading:h,user:P,handleInputChange:z}},We=({value:t,roles:o,onChange:p})=>{const{users:v,isLoading:h,user:u,handleInputChange:R}=Ke(o,t);return e.jsx(T.Select,{label:"Select user",value:u?.value||"",onChange:w=>{p(w.target.value)},onOpen:()=>R(""),disabled:h,className:`${Ue.styles["profile-value"]}`,variant:"outlined",children:h?e.jsx(T.MenuItem,{disabled:!0,children:e.jsx(T.CircularProgress,{size:20})}):v.length>0?v.map(w=>e.jsx(T.MenuItem,{value:w.value,children:`${w.label}`},w.value)):e.jsx(T.MenuItem,{disabled:!0,children:"No users found"})})},Xe=({userDetail:t,confirmData:o,goBack:p,teacherOptions:v,getDataTeachers:h,id:u,checkHasTeacher:R,setCheckHasTeacher:w,userHasData:P,currentRoles:b})=>{const{t:g}=m.useTranslation(),$=S.useRef(null),F=te.useSelector(L=>L.common.user)?.hasEsSchool!==!1,{getLabel:H,system:z}=m.useGradeLabel();return e.jsxs("div",{className:a["edit-profile-container"],children:[e.jsx("div",{className:a["edit-profile-container__title"],children:`${u?"Edit User Profile":"Create User"}`}),e.jsx(Ne.Formik,{initialValues:t,enableReinitialize:!0,onSubmit:L=>{o(L)},validationSchema:Ye,children:L=>{const{values:l,setFieldValue:r,handleSubmit:M,errors:y,touched:N}=L,U=Object.keys(y);U.length&&document.querySelector(`input[name=${U[0]}]`)?.scrollIntoView({behavior:"smooth",block:"center"});const E=l?.appTypes||[],_=E.includes("MS"),fe=E.includes("ES"),Q=E.includes("HS"),ee=l?.msRoles||[],K=l?.esRoles||[],ae=l?.hsRoles||[],D=ee.includes(f.STUDENT)||K.includes(f.STUDENT)||ae.includes(f.STUDENT),k=F?D&&(l?.preferredAppType==="HS"||l?.preferredAppType==="MS")?l.preferredAppType.toLowerCase():me(l?.preferredAppType,E,l?.gradeLevel):D?l?.preferredAppType==="HS"?"hs":l?.preferredAppType==="MS"?"ms":l?.gradeLevel&&q.includes(l.gradeLevel)?"hs":"ms":"ms",ne=k==="ms"||k==="hs"||k==="both",oe=k==="es"||k==="both",ie=D?k==="es"?pe.filter(n=>V.includes(n)):k==="hs"?pe.filter(n=>q.includes(n)):pe.filter(n=>G.includes(n)):pe,le=n=>{const d=n.target.value;r("gradeLevel",d),D&&(q.includes(d)?(r("preferredAppType","HS"),r("hsRoles",[f.STUDENT]),r("msRoles",[]),r("esRoles",[]),u||r("appTypes",["HS"])):G.includes(d)?(r("preferredAppType","MS"),r("msRoles",[f.STUDENT]),r("hsRoles",[]),r("esRoles",[]),u||r("appTypes",["MS"])):V.includes(d)&&(r("preferredAppType","ES"),r("esRoles",[f.STUDENT]),r("msRoles",[]),r("hsRoles",[]),u||r("appTypes",["ES"])))},he=(n,d)=>{if(!d)return;const I=Ve(d),Y=Ge(d),s=i=>{const c=t?.gradeLevel;return i==="hs"?c&&q.includes(c)?c:q[0]:i==="ms"?c&&G.includes(c)?c:G[0]??"6":i==="es"?c&&V.includes(c)?c:V[0]:l?.gradeLevel};u?(r("preferredAppType",Y),D&&(d==="es"?(r("esRoles",[f.STUDENT]),r("msRoles",[]),r("hsRoles",[])):d==="hs"?(r("hsRoles",[f.STUDENT]),r("msRoles",[]),r("esRoles",[])):d==="ms"&&(r("msRoles",[f.STUDENT]),r("hsRoles",[]),r("esRoles",[])),d==="hs"&&l?.gradeLevel&&q.includes(l.gradeLevel)||d==="ms"&&l?.gradeLevel&&G.includes(l.gradeLevel)||d==="es"&&l?.gradeLevel&&V.includes(l.gradeLevel)||r("gradeLevel",s(d)))):(r("appTypes",I),r("preferredAppType",Y),D&&(d==="es"?(r("esRoles",[f.STUDENT]),r("msRoles",[]),r("hsRoles",[])):d==="hs"?(r("hsRoles",[f.STUDENT]),r("msRoles",[]),r("esRoles",[])):d==="ms"&&(r("msRoles",[f.STUDENT]),r("hsRoles",[]),r("esRoles",[])),h(d==="es"?"ES":"MS"),d==="hs"&&l?.gradeLevel&&q.includes(l.gradeLevel)||d==="ms"&&l?.gradeLevel&&G.includes(l.gradeLevel)||d==="es"&&l?.gradeLevel&&V.includes(l.gradeLevel)||r("gradeLevel",s(d))))},ce=b?.MS?.includes(f.STUDENT)||b?.ES?.includes(f.STUDENT)||b?.HS?.includes(f.STUDENT),de=n=>d=>{const I=d.target.value,Y=n==="MS"?"msRoles":n==="ES"?"esRoles":"hsRoles",s=n==="MS"?["esRoles","hsRoles"]:n==="ES"?["msRoles","hsRoles"]:["msRoles","esRoles"],i=$.current,c=P?.[n]??{};if(u&&(c.isHasTeacherData&&i==="Teacher"||c.isHasAssistantData&&i==="Assistant"||c.isHasCounselorData&&i==="Counselor"||c.isHasSecondaryTeacherData&&i==="SecondaryTeacher"||i==="Student"&&(c.isHasAssistantData||c.isHasCounselorData||c.isHasSecondaryTeacherData||c.isHasTeacherData))){alert("Please switch data before removing the role");return}if(ce&&!I.includes(f.STUDENT)){alert("Student account cannot be changed to another role");return}const C=l?.[Y]||[],O=I.some(J=>ye.includes(J))?i&&!C.includes(i)?[i]:[I.find(J=>ye.includes(J))].filter(Boolean):I,B=C.includes(f.STUDENT),ge=O.includes(f.STUDENT);if(r(Y,O),$.current=null,ge){const J=n;r("preferredAppType",J),s.forEach(Ce=>r(Ce,[])),u||(r("appTypes",[J]),h(n==="ES"?"ES":"MS"))}else B&&!ge&&s.forEach(J=>r(J,[]))},re=n=>{const d=n==="MS"?"msRoles":n==="ES"?"esRoles":"hsRoles",I=n==="MS"?ee:n==="ES"?K:l?.hsRoles||[],Y=n==="MS"?Oe:n==="ES"?Be:qe,s=b?.[n]||[];return e.jsxs("div",{className:`${a["edit-profile-container__form--field"]} ${ne&&oe?a["edit-profile-container__form--width-50"]:""}`,children:[e.jsxs("p",{children:[F&&e.jsx("span",{style:{display:"inline-block",fontSize:11,fontWeight:700,color:"#3b4ba8",backgroundColor:"#e9ecfb",borderRadius:4,padding:"1px 6px",marginRight:6,verticalAlign:"middle"},children:n}),F?n==="HS"?"High school roles":n==="MS"?"Middle school roles":"Elementary school roles":n==="HS"?"High school roles":n==="MS"?"Middle school roles":"Roles"," ",e.jsx("sup",{children:"*"})]}),e.jsx(T.Select,{variant:"outlined",multiple:!0,name:d,value:I,renderValue:i=>i.map(c=>c==="SecondaryTeacher"?"Support Teacher":c).join(", "),onChange:de(n),className:`${a["profile-value"]}`,children:Y.map(i=>{const c=u?ce?i!==f.STUDENT:i===f.STUDENT||["Parent"].includes(i)||s.some(C=>["Student","Parent","General ED teacher"].includes(C)):["Parent"].includes(i)||D&&i!==f.STUDENT;return e.jsxs(T.MenuItem,{value:i,disabled:c,onClick:()=>{$.current=i},children:[e.jsx(T.Checkbox,{checked:I.includes(i)}),e.jsx(T.ListItemText,{primary:i==="SecondaryTeacher"?"Support Teacher":i})]},i)})}),y[d]&&N[d]?e.jsx("div",{className:`${a["input-error"]}`,children:y[d]}):null]})};return e.jsxs("div",{className:a["edit-profile-container__form"],children:[e.jsxs("div",{className:a["edit-profile-container__form--row"],children:[e.jsxs("div",{className:`${a["edit-profile-container__form--field"]} ${a["edit-profile-container__form--width-50"]}`,children:[e.jsxs("p",{children:[g("first_name")," ",e.jsx("sup",{children:"*"})]}),e.jsx(T.TextField,{name:"firstName",variant:"outlined",value:l?.firstName||"",onChange:n=>r("firstName",n.target.value)}),y.firstName&&N.firstName?e.jsx("div",{className:`${a["input-error"]}`,children:y.firstName}):null]}),e.jsxs("div",{className:`${a["edit-profile-container__form--field"]} ${a["edit-profile-container__form--width-50"]}`,children:[e.jsxs("p",{children:[g("last_name")," ",e.jsx("sup",{children:"*"})]}),e.jsx(T.TextField,{name:"lastName",variant:"outlined",className:`${a["profile-value"]}`,value:l?.lastName||"",onChange:n=>r("lastName",n.target.value)}),y.lastName&&N.lastName?e.jsx("div",{className:`${a["input-error"]}`,children:y.lastName}):null]})]}),e.jsxs("div",{className:a["edit-profile-container__form--row"],children:[e.jsxs("div",{className:`${a["edit-profile-container__form--field"]} ${a["edit-profile-container__form--width-30"]}`,children:[e.jsxs("p",{children:[" ",g("date_of_birth")]}),e.jsx(Te.LocalizationProvider,{dateAdapter:ke.AdapterMoment,children:e.jsx(Te.DatePicker,{format:"Do MMM YYYY",value:l?.dateOfBirth&&!je.DATE_MIN_VALUE.includes(l?.dateOfBirth)?Ae(l?.dateOfBirth):null,onChange:n=>{if(n){const d=n.format("YYYY-MM-DD");r("dateOfBirth",d)}else r("dateOfBirth",null)},slotProps:{textField:{variant:"outlined",id:"time-picker",className:`${a["profile-value"]}`},openPickerButton:{"aria-label":"change date"}}})})]}),e.jsxs("div",{className:`${a["edit-profile-container__form--field"]} ${a["edit-profile-container__form--width-70"]}`,children:[e.jsxs("p",{children:[g("email")," ",e.jsx("sup",{children:"*"})]}),e.jsx(T.TextField,{name:"email",variant:"outlined",className:`${a["profile-value"]}`,value:l?.email||"",onChange:n=>r("email",n.target.value)}),y.email&&N.email?e.jsx("div",{className:`${a["input-error"]}`,children:y.email}):null]})]}),e.jsxs("div",{style:{border:"1px solid #e0e0e0",borderRadius:"12px",marginBottom:"24px",overflow:"hidden"},children:[F&&e.jsx("div",{style:{backgroundColor:"#f8f9fa",padding:"16px 24px",borderBottom:"1px solid #e0e0e0"},children:e.jsxs("div",{className:`${a["edit-profile-container__form--field"]}`,style:{marginBottom:0,width:"100%"},children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[e.jsxs("div",{children:[e.jsxs("p",{style:{marginBottom:4,fontWeight:600,fontSize:16},children:["School tier ",e.jsx("sup",{children:"*"})]}),e.jsx("p",{style:{fontSize:13,color:"#6c757d",marginTop:0,marginBottom:0},children:"Pick a tier. Roles are assigned per tier."})]}),e.jsxs(T.ToggleButtonGroup,{exclusive:!0,value:k,onChange:he,size:"small",sx:{border:"1px solid #e0e0e0",borderRadius:"30px",padding:"4px",backgroundColor:"#fff","& .MuiToggleButton-root":{border:"none",borderRadius:"30px !important",textTransform:"none",padding:"6px 20px",margin:"0",color:"#6c757d",fontWeight:500,fontSize:14,"&.Mui-selected":{backgroundColor:"#2b65d9",color:"#fff","&:hover":{backgroundColor:"#1d4ed8"}}}},children:[e.jsx(T.ToggleButton,{value:"ms",disabled:!!u&&!_&&!Q&&D,children:"Middle school"}),e.jsx(T.ToggleButton,{value:"hs",disabled:!!u&&!_&&!Q&&D,children:"High school"}),e.jsx(T.ToggleButton,{value:"es",disabled:!!u&&!fe&&D,children:"Elementary"}),!D&&e.jsx(T.ToggleButton,{value:"both",disabled:!1,children:"Both"})]})]}),y.appTypes&&N.appTypes?e.jsx("div",{className:`${a["input-error"]}`,children:y.appTypes}):null]})}),e.jsx("div",{style:{backgroundColor:"#fff",padding:"24px"},children:e.jsxs("div",{className:a["edit-profile-container__form--row"],style:{margin:0},children:[oe&&re("ES"),k==="hs"?re("HS"):ne&&re("MS")]})})]}),e.jsx("div",{className:a["edit-profile-container__form--row"],children:e.jsxs("div",{className:`${a["edit-profile-container__form--field"]} ${a["edit-profile-container__form--width-50"]}`,children:[e.jsx("p",{children:g("status")}),e.jsx("div",{className:`${a.gender}`,children:ze.map(n=>e.jsxs("div",{className:`${a.gender__item}`,children:[e.jsx(T.Radio,{color:"primary",value:n.value,checked:l?.isActive===n.value,onChange:()=>r("isActive",n.value),disabled:!!u&&!!l?.isImportedFromIntegration}),n.label]},n.label))})]})}),D&&!u&&!!v&&e.jsx("div",{className:a["edit-profile-container__form--row"],children:e.jsxs("div",{className:`${a["edit-profile-container__form--field"]}`,children:[e.jsxs("p",{children:["Assign Teacher ",e.jsx("sup",{children:"*"})]}),e.jsx(T.Select,{multiple:!0,variant:"outlined",name:"teacherUserId",value:l?.teacherUserId||[],renderValue:n=>v.filter(d=>n.includes(d.value)).map(d=>d.label).join(", "),onChange:n=>{const d=n.target.value;r("teacherUserId",d),w(!!d.length)},className:`${a["profile-value"]}`,children:v?.map(n=>e.jsx(T.MenuItem,{value:n.value,children:n.label},n.value))}),!R&&e.jsx("div",{className:`${a["input-error"]}`,children:"Teacher is required"})]})}),D&&e.jsx("div",{className:a["edit-profile-container__form--row"],children:e.jsxs("div",{className:`${a["edit-profile-container__form--field"]} ${a["edit-profile-container__form--width-50"]}`,children:[e.jsxs("p",{children:[" ",z==="UK"?"Year":g("grade_level")," ",e.jsx("sup",{children:"*"})]}),e.jsxs(T.Select,{variant:"outlined",value:l?.gradeLevel??"",renderValue:n=>H(n),onChange:le,className:`${a["profile-value"]}`,children:[l?.gradeLevel&&!ie.includes(l.gradeLevel)&&e.jsx(T.MenuItem,{value:l.gradeLevel,sx:{display:"none"},children:H(l.gradeLevel)},"__current__"),ie.map(n=>e.jsx(T.MenuItem,{value:n,children:H(n)},n))]}),y.gradeLevel&&N.gradeLevel?e.jsx("div",{className:`${a["input-error"]}`,children:y.gradeLevel}):null]})}),!D&&(!!ee.length||!!K.length)&&!!u&&e.jsx("div",{className:a["edit-profile-container__form--row"],children:e.jsxs("div",{className:`${a["edit-profile-container__form--field"]} ${a["edit-profile-container__form--width-50"]}`,children:[e.jsx("p",{children:g("Map from Roster")}),e.jsx(We,{roles:[...ee,...K],value:l.sourcedId,onChange:n=>r("sourcedId",n)})]})}),e.jsxs("div",{className:a["edit-profile-container__form--btn-group"],children:[e.jsx("button",{type:"button",className:a["btn-cancel"],onClick:()=>p(),children:g("cancel")}),e.jsxs("button",{type:"button",className:a["btn-save"],onClick:()=>M(),children:[e.jsx(Re.DoneCheckInIcon,{color:"#fff"}),g("save_changes")]})]})]})}})]})},A={"input-error":"_input-error_gmvmh_1","change-password-container":"_change-password-container_gmvmh_6","change-password-container__title":"_change-password-container__title_gmvmh_11","change-password-container__form":"_change-password-container__form_gmvmh_19","change-password-container__form--field":"_change-password-container__form--field_gmvmh_24","change-password-container__form--description":"_change-password-container__form--description_gmvmh_38","change-password-container__form--btn-group":"_change-password-container__form--btn-group_gmvmh_54","btn-save":"_btn-save_gmvmh_60","btn-cancel":"_btn-cancel_gmvmh_82"},Ze=j.object({oldPassword:j.string().required("Old password is required"),newPassword:j.string().required("New password is required"),confirmedNewPassword:j.string().oneOf([j.ref("newPassword"),void 0],"New password must match").required("Confirm your new password")}),Qe=({confirmChangePassword:t,goBack:o})=>{const{t:p}=m.useTranslation();return e.jsxs("div",{className:A["change-password-container"],children:[e.jsx("div",{className:A["change-password-container__title"],children:p("change_password")}),e.jsx(Ne.Formik,{initialValues:{oldPassword:"",newPassword:"",confirmedNewPassword:"",showOldPassword:!1,showNewPassword:!1,showConfirmNewPassword:!1},enableReinitialize:!0,onSubmit:v=>{t(v)},validateOnChange:!1,validateOnBlur:!1,validationSchema:Ze,children:v=>{const{values:h,setFieldValue:u,handleSubmit:R,errors:w,touched:P}=v,b=Object.keys(w);return b.length&&document.querySelector(`input[name=${b[0]}]`)?.scrollIntoView({behavior:"smooth",block:"center"}),e.jsxs("div",{className:A["change-password-container__form"],children:[e.jsxs("div",{className:`${A["change-password-container__form--field"]}`,children:[e.jsx("p",{children:p("old_password")}),e.jsx(x.FormControl,{variant:"outlined",className:`${A["input-field"]}`,children:e.jsx(x.OutlinedInput,{type:h.showOldPassword?"text":"password",value:h?.oldPassword,onChange:g=>u("oldPassword",g.target.value.trim()),endAdornment:e.jsx(x.InputAdornment,{position:"end",children:e.jsx(Se.IconButton,{"aria-label":"toggle password visibility",onClick:()=>u("showOldPassword",!h.showOldPassword),onMouseDown:g=>g.preventDefault(),children:h.showOldPassword?e.jsx(_e.Visibility,{color:"primary"}):e.jsx(x.VisibilityOff,{color:"primary"})})})})}),w.oldPassword&&P.oldPassword&&e.jsx("div",{className:`${A["input-error"]}`,children:w.oldPassword})]}),e.jsxs("div",{className:`${A["change-password-container__form--field"]}`,children:[e.jsx("p",{children:p("new_password")}),e.jsx(x.FormControl,{variant:"outlined",className:`${A["input-field"]}`,children:e.jsx(x.OutlinedInput,{type:h.showNewPassword?"text":"password",value:h?.newPassword,onChange:g=>u("newPassword",g.target.value.trim()),endAdornment:e.jsx(x.InputAdornment,{position:"end",children:e.jsx(Se.IconButton,{"aria-label":"toggle password visibility",onClick:()=>u("showNewPassword",!h.showNewPassword),onMouseDown:g=>g.preventDefault(),children:h.showNewPassword?e.jsx(_e.Visibility,{color:"primary"}):e.jsx(x.VisibilityOff,{color:"primary"})})})})}),w.newPassword&&P.newPassword&&e.jsx("div",{className:`${A["input-error"]}`,children:w.newPassword}),e.jsxs("div",{className:`${A["change-password-container__form--description"]}`,children:["Password must contain at least: 1 uppercase letter, 1 lowercase letter,",e.jsx("br",{})," 1 number, and 1 special character"]})]}),e.jsxs("div",{className:`${A["change-password-container__form--field"]}`,children:[e.jsx("p",{children:p("confirm_new_password")}),e.jsx(x.FormControl,{variant:"outlined",className:`${A["input-field"]}`,children:e.jsx(x.OutlinedInput,{type:h.showConfirmNewPassword?"text":"password",value:h?.confirmedNewPassword,onChange:g=>u("confirmedNewPassword",g.target.value.trim()),endAdornment:e.jsx(x.InputAdornment,{position:"end",children:e.jsx(Se.IconButton,{"aria-label":"toggle password visibility",onClick:()=>u("showConfirmNewPassword",!h.showConfirmNewPassword),onMouseDown:g=>g.preventDefault(),children:h.showConfirmNewPassword?e.jsx(_e.Visibility,{color:"primary"}):e.jsx(x.VisibilityOff,{color:"primary"})})})})}),w.confirmedNewPassword&&P.confirmedNewPassword&&e.jsx("div",{className:`${A["input-error"]}`,children:w.confirmedNewPassword})]}),e.jsxs("div",{className:A["change-password-container__form--btn-group"],children:[e.jsx("button",{type:"button",className:A["btn-cancel"],onClick:()=>{o()},children:p("cancel")}),e.jsxs("button",{type:"button",className:A["btn-save"],onClick:()=>R(),children:[e.jsx(Re.DoneCheckInIcon,{color:"#fff"}),p("save_new_password")]})]})]})}})]})},es={id:"",firstName:"",lastName:"",email:"",dateOfBirth:je.DATE_MIN_VALUE,msRoles:[],esRoles:[],hsRoles:[],isActive:!0,profileImageFileName:"",teacherUserId:[],gradeLevel:"",currentGradeLevel:"",isImportedFromIntegration:!1,appTypes:["MS"],preferredAppType:"MS"},be="/admin/users/user-list",ss="User detail",rs=12,ts=20,as=t=>{const o=te.useDispatch(),p=Ee.useNavigate(),v=te.useSelector(s=>s.common.user),h=te.useSelector(s=>s.common?.defaultFontSize),[u,R]=S.useState(es),[w,P]=S.useState(null),[b,g]=S.useState(!1),[$,Z]=S.useState({MS:[],ES:[],HS:[]}),[F,H]=S.useState([]),[z,L]=S.useState(!1),[l,r]=S.useState(X.Info),[M,y]=S.useState(!0),[N,U]=S.useState({}),E=async()=>{localStorage.setItem(window.location.href,"true"),g(!0)},_=()=>{L(!z)},fe=S.useMemo(()=>h==ts?"font-large":h==rs?"font-small":"",[h]);S.useEffect(()=>{document.title=ss,g(!1),localStorage.getItem(window.location.href)&&localStorage.removeItem(window.location.href)},[]),S.useEffect(()=>{t&&ee(),!t&&le()},[t]);const Q=(s=[])=>s.includes("EduTeacher")?[...s.filter(i=>i!=="EduTeacher"),f.EDUTEACHER]:s,ee=S.useCallback(async()=>{o(m.setLoading(!0));try{const s=await x.getByIdUser(t),i=(s.data.appTypeRaw||s.data.appType||"MS").toUpperCase(),c=i.includes("MS"),C=i.includes("ES"),W=i.includes("HS"),O=[];C&&O.push("ES"),c&&O.push("MS"),W&&O.push("HS"),O.length===0&&O.push("MS");let B=s.data.preferredAppType||i;((s.data.roles||[]).includes("Student")||(s.data.msRoles||[]).includes("Student")||(s.data.esRoles||[]).includes("Student"))&&s.data.gradeLevel&&(q.includes(s.data.gradeLevel)?B="HS":G.includes(s.data.gradeLevel)?B="MS":V.includes(s.data.gradeLevel)&&(B="ES")),R({...s.data,dateOfBirth:Pe.format(new Date(s.data.dateOfBirth),m.DATE_FORMAT),msRoles:Q(s.data.msRoles),esRoles:Q(s.data.esRoles),hsRoles:Q(s.data.hsRoles),currentGradeLevel:s.data.gradeLevel,appTypes:O,preferredAppType:B}),Z({MS:s.data.msRoles??[],ES:s.data.esRoles??[],HS:s.data.hsRoles??[]}),document.title=s.data?.fullName,(c||W)&&K("MS"),C&&K("ES")}catch(s){o(m.setAlert({type:"danger",message:s.response?.data?.title||s.message}))}o(m.setLoading(!1))},[t]),K=S.useCallback(async s=>{o(m.setLoading(!0));try{const i=await x.userRoleHasDataApi(t,s);U(c=>({...c,[s]:i.data}))}catch(i){o(m.setAlert({type:"danger",message:i.response?.data?.title||i.message}))}o(m.setLoading(!1))},[t]),ae=S.useCallback(s=>{p(s&&typeof s=="string"?be+`?query=${s}`:be)},[]),D=s=>["Student","Parent","EduTeacher"].includes(s),k=(s=[])=>s.includes(f.EDUTEACHER)?[...s.filter(i=>i!==f.EDUTEACHER),"EduTeacher"]:s,ne=S.useCallback(async s=>{const i=s.msRoles?.includes(f.STUDENT)||s.esRoles?.includes(f.STUDENT)||s.hsRoles?.includes(f.STUDENT);if(i&&!t&&!s.teacherUserId){y(!1);return}i&&s.gradeLevel&&(q.includes(s.gradeLevel)?(s.preferredAppType="HS",s.hsRoles=[f.STUDENT],s.msRoles=[],s.esRoles=[]):G.includes(s.gradeLevel)?(s.preferredAppType="MS",s.msRoles=[f.STUDENT],s.hsRoles=[],s.esRoles=[]):V.includes(s.gradeLevel)&&(s.preferredAppType="ES",s.esRoles=[f.STUDENT],s.msRoles=[],s.hsRoles=[])),o(m.setLoading(!0));try{v?.hasEsSchool===!1&&(s.preferredAppType!=="HS"?(s.appTypes=["MS"],s.preferredAppType="MS"):s.appTypes=["HS"],s.esRoles=[]);const c=t?x.update:x.create;!t&&delete s.id,s.teacherUserId=i?s.teacherUserId:[],s.msRoles=k(s.msRoles),s.esRoles=k(s.esRoles),s.hsRoles=k(s.hsRoles),i&&(s.preferredAppType==="HS"?(s.hsRoles=[f.STUDENT],s.msRoles=[],s.esRoles=[]):s.preferredAppType==="ES"?(s.esRoles=[f.STUDENT],s.msRoles=[],s.hsRoles=[]):(s.msRoles=[f.STUDENT],s.hsRoles=[],s.esRoles=[])),t||(s.profileImageFileName=w||"");const C=await c(s);C&&x.getByIdUser(C.data.id).then(W=>{ae(W.data.fullName)}),t||alert("Password of "+C.data.email+` is "${C.data.password}"`),o(m.setAlert({type:"success",message:`${t?"Update":"Create"} user successfully`}))}catch(c){o(m.setAlert({type:"danger",message:c.response?.data?.title||c.message}))}o(m.setLoading(!1))},[t,w]),oe=async s=>{o(m.setLoading(!0));try{await x.changePassword(s),o(m.setAlert({type:"success",message:"Change password successfully"}))}catch(i){o(m.setAlert({type:"danger",message:i.response?.data?.title||i.message}))}o(m.setLoading(!1))},ie=S.useCallback(async s=>{o(m.setLoading(!0));try{await x.forgotChangePassword(s),o(m.setAlert({type:"success",message:"Send forgot password link successfully"}))}catch(i){o(m.setAlert({type:"danger",message:i.response?.data?.title||i.message||"Error occured"}))}o(m.setLoading(!1))},[]),le=async s=>{try{const i=await x.getTeachers({sortBy:"Email"},s);i.data&&H((i.data.map?.(c=>({label:c.email,value:c.id}))||[]).sort((c,C)=>c.label.localeCompare(C.label)))}catch(i){o(m.setAlert({type:"danger",message:i.response?.data?.title||i.message}))}},he=20097152,[ce,de]=S.useState(""),re=s=>{s.preventDefault();let i=new FileReader,c=s.target.files[0];if(c.size>he){o(m.setAlert({type:"danger",message:"File can't be larger than 2MB"}));return}i.onloadend=async()=>{if(de(i.result),c){const C=new FormData,{name:W}=c;C.append("file",c,W);const B=(await x.systemProfileUpload(C))?.data?.key;t?await x.updateAvatarByAdminApi(u.id||"",B):P(B)}},c&&i.readAsDataURL(c)},n=async()=>{await x.updateAvatarByAdminApi(u.id||"",""),de("")},d=ce||m.getFileUrl(u?.profileImageFileName),I=u?.profileImageFileName||"";return{userDetail:u,getDataTeachers:le,backToList:ae,confirmData:ne,file:w,setFile:P,edited:b,currentRoles:$,setEdited:g,setEditedTrue:E,confirmChangePassword:oe,forgotPasswordRequest:ie,handleDisableRoles:D,classFontSize:fe,teacherOptions:F,handleToggleModel:_,openModel:z,user:v,activeTab:l,setActiveTab:r,imageSrc:d,imageUse:I,handleImageChange:re,handleDeleteAvatar:n,getFile:()=>{var s=window.location.origin+"/api/ExportDataUser/"+t;window.open(s)},checkHasTeacher:M,setCheckHasTeacher:y,userHasData:N}},ns="/images/image-default.png",os=()=>{const{id:t}=Ee.useParams(),{userDetail:o,getDataTeachers:p,backToList:v,confirmData:h,confirmChangePassword:u,forgotPasswordRequest:R,teacherOptions:w,user:P,activeTab:b,setActiveTab:g,imageSrc:$,handleImageChange:Z,handleDeleteAvatar:F,getFile:H,currentRoles:z,handleDisableRoles:L,checkHasTeacher:l,setCheckHasTeacher:r,userHasData:M}=as(t),y=[{value:X.Info,component:e.jsx(Xe,{id:t,goBack:v,userDetail:o,confirmData:h,teacherOptions:w,getDataTeachers:p,currentRoles:z,handleDisableRoles:L,checkHasTeacher:l,setCheckHasTeacher:r,userHasData:M})},{value:X.ChangePassword,component:e.jsx(Qe,{confirmChangePassword:u,goBack:v})}],N=ue.find(_=>_.value===X.ForgotPassword),U=ue.find(_=>_.value===X.DownloadUserData),E=ue.find(_=>_.value===X.ChangePassword);return e.jsxs("div",{className:a["user-profile-container-admin"],children:[e.jsxs("div",{className:a["user-profile-container-admin__left"],children:[e.jsxs("div",{className:a["user-profile-container-admin__left--information"],children:[e.jsxs("div",{className:a["image-user-container"],children:[e.jsx(we.Input,{className:"d-none",type:"file",id:"uploadFile",onChange:Z,accept:"image/*"}),e.jsx("img",{src:$||m.getStaticFileUrl(ns),alt:"avatar",className:`${a["image-user-container__image"]}`}),e.jsx(we.Label,{htmlFor:"uploadFile",role:"button",tabIndex:0,children:e.jsx("div",{className:a["image-user-container__edit-btn"],children:e.jsx("img",{src:m.getStaticFileUrl("/images/user/Edit.svg"),alt:"edit-avatar"})})}),t&&e.jsx("button",{type:"button",onClick:()=>F(),className:a["image-user-container__delete-btn"],children:e.jsx("img",{src:m.getStaticFileUrl("/images/user/DeleteAvatar.svg"),alt:"delete-avatar"})})]}),e.jsxs("div",{className:a["name-role-container"],children:[e.jsx("div",{className:a.name,children:`${o?.firstName||""} ${o?.lastName||""}`}),e.jsx("div",{className:a.role,children:Array.from(new Set([...o?.msRoles||[],...o?.esRoles||[]])).map(_=>_==="SecondaryTeacher"?"Support Teacher":_).join(", ")})]})]}),e.jsxs("div",{className:a["user-profile-container-admin__left--btn-control"],children:[ue.filter(_=>_.isControl).map(_=>e.jsxs("button",{type:"button",className:`${a.item} ${b===_.value?a["item-active"]:""}`,onClick:()=>g(_.value),children:[e.jsx("img",{src:m.getStaticFileUrl(_.icon),alt:_.icon}),_.label]},_.value)),!!t&&!!E&&P?.id===t&&e.jsxs("button",{type:"button",className:`${a.item} ${b===E.value?a["item-active"]:""}`,onClick:()=>g(E.value),children:[e.jsx("img",{src:m.getStaticFileUrl(E.icon),alt:E.icon}),E.label]},E.value),t&&N&&e.jsxs("button",{type:"button",className:`${a.item} ${b===N.value?a["item-active"]:""}`,onClick:()=>R({email:o?.email||""}),children:[e.jsx("img",{src:m.getStaticFileUrl(N.icon),alt:N.icon}),N.label]},N.value),t&&U&&e.jsxs("button",{type:"button",className:`${a.item} ${b===U.value?a["item-active"]:""}`,onClick:()=>H(),children:[e.jsx("img",{src:m.getStaticFileUrl(U.icon),alt:U.icon}),U.label]},U.value)]})]}),e.jsx("div",{className:a["user-profile-container-admin__right"],children:y.find(_=>_.value===b)?.component})]})};exports.default=os;
|