mario-core 2.0.97-release → 2.0.98-release
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/Dashboard-D2zLzwFR.mjs +206 -0
- package/dist/Dashboard-dOwpd3sn.js +1 -0
- package/dist/EmailTemplateDetail-D07dUCZL.js +1 -0
- package/dist/EmailTemplateDetail-uNlh3Otz.mjs +443 -0
- package/dist/EmailTemplateList-B5ee4Byb.js +1 -0
- package/dist/EmailTemplateList-EZ_sAp6W.mjs +170 -0
- package/dist/GalleryList-CdyApn-m.mjs +329 -0
- package/dist/GalleryList-DFuoYp_Q.js +1 -0
- package/dist/Login-8c69l-hn.js +1 -0
- package/dist/Login-MzPc2sA6.mjs +1684 -0
- package/dist/NotificationList-BP871ggG.mjs +3982 -0
- package/dist/NotificationList-CzX65qMV.js +2 -0
- package/dist/SkillList-C-aJeufd.mjs +386 -0
- package/dist/SkillList-hMvqDcsQ.js +1 -0
- package/dist/TeacherSelector-CV9c0Cn8.js +1 -0
- package/dist/TeacherSelector-XuYxdZgr.mjs +30 -0
- package/dist/TheContent-BfT4R2Gc.mjs +38 -0
- package/dist/TheContent-BicDxizL.js +1 -0
- package/dist/UserContainer-DR6lGYNl.js +5 -0
- package/dist/UserContainer-Ip-sYnrv.mjs +2902 -0
- package/dist/UserDetail-iw6l5L3a.mjs +903 -0
- package/dist/UserDetail-uR6dMDOB.js +1 -0
- package/dist/UserList-DLC9FDWG.mjs +1252 -0
- package/dist/UserList-DUiZTiTR.js +7 -0
- package/dist/constants-DUelcmx7.js +1 -0
- package/dist/constants-QjFnVl1d.mjs +286 -0
- package/dist/index--POWjYN0.mjs +19073 -0
- package/dist/index-KWXe_Hjz.js +15 -0
- package/dist/index.js +1 -1
- package/dist/index.modern.js +1 -1
- package/dist/mailCategoryService-B9Yboyna.mjs +11 -0
- package/dist/mailCategoryService-DAw3X_PE.js +1 -0
- package/dist/services/userService.d.ts +1 -0
- package/dist/userService-DEwtByu1.js +1 -0
- package/dist/userService-DxucAe6U.mjs +56 -0
- package/package.json +1 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),d=require("react"),K=require("react-router-dom"),t=require("reactstrap"),W=require("formik"),ee=require("react-datepicker"),X=require("date-fns"),w=require("./userService-DEwtByu1.js"),J=require("react-redux"),se=require("react-i18next"),s=require("./index-KWXe_Hjz.js"),te=require("yup"),ae=require("./TeacherSelector-CV9c0Cn8.js"),Y=require("./constants-DUelcmx7.js");function re(i){const n=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(i){for(const o in i)if(o!=="default"){const x=Object.getOwnPropertyDescriptor(i,o);Object.defineProperty(n,o,x.get?x:{enumerable:!0,get:()=>i[o]})}}return n.default=i,Object.freeze(n)}const N=re(te),oe={id:"",firstName:"",lastName:"",email:"",dateOfBirth:"",roles:[],isActive:!0,profileImageFileName:"",teacherUserId:[]},Q="/admin/users/user-list",ne="User detail",le=i=>{const n=J.useDispatch(),o=K.useNavigate(),[x,D]=d.useState(oe),[y,j]=d.useState(!1),[T,F]=d.useState([]),[S,g]=d.useState(null),[k,v]=d.useState(!1),[b,I]=d.useState({isHasAssistantData:!1,isHasCounselorData:!1,isHasEduTeacherData:!1,isHasSecondaryTeacherData:!1,isHasTeacherData:!1}),B=async()=>{localStorage.setItem(window.location.href,"true"),v(!0)},[A,h]=d.useState([]),u=()=>{j(!y)};d.useEffect(()=>{document.title=ne,v(!1),localStorage.getItem(window.location.href)&&localStorage.removeItem(window.location.href)},[]),d.useEffect(()=>{i&&(p(),O()),!i&&U()},[i]);const p=d.useCallback(async()=>{n(s.setLoading(!0));try{const a=await w.userRoleHasData(i);I(a.data)}catch(a){n(s.setAlert({type:"danger",message:a.response?.data?.title||a.message}))}n(s.setLoading(!1))},[i]),O=d.useCallback(async()=>{n(s.setLoading(!0));try{const a=await w.getById(i);D({...a.data,dateOfBirth:X.format(new Date(a.data.dateOfBirth),s.DATE_FORMAT),roles:a.data.roles.map(c=>c!="EduTeacher"?c:s.ROLES.EDUTEACHER)}),h(a?.data?.roles??[]),document.title=a.data?.fullName}catch(a){n(s.setAlert({type:"danger",message:a.response?.data?.title||a.message}))}n(s.setLoading(!1))},[i]),U=async()=>{try{const a=await w.getTeachers({sortBy:"Email"});a.data&&F(a.data.map?.(c=>({label:c.email,value:c.id}))||[])}catch(a){n(s.setAlert({type:"danger",message:a.response?.data?.title||a.message}))}},P=d.useCallback(a=>{o(a&&typeof a=="string"?Q+`?query=${a}`:Q)},[]),_=d.useCallback(async a=>{n(s.setLoading(!0));try{if(S){const C=new FormData,{name:E}=S;C.append("file",S,E);const $=(await s.systemProfileUpload(C))?.data?.key;a.profileImageFileName=$}const c=i?w.update:w.create;!i&&delete a.id,a.dateOfBirth===""&&delete a.dateOfBirth;const m=await c(a);m&&w.getById(m.data.id).then(C=>{P(C.data.fullName)}),i||alert("Password of "+m.data.email+` is "${m.data.password}"`),m.data.id&&await w.changeGradeOfStudents(m.data.id,a.gradeLevel),n(s.setAlert({type:"success",message:`${i?"Update":"Create"} user successfully`}))}catch(c){n(s.setAlert({type:"danger",message:c.response?.data?.title||c.message}))}n(s.setLoading(!1))},[i,S]),R=a=>["Student","Parent","EduTeacher"].includes(a),M=async a=>{n(s.setLoading(!0));try{await w.changePassword(a),n(s.setAlert({type:"success",message:"Change password successfully"}))}catch(c){n(s.setAlert({type:"danger",message:c.response?.data?.title||c.message}))}n(s.setLoading(!1))},f=d.useCallback(async a=>{n(s.setLoading(!0));try{await w.forgotChangePassword(a),n(s.setAlert({type:"success",message:"Send forgot password link successfully"}))}catch(c){n(s.setAlert({type:"danger",message:c.response?.data?.title||c.message||"Error occured"}))}n(s.setLoading(!1))},[]),l=d.useCallback(async a=>{n(s.setLoading(!0));try{const c={userId:a},m=await w.resetPasswordForAdmin(c);if(m.data){const C=`${x.firstName} ${x.lastName}`;alert(`Password of ${C} is ${m.data}`),n(s.setAlert({type:"success",message:"Update user password successfully"}))}}catch(c){n(s.setAlert({type:"danger",message:c.response?.data?.title||c.message}))}n(s.setLoading(!1))},[x]);return{userDetail:x,backToList:P,confirmData:_,file:S,setFile:g,edited:k,setEdited:v,setEditedTrue:B,confirmChangePassword:M,forgotPasswordRequest:f,currentRoles:A,handleDisableRoles:R,handleResetPassword:l,teacherOptions:T,openModel:y,handleToggleModel:u,userHasData:b}},ie=N.object({firstName:N.string().required("First name is required"),lastName:N.string().required("Last name is required"),email:N.string().email("Email is invalid").required("Email is required"),roles:N.array().of(N.string()).min(1,"Role is required")}),ce=N.object({oldPassword:N.string().required("Current password is required"),newPassword:N.string().required("New password is required"),confirmedNewPassword:N.string().required("Confirm password is required")}),de={currentPage:1,pageSize:100},ue=(i,n)=>{const[o,x]=d.useState([]),[D,y]=d.useState(!1),[j,T]=d.useState(de),[F,S]=d.useState(),g=J.useDispatch(),k=d.useCallback(async()=>{y(!0);try{const u=(await w.getRosterUsersApi(j)).data?.items||[];x(b(u))}catch{g(s.setAlert({type:"error",message:"Cannot get roster users"}))}y(!1)},[JSON.stringify(j)]),v=d.useCallback(async()=>{if(!n)return;const h=o.find(u=>u.value===n);if(h){S(h);return}y(!0);try{const p=(await w.getRosterUserBySourcedIdApi(n)).data;S({label:I(p),value:p.sourcedId})}catch(u){console.log("err:",u)}y(!1)},[n]),b=h=>h.map(u=>({label:I(u),value:u.sourcedId})),I=h=>{const u=[],{givenName:p,middleName:O,familyName:U,email:P,role:_}=h,R=[];return p&&R.push(p),O&&R.push(O),U&&R.push(U),R.length&&u.push(R.join(" ")),P&&u.push(P),`${u.join(" - ")}${_?` (${_})`:""}`},B=h=>{T(u=>({...u,searchString:h}))},A=d.useCallback(h=>{T({...j,...h})},[JSON.stringify(j)]);return d.useEffect(()=>{j.roles?.length&&k()},[JSON.stringify(j)]),d.useEffect(()=>{A({roles:i})},[JSON.stringify(i)]),d.useEffect(()=>{v()},[n]),{users:o,isLoading:D,user:F,handleInputChange:B}},me=({value:i,roles:n,onChange:o})=>{const{users:x,isLoading:D,user:y,handleInputChange:j}=ue(n,i);return e.jsx(s.CustomSelector,{options:x,value:y,placeholder:"Select user",onChange:o,isLoading:D,onInputChange:j})},he="create_user",pe="edit_user",ge="change_password",fe=()=>{const{id:i}=K.useParams(),n=J.useSelector(f=>f.common.user),{t:o}=se.useTranslation(),{userDetail:x,backToList:D,confirmData:y,file:j,setFile:T,edited:F,setEdited:S,setEditedTrue:g,confirmChangePassword:k,forgotPasswordRequest:v,currentRoles:b,handleDisableRoles:I,handleResetPassword:B,teacherOptions:A,openModel:h,handleToggleModel:u,userHasData:p}=le(i),O={oldPassword:"",newPassword:"",confirmedNewPassword:""},U=o(i?`${pe}`:`${he}`),P=o(i?"update":"create"),_=()=>{var f=window.location.origin+"/api/ExportDataUser/"+i;window.open(f)},R=async f=>{var l={email:f};v(l)},M=()=>{if(!i)return;confirm("You want to reset this user's password")==!0&&B(i)};return e.jsx(W.Formik,{initialValues:x,enableReinitialize:!0,validationSchema:ie,onSubmit:f=>{y({...f,roles:f.roles.map(l=>l!=s.ROLES.EDUTEACHER?l:"EduTeacher")}),S(!1),localStorage.getItem(window.location.href)&&localStorage.removeItem(window.location.href)},children:f=>{const{values:l,touched:a,errors:c,setFieldValue:m,handleChange:C,handleBlur:E,handleSubmit:G}=f,$=d.useCallback(r=>{if(l.roles.includes(r)){m("roles",l.roles.filter(L=>L!==r));return}if([s.ROLES.STUDENT,s.ROLES.PARENT].includes(r)){m("roles",[r]);return}if(l.roles.includes(s.ROLES.STUDENT)&&s.ROLES.STUDENT!=r){m("roles",[r]);return}m("roles",[...l.roles,r])},[l.roles]);return e.jsxs("div",{className:`animated fadeIn detail-buttons-padding ${s.screenWidth<=767?s.styles["p-0-12"]:""}`,children:[e.jsx(s.QuitPrompt,{when:F}),e.jsx("h5",{className:"mb-2",children:U}),e.jsxs(t.Row,{className:"pt-2",children:[e.jsxs(t.Col,{md:8,children:[e.jsxs(t.Row,{children:[e.jsx(t.Col,{md:6,children:e.jsxs(t.FormGroup,{children:[e.jsx(s.RequiredLabel,{text:o("first_name"),className:"text-capitalize"}),e.jsx(t.Input,{name:"firstName",value:l.firstName,onChange:r=>{C(r),g()},onBlur:E("subject"),placeholder:o("first_name"),className:s.styles["input-name"]}),a.firstName&&c.firstName&&e.jsx(s.ErrorHandler,{text:c.firstName})]})}),e.jsx(t.Col,{md:6,children:e.jsxs(t.FormGroup,{children:[e.jsx(t.Label,{children:o("date_of_birth")}),e.jsx("div",{children:e.jsx(ee,{value:l.dateOfBirth,todayButton:"Today",peekNextMonth:!0,showMonthDropdown:!0,showYearDropdown:!0,dropdownMode:"select",selected:l.dateOfBirth?w.toDate(new Date(l.dateOfBirth)):null,onChange:r=>{f.setFieldValue("dateOfBirth",X.format(r,s.DATE_FORMAT)),g()},placeholderText:o("date_of_birth"),customInput:e.jsx(t.Input,{type:"text",style:{width:"maxContent"},placeholder:o("date_of_birth")})})})]})})]}),e.jsxs(t.Row,{children:[e.jsx(t.Col,{md:6,children:e.jsxs(t.FormGroup,{children:[e.jsx(s.RequiredLabel,{text:o("last_name"),className:"text-capitalize"}),e.jsx(t.Input,{name:"lastName",value:l.lastName,onChange:r=>{C(r),g()},onBlur:E("lastName"),placeholder:o("last_name"),className:s.styles["input-name"]}),a.lastName&&c.lastName&&e.jsx(s.ErrorHandler,{text:c.lastName})]})}),e.jsx(t.Col,{md:6,children:e.jsxs(t.FormGroup,{children:[e.jsx(s.RequiredLabel,{text:o("roles")}),e.jsx(t.Row,{children:e.jsx(t.Col,{md:12,className:"d-flex flex-wrap align-items-center",children:s.USER_ROLES.map(r=>e.jsx("div",{className:"mr-3",children:e.jsx(t.Input,{type:"checkbox",id:`role-checkbox-${r}`,label:r==="SecondaryTeacher"?"SupportTeacher":`${r}`,checked:l.roles.includes(r),onChange:()=>{i&&(p.isHasTeacherData&&r==="Teacher"||p.isHasAssistantData&&r==="Assistant"||p.isHasCounselorData&&r==="Counselor"||p.isHasSecondaryTeacherData&&r==="SecondaryTeacher"||r=="Student"&&(p.isHasAssistantData||p.isHasCounselorData||p.isHasSecondaryTeacherData||p.isHasTeacherData))?alert("Please switch data before removing the role"):($(r),g())},disabled:b.includes("Parent")||b.includes("Student")&&i?b.concat(["Student","Parent"]).includes(r)||b.every(I):["Parent"].includes(r)})},r))})}),a.roles&&c.roles&&e.jsx(s.ErrorHandler,{text:c.roles})]})})]}),e.jsxs(t.Row,{children:[e.jsx(t.Col,{md:6,children:e.jsxs(t.FormGroup,{children:[e.jsx(s.RequiredLabel,{text:o("email")}),e.jsx(t.Input,{name:"email",value:l.email,onChange:r=>{C(r),g()},onBlur:E("email"),placeholder:o("email")}),a.email&&c.email&&e.jsx(s.ErrorHandler,{text:c.email})]})}),e.jsx(t.Col,{md:6,children:e.jsxs(t.FormGroup,{children:[e.jsx(s.RequiredLabel,{text:o("status")}),e.jsxs(t.Row,{children:[e.jsx(t.Col,{md:3,children:e.jsx(t.Input,{id:"role-checkbox-active",type:"radio",name:"active",label:o("active"),checked:!!l&&!!l.isActive,onChange:()=>{m("isActive",!0),g()}})}),e.jsx(t.Col,{md:3,children:e.jsx(t.Input,{id:"role-checkbox-inActive",type:"radio",name:"active",label:o("inactive"),checked:!!l&&!l.isActive,onChange:()=>m("isActive",!1)})})]})]})})]}),l.roles.includes(s.ROLES.STUDENT)&&e.jsx(t.Row,{children:e.jsx(t.Col,{md:6,children:e.jsxs(t.FormGroup,{children:[e.jsx(t.Label,{children:"Grade Level"}),e.jsx(s.CustomSelector,{options:Y.gradeOptions,value:Y.gradeOptions.find(r=>r.value==l.gradeLevel),placeholder:"Grade Level",onChange:r=>{m("gradeLevel",r.value)}})]})})}),!!i&&e.jsxs(t.Row,{children:[e.jsx(t.Col,{md:6,children:(!l.roles.includes("Admin")||l.roles.length>1)&&!!l.roles.length&&e.jsxs(t.FormGroup,{children:[e.jsx(t.Label,{children:"Map from Roster"}),e.jsx(me,{roles:l.roles,value:l.sourcedId,onChange:r=>m("sourcedId",r.value)})]})}),e.jsxs(t.Col,{md:6,children:[e.jsx(t.Button,{color:"primary",className:"w-100",onClick:()=>{R(l.email||"")},children:o("send_forgot_password_link")}),e.jsx(t.Button,{color:"primary",className:"w-100 mt-3",onClick:()=>M(),children:o("reset_password")}),e.jsx(t.Button,{color:"success",className:"w-100 mt-3",onClick:()=>{_()},children:o("download_user_data")})]})]})]}),e.jsx(t.Col,{md:4,children:e.jsx(t.Row,{children:e.jsxs(t.Col,{md:8,children:[e.jsx(s.UploadFileButton,{setFile:T,fileName:l.profileImageFileName,onAddImage:g,canDelete:!0,onDelete:()=>{T(null),m("profileImageFileName",""),g()}}),!j&&!l.profileImageFileName&&e.jsx("img",{src:s.DEFAULT_IMAGE_URL,style:{maxWidth:"100%"}})]})})})]}),n.id===i?e.jsxs("div",{children:[e.jsx("h5",{className:"mt-3",children:o(`${ge}`)}),e.jsx(W.Formik,{initialValues:O,enableReinitialize:!0,validationSchema:ce,onSubmit:r=>{k(r)},children:r=>{const{values:L,touched:z,errors:q,handleChange:V,handleSubmit:Z}=r;return e.jsxs(t.Row,{className:"pt-2 pb-5",children:[e.jsx(t.Col,{md:7,children:e.jsxs(t.FormGroup,{children:[e.jsx(s.RequiredLabel,{text:o("current_password"),className:"text-capitalize"}),e.jsx(t.Input,{name:"oldPassword",type:"password",value:L.oldPassword,onChange:H=>{V(H),g()},onBlur:E("subject"),placeholder:o("current_password"),className:s.styles["input-name"]}),z.oldPassword&&q.oldPassword&&e.jsx(s.ErrorHandler,{text:q.oldPassword})]})}),e.jsx(t.Col,{md:7,children:e.jsxs(t.FormGroup,{children:[e.jsx(s.RequiredLabel,{text:o("new_password"),className:"text-capitalize"}),e.jsx(t.Input,{name:"newPassword",type:"password",value:L.newPassword,onChange:H=>{V(H),g()},onBlur:E("subject"),placeholder:o("new_password"),className:s.styles["input-name"]}),z.newPassword&&q.newPassword&&e.jsx(s.ErrorHandler,{text:q.newPassword})]})}),e.jsx(t.Col,{md:7,children:e.jsxs(t.FormGroup,{children:[e.jsx(s.RequiredLabel,{text:o("confirm_password"),className:"text-capitalize"}),e.jsx(t.Input,{name:"confirmedNewPassword",type:"password",value:L.confirmedNewPassword,onChange:H=>{V(H),g()},onBlur:E("subject"),placeholder:o("confirm_password"),className:s.styles["input-name"]}),z.confirmedNewPassword&&q.confirmedNewPassword&&e.jsx(s.ErrorHandler,{text:q.confirmedNewPassword})]})}),e.jsx(t.Col,{md:12,children:e.jsx(t.Button,{color:"primary",size:"sm",className:"px-4 pl-1 mr-2 ml-3",onClick:()=>Z(),children:o("save")})})]})}})]}):null,e.jsx(s.DetailActionButtons,{confirmText:P,onConfirm:l.roles.includes(s.ROLES.STUDENT)&&!i?u:G,onCancel:D}),e.jsxs(t.Modal,{centered:!0,isOpen:h,toggle:()=>u(),children:[e.jsx(t.ModalHeader,{children:"Assign Teacher"}),e.jsx(t.ModalBody,{children:e.jsx(ae.TeacherSelector,{isMulti:!0,value:A.filter(r=>l.teacherUserId?.includes(r.value))||null,options:A,onChange:r=>m("teacherUserId",r.map(L=>L.value)),placeholder:o("select_teacher"),className:"flex-grow-1 mb-3"})}),e.jsxs(t.ModalFooter,{className:"text-right",children:[e.jsx(t.Button,{onClick:()=>u(),children:"Cancel"}),e.jsx(t.Button,{disabled:!l.teacherUserId,color:"primary",onClick:()=>{G()},children:"Assign"})]})]})]})}})};exports.default=fe;
|