mario-education 2.0.98-staging → 2.0.99-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/MyProfile-BkmMLmdD.cjs +1 -0
- package/dist/MyProfile-DSl7kYQ6.js +716 -0
- package/dist/OutlinedInput-BZO6vjyn.js +1758 -0
- package/dist/OutlinedInput-DQEM2Wtc.cjs +4 -0
- package/dist/UserProfileManagement-7x_FM8qD.js +1127 -0
- package/dist/UserProfileManagement-CaTBAlbV.cjs +1 -0
- package/dist/index.js +1 -1
- package/dist/index.modern.js +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),O=require("reactstrap"),x=require("react"),$=require("react-redux"),i=require("mario-core"),d=require("./OutlinedInput-DQEM2Wtc.cjs"),q=require("react-router-dom"),D=require("formik"),L=require("yup"),P=require("@mui/material"),A=require("@mui/x-date-pickers"),V=require("moment"),M=require("react-phone-number-input"),T=require("./DoneCheckInIcon-7Q31KvHI.cjs"),z=require("./AdapterMoment-B-q0UCj0.cjs"),S=require("./Visibility-CDU117S_.cjs"),I=require("./IconButton-DWhytE6k.cjs");function K(s){const u=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(s){for(const m in s)if(m!=="default"){const n=Object.getOwnPropertyDescriptor(s,m);Object.defineProperty(u,m,n.get?n:{enumerable:!0,get:()=>s[m]})}}return u.default=s,Object.freeze(u)}const w=K(L),Y="_name_w9305_205",G="_role_w9305_217",X="_item_w9305_230",Z="_gender_w9305_320",H="_gender__item_w9305_325",r={"profile-value":"_profile-value_w9305_77","input-error":"_input-error_w9305_94","user-profile-container-admin":"_user-profile-container-admin_w9305_122","user-profile-container-admin__left":"_user-profile-container-admin__left_w9305_135","user-profile-container-admin__left--information":"_user-profile-container-admin__left--information_w9305_146","image-user-container":"_image-user-container_w9305_154","image-user-container__image":"_image-user-container__image_w9305_169","image-user-container__edit-btn":"_image-user-container__edit-btn_w9305_176","image-user-container__delete-btn":"_image-user-container__delete-btn_w9305_190","name-role-container":"_name-role-container_w9305_205",name:Y,role:G,"user-profile-container-admin__left--btn-control":"_user-profile-container-admin__left--btn-control_w9305_224",item:X,"item-active":"_item-active_w9305_246","user-profile-container-admin__left--sign-out":"_user-profile-container-admin__left--sign-out_w9305_249","user-profile-container-admin__right":"_user-profile-container-admin__right_w9305_274","edit-profile-container":"_edit-profile-container_w9305_285","edit-profile-container__title":"_edit-profile-container__title_w9305_290","edit-profile-container__form":"_edit-profile-container__form_w9305_297","edit-profile-container__form--row":"_edit-profile-container__form--row_w9305_302","edit-profile-container__form--field":"_edit-profile-container__form--field_w9305_307",gender:Z,gender__item:H,"edit-profile-container__form--width-50":"_edit-profile-container__form--width-50_w9305_331","edit-profile-container__form--width-30":"_edit-profile-container__form--width-30_w9305_334","edit-profile-container__form--width-70":"_edit-profile-container__form--width-70_w9305_337","edit-profile-container__form--btn-group":"_edit-profile-container__form--btn-group_w9305_340","btn-save":"_btn-save_w9305_346","btn-cancel":"_btn-cancel_w9305_368","custom-phone-input-container":"_custom-phone-input-container_w9305_399"},b={Info:"info",ChangePassword:"changePassword",Signout:"signout"},k=[{value:b.Info,label:"Personal Information",icon:"/images/user/User.svg",isControl:!0},{value:b.ChangePassword,label:"Change Password",icon:"/images/user/Lock.svg",isControl:!0},{value:b.Signout,label:"Sign Out",icon:"/images/user/Log-out.svg",isControl:!1}],J=["Male","Female","NonBinary","Other"],Q={firstName:"",lastName:"",legalGender:"",dateOfBirth:"",teacherRole:"",email:"",country:"US",phoneNumber:"",address:""},W=()=>{const{t:s}=i.useTranslation(),u=q.useNavigate(),m=$.useSelector(h=>h.common.user),n=$.useDispatch(),[f,t]=x.useState(Q),[o,j]=x.useState(b.Info),[c,p]=x.useState(""),g=x.useCallback(async()=>{n(i.setLoading(!0));try{const h=await d.getByIdUser(m?.id);t(h.data),p(i.getFileUrl(h.data?.profileImageFileName||""))}catch(h){n(i.setAlert({type:"danger",message:h.response?.data?.title||h.message}))}n(i.setLoading(!1))},[]),a=async h=>{n(i.setLoading(!0));try{await d.updateProfileTeacher(h);const{firstName:v,lastName:N,email:y,profileImageFileName:C}=h;n(i.setUser({...m,firstName:v,lastName:N,email:y,profileImageFileName:C})),n(i.setAlert({type:"success",message:"Update user successfully"}))}catch(v){n(i.setAlert({type:"danger",message:v.response?.data?.title||v.message}))}n(i.setLoading(!1))},l=20097152,U=h=>{h.preventDefault();let v=new FileReader,N=h.target.files[0];if(N.size>l){n(i.setAlert({type:"danger",message:"File can't be larger than 2MB"}));return}v.onloadend=async()=>{if(p(v.result),N){const y=new FormData,{name:C}=N;y.append("file",N,C);const F=(await d.systemProfileUpload(y))?.data?.key;await d.updateAvatarApi(F),n(i.setUser({...m,profileImageFileName:F}))}},N&&v.readAsDataURL(N)},E=async()=>{await d.updateAvatarApi(""),p(""),n(i.setUser({...m,profileImageFileName:""}))},B=f?.profileImageFileName||"",R=()=>{u("/home")};return x.useEffect(()=>{o==b.Info&&g()},[o]),x.useEffect(()=>{document.title=s("my_profile")},[]),{dataProfile:f,updateProfile:a,activeTab:o,setActiveTab:j,handleImageChange:U,handleDeleteAvatar:E,imageUse:B,imagePreviewUrl:c,currentUser:m,goBack:R,signout:()=>{localStorage.removeItem(i.ACCESS_TOKEN),sessionStorage.removeItem(i.ACCESS_TOKEN),localStorage.removeItem("ROLES"),n(i.reset()),u("/",{replace:!0})}}},ee=w.object({firstName:w.string().trim().required("First name is required"),lastName:w.string().trim().required("Last name is required"),email:w.string().email("Invalid email").trim().required("Email is required")}),re=({dataProfile:s,updateProfile:u,goBack:m})=>{const{t:n}=i.useTranslation();return e.jsxs("div",{className:r["edit-profile-container"],children:[e.jsx("div",{className:r["edit-profile-container__title"],children:n("edit_my_profile")}),e.jsx(D.Formik,{initialValues:s,enableReinitialize:!0,onSubmit:f=>{u(f)},validationSchema:ee,children:f=>{const{values:t,setFieldValue:o,handleSubmit:j,errors:c,touched:p}=f,g=Object.keys(c);return g.length&&document.querySelector(`input[name=${g[0]}]`)?.scrollIntoView({behavior:"smooth",block:"center"}),!!s&&e.jsxs("div",{className:r["edit-profile-container__form"],children:[e.jsxs("div",{className:r["edit-profile-container__form--row"],children:[e.jsxs("div",{className:`${r["edit-profile-container__form--field"]} ${r["edit-profile-container__form--width-50"]}`,children:[e.jsx("p",{children:n("first_name")}),e.jsx(P.TextField,{name:"firstName",variant:"outlined",value:t?.firstName||"",onChange:a=>o("firstName",a.target.value)}),c.firstName&&p.firstName?e.jsx("div",{className:`${r["input-error"]}`,children:String(c.firstName)}):null]}),e.jsxs("div",{className:`${r["edit-profile-container__form--field"]} ${r["edit-profile-container__form--width-50"]}`,children:[e.jsx("p",{children:n("last_name")}),e.jsx(P.TextField,{name:"lastName",variant:"outlined",className:`${r["profile-value"]}`,value:t?.lastName||"",onChange:a=>o("lastName",a.target.value)}),c.lastName&&p.lastName?e.jsx("div",{className:`${r["input-error"]}`,children:String(c.lastName)}):null]})]}),e.jsx("div",{className:r["edit-profile-container__form--row"],children:e.jsxs("div",{className:`${r["edit-profile-container__form--field"]}`,children:[e.jsx("p",{children:n("gender")}),e.jsx("div",{className:`${r.gender}`,children:J.map(a=>e.jsxs("div",{className:`${r.gender__item}`,children:[e.jsx(P.Radio,{color:"primary",value:a,checked:t?.legalGender===a,onChange:()=>o("legalGender",a)}),a]},a))})]})}),e.jsxs("div",{className:r["edit-profile-container__form--row"],children:[e.jsxs("div",{className:`${r["edit-profile-container__form--field"]} ${r["edit-profile-container__form--width-30"]}`,children:[e.jsxs("p",{children:[" ",n("date_of_birth")]}),e.jsx(A.LocalizationProvider,{dateAdapter:z.AdapterMoment,children:e.jsx(A.DatePicker,{format:"Do MMM YYYY",value:t?.dateOfBirth?V(t?.dateOfBirth):null,onChange:a=>o("dateOfBirth",new Date(a)),slotProps:{textField:{id:"time-picker",variant:"outlined",className:`${r["profile-value"]}`}}})})]}),e.jsxs("div",{className:`${r["edit-profile-container__form--field"]} ${r["edit-profile-container__form--width-70"]}`,children:[e.jsxs("p",{children:[" ",n("role")]}),e.jsx(P.Select,{multiple:!0,disabled:!0,name:"roles",variant:"outlined",value:t?.roles||[],renderValue:a=>a.map(l=>l==="SecondaryTeacher"?"Support Teacher":l).join(", "),className:`${r["profile-value"]}`})]})]}),e.jsxs("div",{className:r["edit-profile-container__form--row"],children:[e.jsxs("div",{className:`${r["edit-profile-container__form--field"]} ${r["edit-profile-container__form--width-50"]}`,children:[e.jsx("p",{children:n("email")}),e.jsx(P.TextField,{name:"email",variant:"outlined",className:`${r["profile-value"]}`,value:t?.email||"",onChange:a=>o("email",a.target.value)}),c.email&&p.email?e.jsx("div",{className:`${r["input-error"]}`,children:String(c.email)}):null]}),e.jsxs("div",{className:`${r["edit-profile-container__form--field"]} ${r["edit-profile-container__form--width-50"]}`,children:[e.jsx("p",{children:n("phone")}),e.jsx(M,{placeholder:"(000) 000-0000",defaultCountry:t.country||"US",value:t.phoneNumber,onChange:a=>o("phoneNumber",a),className:`${r["custom-phone-input-container"]}`,onCountryChange:a=>{o("country",a)}})]})]}),e.jsx("div",{className:r["edit-profile-container__form--row"],children:e.jsxs("div",{className:`${r["edit-profile-container__form--field"]}`,children:[e.jsx("p",{children:n("location")}),e.jsx(P.TextField,{name:"address",variant:"outlined",className:`${r["profile-value"]}`,value:t?.address||"",onChange:a=>o("address",a.target.value)})]})}),e.jsxs("div",{className:r["edit-profile-container__form--btn-group"],children:[e.jsx("button",{type:"button",className:r["btn-cancel"],onClick:()=>m(),children:n("cancel")}),e.jsxs("button",{type:"button",className:r["btn-save"],onClick:()=>j(),children:[e.jsx(T.DoneCheckInIcon,{color:"#fff"}),n("save_changes")]})]})]})}})]})},_={"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--forgot-password":"_change-password-container__form--forgot-password_gmvmh_45","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"},ae=()=>{const s=$.useDispatch(),u=q.useNavigate();return x.useEffect(()=>{document.title="Change Password"},[]),{changePassword:async t=>{s(i.setLoading(!0));try{await d.changePasswordApi(t),s(i.setAlert({type:"success",message:"Change password successfully"}))}catch(o){s(i.setAlert({type:"danger",message:o.response?.data?.title||o.message}))}s(i.setLoading(!1))},goBack:()=>{u("/home")},handleRedirectForgotPassword:()=>{localStorage.removeItem(i.ACCESS_TOKEN),sessionStorage.removeItem(i.ACCESS_TOKEN),localStorage.removeItem("ROLES"),s(i.reset()),u("/forgot-password")}}},ne=w.object({oldPassword:w.string().required("Old password is required"),newPassword:w.string().required("New password is required"),confirmedNewPassword:w.string().oneOf([w.ref("newPassword"),void 0],"New password must match").required("Confirm your new password")}),te=()=>{const{t:s}=i.useTranslation(),{changePassword:u,goBack:m,handleRedirectForgotPassword:n}=ae();return e.jsxs("div",{className:_["change-password-container"],children:[e.jsx("div",{className:_["change-password-container__title"],children:s("change_password")}),e.jsx(D.Formik,{initialValues:{oldPassword:"",newPassword:"",confirmedNewPassword:"",showOldPassword:!1,showNewPassword:!1,showConfirmNewPassword:!1},enableReinitialize:!0,onSubmit:f=>{u(f)},validateOnChange:!1,validateOnBlur:!1,validationSchema:ne,children:f=>{const{values:t,setFieldValue:o,handleSubmit:j,errors:c,touched:p}=f,g=Object.keys(c);return g.length&&document.querySelector(`input[name=${g[0]}]`)?.scrollIntoView({behavior:"smooth",block:"center"}),e.jsxs("div",{className:_["change-password-container__form"],children:[e.jsxs("div",{className:`${_["change-password-container__form--field"]}`,children:[e.jsx("p",{children:s("old_password")}),e.jsx(d.FormControl,{variant:"outlined",className:`${_["input-field"]}`,children:e.jsx(d.OutlinedInput,{type:t.showOldPassword?"text":"password",value:t?.oldPassword,onChange:a=>o("oldPassword",a.target.value.trim()),endAdornment:e.jsx(d.InputAdornment,{position:"end",children:e.jsx(I.IconButton,{"aria-label":"toggle password visibility",onClick:()=>o("showOldPassword",!t.showOldPassword),onMouseDown:a=>a.preventDefault(),children:t.showOldPassword?e.jsx(S.Visibility,{color:"primary"}):e.jsx(d.VisibilityOff,{color:"primary"})})})})}),c.oldPassword&&p.oldPassword&&e.jsx("div",{className:`${_["input-error"]}`,children:c.oldPassword}),e.jsx("button",{type:"button",className:`${_["change-password-container__form--forgot-password"]}`,onClick:n,children:`${s("forgot_password")}?`})]}),e.jsxs("div",{className:`${_["change-password-container__form--field"]}`,children:[e.jsx("p",{children:s("new_password")}),e.jsx(d.FormControl,{variant:"outlined",className:`${_["input-field"]}`,children:e.jsx(d.OutlinedInput,{type:t.showNewPassword?"text":"password",value:t?.newPassword,onChange:a=>o("newPassword",a.target.value.trim()),endAdornment:e.jsx(d.InputAdornment,{position:"end",children:e.jsx(I.IconButton,{"aria-label":"toggle password visibility",onClick:()=>o("showNewPassword",!t.showNewPassword),onMouseDown:a=>a.preventDefault(),children:t.showNewPassword?e.jsx(S.Visibility,{color:"primary"}):e.jsx(d.VisibilityOff,{color:"primary"})})})})}),c.newPassword&&p.newPassword&&e.jsx("div",{className:`${_["input-error"]}`,children:c.newPassword}),e.jsxs("div",{className:`${_["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:`${_["change-password-container__form--field"]}`,children:[e.jsx("p",{children:s("confirm_new_password")}),e.jsx(d.FormControl,{variant:"outlined",className:`${_["input-field"]}`,children:e.jsx(d.OutlinedInput,{type:t.showConfirmNewPassword?"text":"password",value:t?.confirmedNewPassword,onChange:a=>o("confirmedNewPassword",a.target.value.trim()),endAdornment:e.jsx(d.InputAdornment,{position:"end",children:e.jsx(I.IconButton,{"aria-label":"toggle password visibility",onClick:()=>o("showConfirmNewPassword",!t.showConfirmNewPassword),onMouseDown:a=>a.preventDefault(),children:t.showConfirmNewPassword?e.jsx(S.Visibility,{color:"primary"}):e.jsx(d.VisibilityOff,{color:"primary"})})})})}),c.confirmedNewPassword&&p.confirmedNewPassword&&e.jsx("div",{className:`${_["input-error"]}`,children:c.confirmedNewPassword})]}),e.jsxs("div",{className:_["change-password-container__form--btn-group"],children:[e.jsx("button",{type:"button",className:_["btn-cancel"],onClick:()=>{m()},children:s("cancel")}),e.jsxs("button",{type:"button",className:_["btn-save"],onClick:()=>j(),children:[e.jsx(T.DoneCheckInIcon,{color:"#fff"}),s("save_new_password")]})]})]})}})]})},ie="/images/image-default.png",se=()=>{const{dataProfile:s,activeTab:u,setActiveTab:m,handleImageChange:n,handleDeleteAvatar:f,imagePreviewUrl:t,currentUser:o,updateProfile:j,goBack:c,signout:p}=W(),g=k.find(l=>!l.isControl),a=[{value:b.Info,component:e.jsx(re,{dataProfile:s,updateProfile:j,goBack:c})},{value:b.ChangePassword,component:e.jsx(te,{})}];return e.jsxs("div",{className:r["user-profile-container-admin"],children:[e.jsxs("div",{className:r["user-profile-container-admin__left"],children:[e.jsxs("div",{className:r["user-profile-container-admin__left--information"],children:[e.jsxs("div",{className:r["image-user-container"],children:[e.jsx(O.Input,{className:"d-none",type:"file",id:"uploadFile",onChange:n,accept:"image/*"}),e.jsx("img",{src:t||i.getStaticFileUrl(ie),alt:"user-avatar",className:`${r["image-user-container__image"]}`}),e.jsx(O.Label,{htmlFor:"uploadFile",role:"button",tabIndex:0,children:e.jsx("div",{className:r["image-user-container__edit-btn"],children:e.jsx("img",{src:i.getStaticFileUrl("/images/user/Edit.svg"),alt:"edit-avatar"})})}),e.jsx("button",{type:"button",onClick:()=>f(),className:r["image-user-container__delete-btn"],children:e.jsx("img",{src:i.getStaticFileUrl("/images/user/DeleteAvatar.svg"),alt:"delete-avatar"})})]}),e.jsxs("div",{className:r["name-role-container"],children:[e.jsx("div",{className:r.name,children:`${s?.fullName||""}`}),e.jsx("div",{className:r.role,children:(o?.roles||[]).map(l=>l==="SecondaryTeacher"?"Support Teacher":l).join(", ")})]})]}),e.jsx("div",{className:r["user-profile-container-admin__left--btn-control"],children:k.filter(l=>l.isControl).map(l=>e.jsxs("button",{type:"button",className:`${r.item} ${u===l.value?r["item-active"]:""}`,onClick:()=>m(l.value),children:[e.jsx("img",{src:i.getStaticFileUrl(l.icon),alt:l.icon}),l.label]},l.value))}),e.jsx("div",{className:r["user-profile-container-admin__left--sign-out"],children:g&&e.jsxs("button",{type:"button",className:r.item,onClick:p,children:[e.jsx("img",{src:i.getStaticFileUrl(g.icon),alt:g.icon}),g.label]})})]}),e.jsx("div",{className:r["user-profile-container-admin__right"],children:a.find(l=>l.value===u)?.component})]})};exports.default=se;
|