mario-core 2.0.102-release → 2.0.103-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-B2WY8-IU.js +1 -0
- package/dist/Dashboard-BzKx6Ox_.mjs +206 -0
- package/dist/Dashboard-DJS7P679.mjs +206 -0
- package/dist/Dashboard-NC2RHYE3.js +1 -0
- package/dist/EmailTemplateDetail-22mli8ZO.js +1 -0
- package/dist/EmailTemplateDetail-CfqeSysW.js +1 -0
- package/dist/EmailTemplateDetail-D5H-KPFi.mjs +443 -0
- package/dist/EmailTemplateDetail-DnEe1dJY.mjs +443 -0
- package/dist/EmailTemplateList-BBgctzKn.mjs +170 -0
- package/dist/EmailTemplateList-BSETyjvK.js +1 -0
- package/dist/EmailTemplateList-CEfrVodv.mjs +170 -0
- package/dist/EmailTemplateList-CpfPUX5H.js +1 -0
- package/dist/GalleryList-BKH6TE8o.js +1 -0
- package/dist/GalleryList-D1-lprY3.mjs +329 -0
- package/dist/GalleryList-D6Npg6OD.mjs +329 -0
- package/dist/GalleryList-DZDBNr1J.js +1 -0
- package/dist/Login-07zPaPX9.js +1 -0
- package/dist/Login-CSb85ENW.mjs +1697 -0
- package/dist/Login-C_elLcnh.mjs +1688 -0
- package/dist/Login-t8Cp9sZB.js +1 -0
- package/dist/NotificationList-D1ay6Hyf.mjs +3982 -0
- package/dist/NotificationList-DHjB1hHV.js +2 -0
- package/dist/NotificationList-DlWtyPB-.mjs +3982 -0
- package/dist/NotificationList-Dr8Yrfl7.js +2 -0
- package/dist/SkillList-CjP3DHVV.mjs +386 -0
- package/dist/SkillList-DED-BKhK.js +1 -0
- package/dist/SkillList-EMox2GtU.js +1 -0
- package/dist/SkillList-a-PCBXTS.mjs +386 -0
- package/dist/TeacherSelector-CT_LK5ps.js +1 -0
- package/dist/TeacherSelector-CYN1RV9H.js +1 -0
- package/dist/TeacherSelector-Ckdz4LDA.mjs +30 -0
- package/dist/TeacherSelector-TtFRSN6T.mjs +30 -0
- package/dist/TheContent-BLL5TnF0.js +1 -0
- package/dist/TheContent-C1z93b1T.mjs +38 -0
- package/dist/TheContent-CV2yUmwY.js +1 -0
- package/dist/TheContent-ClceIaDH.mjs +38 -0
- package/dist/UserContainer-BwVN8uDh.mjs +2902 -0
- package/dist/UserContainer-DKBxc6bM.js +5 -0
- package/dist/UserContainer-Dgajsjc2.js +5 -0
- package/dist/UserContainer-W5RhNyuY.mjs +2902 -0
- package/dist/UserDetail-B1OEfUkB.mjs +903 -0
- package/dist/UserDetail-CcAyPDXB.mjs +903 -0
- package/dist/UserDetail-D_54wIZ1.js +1 -0
- package/dist/UserDetail-EIVg7R4V.js +1 -0
- package/dist/UserList-BHBPOboi.js +7 -0
- package/dist/UserList-CuML6EN2.mjs +1261 -0
- package/dist/UserList-D7DcyFHI.js +7 -0
- package/dist/UserList-DPS62SYL.mjs +1254 -0
- package/dist/constants-CAl8i9EQ.mjs +286 -0
- package/dist/constants-CQviSc2u.js +1 -0
- package/dist/constants-DIXj0L_y.js +1 -0
- package/dist/constants-Jqu1Wphx.mjs +286 -0
- package/dist/index-7hA60HfM.mjs +19133 -0
- package/dist/index-9XtI-PeV.js +15 -0
- package/dist/index-C6cqi7Br.js +15 -0
- package/dist/index-DplP6JK1.mjs +19133 -0
- package/dist/index.js +1 -1
- package/dist/index.modern.js +1 -1
- package/dist/mailCategoryService-Bhcruih6.js +1 -0
- package/dist/mailCategoryService-CJQb-5oo.mjs +11 -0
- package/dist/mailCategoryService-CQdNPG8e.js +1 -0
- package/dist/mailCategoryService-D_DFc1LB.mjs +11 -0
- package/dist/userService-1_ugW9AK.js +1 -0
- package/dist/userService-C4VF2Wck.mjs +56 -0
- package/dist/userService-De8Jm8I4.js +1 -0
- package/dist/userService-OWU32PxA.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-De8Jm8I4.js"),J=require("react-redux"),se=require("react-i18next"),s=require("./index-9XtI-PeV.js"),te=require("yup"),ae=require("./TeacherSelector-CT_LK5ps.js"),Y=require("./constants-CQviSc2u.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;
|
|
@@ -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-1_ugW9AK.js"),J=require("react-redux"),se=require("react-i18next"),s=require("./index-C6cqi7Br.js"),te=require("yup"),ae=require("./TeacherSelector-CYN1RV9H.js"),Y=require("./constants-DIXj0L_y.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;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";const t=require("react/jsx-runtime"),N=require("reactstrap"),z=require("./userService-De8Jm8I4.js"),Y=require("react-i18next"),u=require("react"),H=require("react-redux"),ie=require("react-router-dom"),s=require("./index-9XtI-PeV.js"),P=require("./constants-CQviSc2u.js"),fe=require("./types-CTFcZUFS.js"),ae=require("date-fns"),re=require("papaparse");function ye(e,n){z.requiredArgs(2,arguments);var m=z.toDate(e),l=z.toDate(n);return m.getFullYear()-l.getFullYear()}const Se=()=>{const[e,n]=u.useState(P.DEFAULT_FILTER);return{filters:e,setFilters:n,changeFilters:l=>{const v={...e,...l};v.searchString&&l.searchString&&l.searchString!=e.searchString&&(v.currentPage=1),n(v)}}},xe="/admin/user",ve="/admin/create-user",Ce="User list",W="/home",be="/home",Ee="/admin/home",je="/parent",Ne="/admin/schools",_e="/list-student",Ae=()=>{const e=ie.useNavigate(),m=new URLSearchParams(location.search).get("query"),l=H.useSelector(a=>a.users.userList),v=H.useSelector(a=>a.users.totalItems),{filters:S,changeFilters:c}=Se(),x=m||"",[f,E]=u.useState([]),i=window.location.host.includes("-district"),o=H.useDispatch(),{t:p}=Y.useTranslation(),U=a=>{const y=f.find(g=>g==a);E(y?f.filter(g=>g!=a):f.concat([a]))},A=u.useMemo(()=>(l||[]).length>0&&(l||[]).every(a=>f.includes(a.id)),[l,f]),I=u.useCallback(()=>{if(A){const y=new Set((l||[]).map(g=>g.id));E(g=>g.filter(r=>!y.has(r)));return}const a=(l||[]).map(y=>y.id).filter(y=>!f.includes(y));E(y=>[...y,...a])},[l,A,f]),j=u.useCallback(async()=>{if(S.searchBy!==void 0&&S.searchByStrings!==void 0&&S.searchByStrings.length===0){o(s.setUserList({userList:[],totalItems:0}));return}o(s.setLoading(!0));try{const a=await z.getRosterUser(S),{items:y,totalItems:g}=a.data;for(const r of y)r.roles=r.roles.map(h=>h!=s.ROLES.EDUTEACHER?h:"EduTeacher"),r.msRoles&&(r.msRoles=r.msRoles.map(h=>h!=s.ROLES.EDUTEACHER?h:"EduTeacher")),r.esRoles&&(r.esRoles=r.esRoles.map(h=>h!=s.ROLES.EDUTEACHER?h:"EduTeacher"));o(s.setUserList({userList:y,totalItems:g}))}catch(a){o(s.setAlert({type:"danger",message:a.response?.data?.title||a.message}))}o(s.setLoading(!1))},[o,S]),C=async()=>{o(s.setLoading(!0));try{const y=(await z.triggerAllRosterSyncApi()).data?.message||p("sync_roster_running_in_background","Roster synchronization is currently running in the background. Please wait a few moments before refreshing the page.");o(s.setModal({isOpen:!0,type:"success",message:y}))}catch(a){o(s.setModal({isOpen:!0,type:"danger",message:a.response?.data?.message||a.response?.data?.title||a.message}))}o(s.setLoading(!1))},b=a=>{if(!a)return"";const y=[],{sourcedId:g,rosterUser:r}=a;if(g&&r&&y.push(g),r){const{givenName:h,middleName:O,familyName:T,email:$}=r,F=[];T&&F.push(T),O&&F.push(O),h&&F.push(h),y.push(F.join(" ")||""),y.push($||"")}return y.join(" / ")};u.useEffect(()=>{document.title=Ce},[]),u.useEffect(()=>{c({...S,searchString:x})},[x]),u.useEffect(()=>{j()},[JSON.stringify(S)]);const R=u.useCallback(a=>{o(s.setModal({isOpen:!0,type:"warning",message:p("do_you_want_to_remove_this_user"),onConfirm:async()=>{o(s.setLoading(!0));try{await z.remove(a),o(s.setAlert({type:"success",message:"Remove user successfully"})),S.currentPage!==1?c({currentPage:1}):j()}catch(y){o(s.setAlert({type:"danger",message:y.response?.data?.title||y.message}))}o(s.setLoading(!1))}}))},[JSON.stringify(S)]),D=[{role:"Admin",path:Ee},{role:"Teacher",path:W},{role:"Assistant",path:W},{role:"Counselor",path:W},{role:"SecondaryTeacher",path:W},{role:"EduTeacher",path:_e},{role:"Student",path:be},{role:"Parent",path:je}],B=a=>{const y=sessionStorage.getItem(s.IS_USER_SESSION_BROWSER),g=a.data?.token;let r=a.data.msRoles||[],h=a.data.esRoles||[];const O=a.data.roles||a.data.userRoles||[],T=(a.data.appType||"").toUpperCase();r.length===0&&h.length===0&&O.length>0&&(T.includes("ES")&&!T.includes("MS")?h=O:T.includes("MS")&&!T.includes("ES")?r=O:(r=O,h=O));let $="MS",F="/home",k=!1;for(const{role:q,path:J}of D){const G=r.includes(q),M=h.includes(q);if(!(!G&&!M)){$=G?"MS":"ES",F=J,k=!0;break}}k||($=r.length>0?"MS":h.length>0?"ES":"MS");const _=$==="ES"?h:r;y?sessionStorage.setItem(s.ACCESS_TOKEN,g):localStorage.setItem(s.ACCESS_TOKEN,g);let w="";_.includes("Admin")?w="Admin":_.includes("Teacher")?w=_.includes("Assistant")?"Teacher,Assistant":"Teacher":_.includes("Assistant")?w="Assistant":_.includes("Counselor")?w="Counselor":_.includes("SecondaryTeacher")?w="SecondaryTeacher":_.includes("EduTeacher")?w="EduTeacher":_.includes("Student")?w="Student":_.includes("Parent")?w="Parent":_.length>0&&(w=_[0]),w&&localStorage.setItem("ROLES",w),localStorage.removeItem(s.NOTIFICATION_ALERT_KEY),i&&(F=Ne);const V=$==="ES"&&!_.includes("Admin")?`/es${F}`:F;window.location.href=V},L=u.useCallback(async a=>{try{const g=(await z.switchAccountUser(a)).data;o(s.setModal({isOpen:!0,type:"warning",message:p("do_you_want_to_impersonate_this_user"),onConfirm:async()=>{o(s.setLoading(!0));try{const r={email:g.email,password:"default",accessToken:g.token,loginType:fe.LoginType.Impersonate},h=await s.logIn(r),O={};for(let T=0;T<localStorage.length;T++){const $=localStorage.key(T);$&&($==="SELECTED_TIER"||$.startsWith("SELECTED_TIER_"))&&(O[$]=localStorage.getItem($)||"")}localStorage.clear(),Object.keys(O).forEach(T=>{localStorage.setItem(T,O[T])}),B(h)}catch(r){s.setAlert({type:"danger",message:r.response?.data?.title||r.message})}o(s.setLoading(!1))}}))}catch(y){o(s.setAlert({type:"danger",message:y.response?.data?.title||y.message}))}},[S]);return{userList:l,totalItems:v,filters:S,queryName:m,fullName:x,getData:j,removeData:R,changeFilters:c,reDirectDetailPage:a=>{const y=a?`${xe}/${a}`:ve;e(y)},switchUser:L,handleSyncRosterUsers:C,rosterUserInfo:b,userIds:f,onSelectAllUser:I,onSelectUser:U,isCheckAll:A}},Re={fontWeight:500},Te={height:38,background:"#316cd9"},Ie=({text:e,onClick:n,className:m=""})=>t.jsxs(N.Button,{onClick:n,color:"primary",style:Te,className:`d-flex align-items-center ${m} gap-2`,children:[t.jsx(s.FaSyncAlt,{}),t.jsx("span",{style:Re,children:e})]});function Le(e){return s.GenIcon({attr:{viewBox:"0 0 24 24"},child:[{tag:"path",attr:{d:"M21 3H5a1 1 0 0 0-1 1v2.59c0 .523.213 1.037.583 1.407L10 13.414V21a1.001 1.001 0 0 0 1.447.895l4-2c.339-.17.553-.516.553-.895v-5.586l5.417-5.417c.37-.37.583-.884.583-1.407V4a1 1 0 0 0-1-1zm-6.707 9.293A.996.996 0 0 0 14 13v5.382l-2 1V13a.996.996 0 0 0-.293-.707L6 6.59V5h14.001l.002 1.583-5.71 5.71z"}}]})(e)}function we(e){return s.GenIcon({attr:{viewBox:"0 0 24 24"},child:[{tag:"path",attr:{d:"M19.023 16.977a35.13 35.13 0 0 1-1.367-1.384c-.372-.378-.596-.653-.596-.653l-2.8-1.337A6.962 6.962 0 0 0 16 9c0-3.859-3.14-7-7-7S2 5.141 2 9s3.14 7 7 7c1.763 0 3.37-.66 4.603-1.739l1.337 2.8s.275.224.653.596c.387.363.896.854 1.384 1.367l1.358 1.392.604.646 2.121-2.121-.646-.604c-.379-.372-.885-.866-1.391-1.36zM9 14c-2.757 0-5-2.243-5-5s2.243-5 5-5 5 2.243 5 5-2.243 5-5 5z"}}]})(e)}function Oe(e){return s.GenIcon({attr:{viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true"},child:[{tag:"path",attr:{fillRule:"evenodd",d:"M3 3a1 1 0 011-1h12a1 1 0 011 1v3a1 1 0 01-.293.707L12 11.414V15a1 1 0 01-.293.707l-2 2A1 1 0 018 17v-5.586L3.293 6.707A1 1 0 013 6V3z",clipRule:"evenodd"}}]})(e)}function Ue(e){return s.GenIcon({attr:{viewBox:"0 0 1024 1024"},child:[{tag:"path",attr:{d:"M505.7 661a8 8 0 0 0 12.6 0l112-141.7c4.1-5.2.4-12.9-6.3-12.9h-74.1V168c0-4.4-3.6-8-8-8h-60c-4.4 0-8 3.6-8 8v338.3H400c-6.7 0-10.4 7.7-6.3 12.9l112 141.8zM878 626h-60c-4.4 0-8 3.6-8 8v154H214V634c0-4.4-3.6-8-8-8h-60c-4.4 0-8 3.6-8 8v198c0 17.7 14.3 32 32 32h684c17.7 0 32-14.3 32-32V634c0-4.4-3.6-8-8-8z"}}]})(e)}function de(e){return s.GenIcon({attr:{viewBox:"0 0 1024 1024"},child:[{tag:"path",attr:{d:"M839.6 433.8L749 150.5a9.24 9.24 0 0 0-8.9-6.5h-77.4c-4.1 0-7.6 2.6-8.9 6.5l-91.3 283.3c-.3.9-.5 1.9-.5 2.9 0 5.1 4.2 9.3 9.3 9.3h56.4c4.2 0 7.8-2.8 9-6.8l17.5-61.6h89l17.3 61.5c1.1 4 4.8 6.8 9 6.8h61.2c1 0 1.9-.1 2.8-.4 2.4-.8 4.3-2.4 5.5-4.6 1.1-2.2 1.3-4.7.6-7.1zM663.3 325.5l32.8-116.9h6.3l32.1 116.9h-71.2zm143.5 492.9H677.2v-.4l132.6-188.9c1.1-1.6 1.7-3.4 1.7-5.4v-36.4c0-5.1-4.2-9.3-9.3-9.3h-204c-5.1 0-9.3 4.2-9.3 9.3v43c0 5.1 4.2 9.3 9.3 9.3h122.6v.4L587.7 828.9a9.35 9.35 0 0 0-1.7 5.4v36.4c0 5.1 4.2 9.3 9.3 9.3h211.4c5.1 0 9.3-4.2 9.3-9.3v-43a9.2 9.2 0 0 0-9.2-9.3zM416 702h-76V172c0-4.4-3.6-8-8-8h-56c-4.4 0-8 3.6-8 8v530h-76c-6.7 0-10.5 7.8-6.3 13l112 141.9a8 8 0 0 0 12.6 0l112-141.9c4.1-5.2.4-13-6.3-13z"}}]})(e)}function ue(e){return s.GenIcon({attr:{viewBox:"0 0 1024 1024"},child:[{tag:"path",attr:{d:"M839.6 433.8L749 150.5a9.24 9.24 0 0 0-8.9-6.5h-77.4c-4.1 0-7.6 2.6-8.9 6.5l-91.3 283.3c-.3.9-.5 1.9-.5 2.9 0 5.1 4.2 9.3 9.3 9.3h56.4c4.2 0 7.8-2.8 9-6.8l17.5-61.6h89l17.3 61.5c1.1 4 4.8 6.8 9 6.8h61.2c1 0 1.9-.1 2.8-.4 2.4-.8 4.3-2.4 5.5-4.6 1.1-2.2 1.3-4.7.6-7.1zM663.3 325.5l32.8-116.9h6.3l32.1 116.9h-71.2zm143.5 492.9H677.2v-.4l132.6-188.9c1.1-1.6 1.7-3.4 1.7-5.4v-36.4c0-5.1-4.2-9.3-9.3-9.3h-204c-5.1 0-9.3 4.2-9.3 9.3v43c0 5.1 4.2 9.3 9.3 9.3h122.6v.4L587.7 828.9a9.35 9.35 0 0 0-1.7 5.4v36.4c0 5.1 4.2 9.3 9.3 9.3h211.4c5.1 0 9.3-4.2 9.3-9.3v-43a9.2 9.2 0 0 0-9.2-9.3zM310.3 167.1a8 8 0 0 0-12.6 0L185.7 309c-4.2 5.3-.4 13 6.3 13h76v530c0 4.4 3.6 8 8 8h56c4.4 0 8-3.6 8-8V322h76c6.7 0 10.5-7.8 6.3-13l-112-141.9z"}}]})(e)}const Be=(e,n)=>{u.useEffect(()=>{function m(l){e.current&&!e.current.contains(l.target)&&n?.()}return document.addEventListener("mousedown",m),()=>{document.removeEventListener("mousedown",m)}},[e.current])},ke=e=>{const{isOpen:n,sortBy:m,filters:l,users:v,searchBy:S,defaultOptions:c,selectedOptions:x,searchKey:f,onChangeSearchKey:E,onOptionsChange:i,onSearch:o,onClose:p,onChangeFilters:U,getOption:A}=e,[I,j]=u.useState(),[C,b]=u.useState([]),R=u.useRef(null),D=u.useRef(null);Be(R,p);const{t:B}=Y.useTranslation(),L=u.useCallback(()=>{if(!n)return;const k=f?.trim?.()??"";S!=null&&!c&&o?.(k,S),S!=null&&c&&b(c.filter(_=>_.label.toLowerCase().includes(k.toLowerCase())))},[S,f,JSON.stringify(c),n]),d=()=>{D.current&&clearTimeout(D.current),D.current=setTimeout(L,500)},a=k=>{const _=k.target.value;E(_)},y=u.useCallback(()=>{i?.(I,S),p?.()},[JSON.stringify(I)]),g=u.useCallback(k=>{const _=k.target.value??"";let w=I??[],V=w.indexOf(_);V>-1?w.splice(V,1):w=[...w,_],j(w==null?w:[...w])},[JSON.stringify(I)]),r=u.useCallback(k=>{const _=k.target.checked;j(_?void 0:[])},[]),h=u.useCallback(()=>{U?.({...l,sortBy:m,isDescending:!0}),p?.()},[JSON.stringify(l),S]),O=u.useCallback(()=>{U?.({...l,sortBy:m,isDescending:!1}),p?.()},[JSON.stringify(l),S]),T=u.useMemo(()=>A?v.map(k=>A(k,B)):[],[JSON.stringify(v),JSON.stringify(A)]),$=l?.isDescending==!1&&l.sortBy===m,F=!!l?.isDescending&&l.sortBy===m;return u.useEffect(()=>{l?.searchBy!==S?j(void 0):j(x)},[JSON.stringify(x),l?.searchBy]),u.useEffect(()=>{b(c||[])},[JSON.stringify(c)]),u.useEffect(()=>{d()},[f,n]),{ref:R,options:T,inputRef:D,sOptions:I,isAscending:$,isDescending:F,filteredOptions:C,searchKey:f,handleSearch:L,handleApplyFilter:y,handleOptionSelected:g,handleOptionSelectedAll:r,handleSortDesc:h,handleSortAsc:O,handleChangeSearchKey:a}},De=e=>{const{defaultOptions:n,onClose:m,getOption:l}=e,{ref:v,inputRef:S,options:c,sOptions:x,isAscending:f,isDescending:E,filteredOptions:i,searchKey:o,handleChangeSearchKey:p,handleApplyFilter:U,handleOptionSelected:A,handleOptionSelectedAll:I,handleSortDesc:j,handleSortAsc:C}=ke(e);return t.jsx(N.Popover,{...e,hideArrow:!0,className:s.styles["popover-zindex"],children:t.jsx(N.PopoverBody,{className:"pb-3",children:t.jsxs("div",{ref:v,className:s.styles.popover,children:[t.jsxs("div",{className:`d-flex flex-column ${s.styles.popover__sort}`,children:[t.jsx(N.Label,{className:"font-weight-bold",children:"Sort"}),t.jsxs("div",{className:`px-1 ${s.styles.popover__sort__item} ${f&&s.styles["popover__sort__item--active"]}`,onClick:C,children:[t.jsx(de,{className:"mr-1"}),"Ascending"]}),t.jsxs("div",{className:`px-1 mt-1 ${s.styles.popover__sort__item} ${E&&s.styles["popover__sort__item--active"]}`,onClick:j,children:[t.jsx(ue,{className:"mr-1"}),"Descending"]})]}),(typeof l<"u"||!!n)&&t.jsxs(u.Fragment,{children:[t.jsx("div",{className:"border border-top-1 border-bottom-0 mx-1 my-2"}),t.jsxs("div",{className:"d-flex flex-column",children:[t.jsx(N.Label,{className:"font-weight-bold",children:"Filter"}),t.jsxs("div",{className:`position-relative px-1 ${s.styles.popover__search}`,children:[t.jsx(we,{className:`position-absolute ${s.styles.popover__search__icon}`}),t.jsx(N.Input,{ref:S,className:s.styles.popover__search__input,value:o,onChange:p})]}),t.jsxs("div",{className:`mx-1 mt-2 p-2 bg-light ${s.styles.popover__options}`,children:[t.jsxs(N.FormGroup,{className:"d-flex align-items-center",check:!0,style:{gap:"8px"},children:[t.jsx(N.Input,{type:"checkbox",onChange:I,checked:x==null})," ",t.jsx(N.Label,{check:!0,children:"(Select all)"})]}),!!l&&!n&&c.map(b=>t.jsxs(N.FormGroup,{className:"d-flex align-items-center",check:!0,style:{gap:"8px"},children:[t.jsx(N.Input,{type:"checkbox",value:b.value,onChange:A,checked:x?.includes(b.value)||x==null})," ",t.jsx(N.Label,{check:!0,children:b.label})]},b.value)),!!n&&i.map(b=>t.jsxs(N.FormGroup,{className:"d-flex align-items-center",check:!0,style:{gap:"8px"},children:[t.jsx(N.Input,{type:"checkbox",value:b.value,onChange:A,checked:x?.includes(b.value)||x==null})," ",t.jsx(N.Label,{check:!0,children:b.label})]},b.value))]})]}),t.jsxs("div",{className:"d-flex justify-content-end mt-3",style:{gap:"8px"},children:[t.jsx(N.Button,{color:"primary",className:"mr-2",size:"sm",onClick:U,children:"Apply Filter"}),t.jsx(N.Button,{color:"secondary",size:"sm",onClick:m,children:"Cancel"})]})]})]})})})},$e=({data:e,popoverId:n,filters:m,searchString:l,users:v,selectedOptions:S,onOptionsChange:c,onSearch:x,onChangeFilters:f,onOpenFilter:E,onClose:i,isCenter:o,isActive:p=!1})=>{const{t:U}=Y.useTranslation(),[A,I]=u.useState(""),j=u.useMemo(()=>e.sortBy!=null?P.userOrders[e.sortBy]:"",[e.sortBy]),C=u.useMemo(()=>n===j,[j,n]),b=()=>{E?.(j,e.searchBy,A,e.sortBy)},R=D=>{I(D)};return t.jsx("th",{className:e.className,children:j&&e.sortBy!==void 0?t.jsxs("div",{className:`w-100 d-flex ${o?"justify-content-center":"justify-content-between"} align-items-center ${s.styles["table-filter-icon"]}`,children:[U(e.name),t.jsxs("div",{className:"ml-2 p-1",id:j,onClick:b,style:{cursor:"pointer"},children:[e.sortBy!==void 0&&e.sortBy===m?.sortBy&&t.jsx("span",{children:m.isDescending?t.jsx(ue,{}):t.jsx(de,{})}),m?.searchByStrings?.length&&e.searchBy===m?.searchBy?t.jsx(Oe,{color:p?"#007bff":"#242424"}):t.jsx(Le,{color:p?"#007bff":"#242424"})]}),t.jsx(De,{placement:"bottom-end",target:j,users:v,isOpen:C,filters:m,sortBy:e.sortBy,searchKey:A,searchBy:e.searchBy,searchString:l,defaultOptions:e.options,selectedOptions:S,onClose:i,onSearch:x,getOption:e.getOption,onChangeFilters:f,onOptionsChange:c,onChangeSearchKey:R})]}):U(e.name)})},Fe=e=>{const{filters:n,onChangeFilters:m,isStudentFilter:l,teacherOptions:v,assistantOptions:S,counselorOptions:c,secondaryTeacherOptions:x}=e,[f,E]=u.useState(),[i,o]=u.useState([]),[p,U]=u.useState({...P.DEFAULT_FILTER_POPOVER,isDescending:n.isDescending,searchString:n.searchString}),A=H.useDispatch(),I=ie.useLocation(),j=u.useCallback(async B=>{try{const d=(l?await z.getStudentFilter(p):await z.getFilterRosterUser({...p,byStudent:B})).data?.items||[];o(d)}catch(L){A(s.setAlert({type:"danger",message:L.response?.data?.title||L.message}))}},[JSON.stringify(p),l]),C=u.useCallback((B,L,d,a)=>{E(B),U({...p,searchBy:L,searchStringBy:d,isDescending:n.sortBy===a?n.isDescending:void 0,searchString:n.searchString})},[JSON.stringify(p),n.isDescending,n.searchString]),b=()=>{E("")},R=u.useCallback((B,L)=>{U({...p,searchBy:L,searchStringBy:B})},[JSON.stringify(p)]),D=u.useCallback((B,L)=>{L&&m?.({...n,[P.SearchBy[L]]:B})},[JSON.stringify(n)]);return u.useEffect(()=>{if(!I.pathname.includes("users/assign-student"))return;const B=d=>d.sort((a,y)=>a.localeCompare(y)),L=p.searchStringBy?.toLowerCase()||"";if(p.searchBy===P.SearchBy.Grade)o(P.GRADE);else{let d=[];switch(p.searchBy){case P.SearchBy.Name:j(!0);break;case P.SearchBy.Teacher:d=v?.map(r=>r.label).filter(Boolean)||[];break;case P.SearchBy.Assistant:d=S?.map(r=>r.label).filter(Boolean)||[];break;case P.SearchBy.Counselor:d=c?.map(r=>r.label).filter(Boolean)||[];break;case P.SearchBy.SecondaryTeacher:d=x?.map(r=>r.label).filter(Boolean)||[];break}const a=Array.from(new Set(d)),y=L?a.filter(r=>r.toLowerCase().includes(L)):a,g=B(y);o(g)}},[JSON.stringify(p),v,S,c,x,I.pathname]),u.useEffect(()=>{!(I.pathname.includes("users/assign-student")&&p.searchBy!==void 0)&&p.searchBy!==void 0&&j()},[JSON.stringify(p),I.pathname]),{popoverFilters:p,popoverId:f,users:i,handleFilterIcon:C,handleCloseFilter:b,handleSearch:R,handleChangeFilters:D}},he=({headers:e,filters:n,onChangeFilters:m,isStudentFilter:l,teacherOptions:v=[],assistantOptions:S=[],counselorOptions:c=[],secondaryTeacherOptions:x=[]})=>{const{popoverId:f,users:E,handleFilterIcon:i,handleCloseFilter:o,handleSearch:p,handleChangeFilters:U}=Fe({filters:n,onChangeFilters:m,isStudentFilter:l,teacherOptions:v,assistantOptions:S,counselorOptions:c,secondaryTeacherOptions:x}),A=Object.entries(n).filter(([C,b])=>b!==""&&!(Array.isArray(b)&&b.length===0)&&b!==null&&b!==void 0).map(([C])=>C),I=Object.entries(P.SearchBy).filter(([C,b])=>isNaN(Number(C))),j=A.map(C=>I.find(([b])=>b===C)).filter(C=>!!C);return t.jsx("tr",{children:e.map(C=>C.onSelectAll?t.jsx("th",{className:`align-middle text-center ${C.className}`,children:t.jsx("input",{type:"checkbox",onChange:()=>C.onSelectAll?.(),checked:C.isCheckAll??!1})},C.name):t.jsx($e,{users:E,data:C,isCenter:C.isCenter,filters:n,popoverId:f,selectedOptions:n.searchByStrings,onSearch:p,onClose:o,onOpenFilter:i,onChangeFilters:m,onOptionsChange:U,isActive:typeof C.searchBy=="number"&&j.some(([b,R])=>R===C.searchBy)},C.name))})},Me=()=>{const e=H.useDispatch(),n=H.useSelector(x=>x?.common?.user?.schoolName)||"",m=async x=>{e(s.setLoading(!0));try{const f=await z.getRosterUserExport(x),E=f.data.items||f.data,i=l(E),o=document.createElement("a");o.href=i,o.download=`${n}_Users_Report.csv`,o.click()}catch(f){e(s.setAlert({type:"danger",message:f.response?.data?.title||f.message}))}e(s.setLoading(!1))},l=x=>{let f=`First Name,Last Name,Email,Phone,Age,Grade,Tiers,Role,Active Status,Create Time,Roster Sourced Id,Roster Status,Roster Family Name,Roster Middle Name,Roster Given Name,Roster Email,Roster Role,Roster Grades,Teachers,Assistants,Counselors,SupportTeachers,EduTeachers
|
|
2
|
+
`;const E=x.map(i=>{const o=i.dateOfBirth!==s.DATE_MIN_VALUE?ae.differenceInCalendarYears(new Date,ae.parseISO(i.dateOfBirth)):"";return`${c(i.firstName)},${c(i.lastName)},${c(i.email)},${c(i.phoneNumber)},${o},${c(i.grade)},${c(i.appType||"")},${c(i.roles.join(", ").replace("SecondaryTeacher","SupportTeacher"))},${i.isActive?"Active":"Inactive"},${s.formatLocalTime(i?.createTime,"yyyy-MM-dd HH:mm")},${c(i.sourcedId)},${c(i.rosterUser?.status)},${c(i.rosterUser?.familyName)},${c(i.rosterUser?.middleName)},${c(i.rosterUser?.givenName)},${c(i.rosterUser?.email)},${c(i.rosterUser?.role)},${c(i.rosterUser?.grades)},${c(i.teachers)},${c(i.assistants)},${c(i.counselors)},${c(i.supportTeachers)},${c(i.eduTeachers)}`}).join(`
|
|
3
|
+
`);return`${P.CSV_PREFIX}${f}${encodeURIComponent(E)}`},v=async x=>{e(s.setLoading(!0));try{const f=await z.getTeacherClassCodesExport(x),E=f?.data?.items||f?.data||[],i=S(E),o=document.createElement("a");o.href=i,o.download="Classcode.csv",o.click()}catch(f){e(s.setAlert({type:"danger",message:f.response?.data?.title||f.message}))}e(s.setLoading(!1))},S=x=>{let f=`Teacher name,Teacher Email,Teacher code
|
|
4
|
+
`;const o=(Array.isArray(x)?x:[]).filter(p=>p.roles&&p.roles.includes("Teacher")).map(p=>`${c(p.fullName)},${c(p.email)},${c(p?.assignCode||"")}`).join(`
|
|
5
|
+
`);return`${P.CSV_PREFIX}${f}${encodeURIComponent(o)}`},c=x=>x?`"${x.replace(/"/g,'""').replaceAll(/\n/g," ")}"`:"";return{exportUsers:m,exportClassCodes:v}},me=`${s.BASE_URL}/api/ImportCsv/csv`,X=`${s.BASE_URL}/api/Teacher`,Pe=(e,n)=>s.apiUpload.post(`${me}/${n}`,e),ce=e=>s.apiUpload.post(`${me}/importClassReflection`,e),ze=(e,n)=>s.apiUpload.post(`${X}/adminImportStudentByTeacherId/${e}`,n),He=e=>s.apiUpload.post(`${X}/adminImport`,e),Ve=(e=!0)=>s.api.get(`${X}/download-template-file-user?hasEsSchool=${e}`),Ge=(e,n,m=!0)=>s.apiUpload.post(`${X}/validate-csv-template-student/${n}?hasEsSchool=${m}`,e);var pe=(e=>(e.Students="students",e.Subjects="subjects",e.Grades="grades",e.Attendances="attendances",e.ClassReflection="classReflection",e.Others="others",e.AllUser="allUser",e))(pe||{});const Z="csvupload",oe={teacherName:"",teacherEmail:"",studentIds:[],file:""},qe=()=>{const e=H.useDispatch(),n=H.useSelector(g=>g.common.isLoading),[m,l]=u.useState(null),[v,S]=u.useState(),[c,x]=u.useState([]),[f,E]=u.useState(oe),[i,o]=u.useState(),p=window.location.hostname,U=p.includes("isb")||p.includes("stage"),[A,I]=u.useState(0),[j,C]=u.useState(""),b=async()=>{e(s.setLoading(!0));try{const h=await Ve();var g=new Blob([h.data.content],{type:"text/csv"});const O=window.URL.createObjectURL(g);var r=document.createElement("a");r.href=O,r.setAttribute("download",h.data.nameFile),r.click(),e(s.setAlert({type:"success",message:"Download successfully"}))}catch(h){e(s.setAlert({type:"danger",message:h.message}))}e(s.setLoading(!1))},R=u.useCallback(async g=>{if(!m||!g)return;e(s.setLoading(!0));try{const T=new FormData;if(T.append("file",g,g.name),m=="allUser"){let F=(await g.text()).trim();const k=F.split(`
|
|
6
|
+
`).map(M=>M.trim()),_=k.findIndex(M=>M.split(",").includes("FirstName"));if(_===0)throw new Error("Invalid CSV: Missing header row.");F=k.slice(_).join(`
|
|
7
|
+
`);const w=re.parse(F,{header:!0,skipEmptyLines:!0}),V=w.meta.fields,q=w.data;if(!V)throw new Error("Unable to determine header from CSV file");const J=20,G=[];for(let M=0;M<q.length;M+=J){const Q=q.slice(M,M+J),K=re.unparse({fields:V,data:Q});G.push(K)}for(let M=0;M<G.length;M++){const Q=new Blob([G[M]],{type:"text/csv"}),K=new FormData;K.append("file",Q,`students_chunk${M+1}.csv`),await He(K)}}else U?m=="classReflection"&&await ce(T):await Pe(T,m.toString());e(s.setAlert({type:"success",message:"Import CSV successfully"}))}catch(T){e(s.setAlert({type:"danger",message:T.response?.data?.title||T.message}))}e(s.setLoading(!1));const r=document.getElementById(Z),h=document.getElementById("import-student"),O=document.getElementById("import-classReflection");r&&(r.value=""),h&&(h.value=""),O&&(O.value="")},[m]),D=async g=>{if(!A){e(s.setAlert({type:"danger",message:"Select teacher before import csv"}));return}if(!m||!g)return;e(s.setLoading(!0));try{const h=new FormData;h.append("file",g,g.name),await ze(A,h),e(s.setAlert({type:"success",message:"Import CSV successfully"}))}catch(h){e(s.setAlert({type:"danger",message:h.response?.data?.title||h.message}))}e(s.setLoading(!1));const r=document.getElementById("teacherSelector");r&&(r.value="")},B=async g=>{if(!v||!v)return;e(s.setLoading(!0));try{const h=new FormData;h.append("file",v,v.name),h.append("teacherName",g.teacherName),h.append("teacherEmail",g.teacherEmail),g.studentIds.forEach(O=>{h.append("studentIds",O)}),await ce(h),e(s.setAlert({type:"success",message:"Import CSV successfully"})),E(oe)}catch(h){e(s.setAlert({type:"danger",message:h.response?.data?.title||h.message}))}e(s.setLoading(!1));const r=document.getElementById(Z);r&&(r.value="")},L=g=>{I(g.value)},d=g=>{o(g),C(g?.name||"")},a=()=>{if(!i){e(s.setAlert({type:"danger",message:"Select CSV to import"}));return}D(i)};return{isLoading:n,id:Z,setType:l,upload:R,initImportReflection:f,setInitImportReflection:E,onConfirm:B,CSVType:pe,dataFile:v,setDataFile:S,setArrStudent:x,arrStudent:c,isCheckDomainIBS:U,onChangeTeacher:L,uploadByTeacherId:D,setDataFileImportStudent:d,onUpLoadStudentFile:a,defaultTeacher:A,fileName:j,onStudentSubmit:()=>{e(s.setModal({isOpen:!0,type:"warning",message:"Are you sure upload this file?",onConfirm:()=>{a()}}))},downloadTemplateUser:b}},Je=()=>{const e=H.useDispatch(),n=async v=>{e(s.setLoading(!0));try{await z.postRequestResendMail(v),e(s.setAlert({type:"success",message:"Send Successfully"}))}catch(S){e(s.setAlert({type:"danger",message:S.response?.data?.title||S.message}))}e(s.setLoading(!1))};return{handleSendMultiUsers:v=>{n({userIds:[...v]})},handleSendSingleUser:v=>{n({userIds:[v]})}}},ee={fontWeight:500},te={height:38,backgroundColor:"#2eb85c",borderColor:"#2eb85c"},Ke={display:"inline-block",fontSize:11,fontWeight:700,color:"#3b4ba8",backgroundColor:"#e9ecfb",borderRadius:4,padding:"1px 6px",marginRight:6,textTransform:"uppercase"},le=({label:e})=>t.jsx("span",{style:Ke,children:e}),se=({label:e})=>t.jsx("span",{style:{display:"inline-flex",alignItems:"center",justifyContent:"center",fontSize:11,fontWeight:700,color:"#3b4ba8",backgroundColor:"#e9ecfb",borderRadius:4,padding:"3px 8px",textTransform:"uppercase"},children:e}),We=({isActive:e,t:n})=>t.jsxs("span",{style:{display:"inline-flex",alignItems:"center",fontSize:12,fontWeight:600,color:e?"#047857":"#6b7280",backgroundColor:e?"#d1fae5":"#f3f4f6",borderRadius:"20px",padding:"4px 12px"},children:[t.jsx("span",{style:{width:"6px",height:"6px",borderRadius:"50%",backgroundColor:e?"#10b981":"#9ca3af",marginRight:"8px"}}),n(e?"active":"inactive")]}),ne=e=>(e||[]).map(n=>n==="SecondaryTeacher"?"SupportTeacher":n).join(", "),Ye="user",ge=()=>{const{queryName:e,userList:n,totalItems:m,filters:l,fullName:v,removeData:S,changeFilters:c,reDirectDetailPage:x,switchUser:f,handleSyncRosterUsers:E,rosterUserInfo:i,onSelectUser:o,userIds:p,onSelectAllUser:U,isCheckAll:A}=Ae(),{handleSendMultiUsers:I}=Je(),{upload:j}=qe(),{exportUsers:C,exportClassCodes:b}=Me(),{t:R}=Y.useTranslation(),D=()=>C(l),B=()=>b(l),L=[{name:"",isCenter:!0,onSelectAll:U,isCheckAll:A}].concat(P.UserColumns);return t.jsxs("div",{className:`fadeIn animated h-100 ${s.screenWidth<=767?s.styles["p-0-12"]:""}`,children:[t.jsx("h5",{className:"mt-4 mb-2",children:R(`${Ye}`)}),t.jsxs(N.Row,{className:"my-2",children:[t.jsx(N.Col,{md:8,children:t.jsx(s.SearchBoxContainer,{text:R("create_user"),onClick:()=>x(),initValue:e||"",onSearch:d=>c({searchString:d}),placeholder:R("type_something_to_search_by_user_name")})}),t.jsxs(N.Col,{md:4,className:"d-flex justify-content-end align-items-center",children:[R("total_of_users")," : ",m]}),t.jsxs(N.Col,{md:12,className:"d-flex justify-content-end my-2 flex-wrap",style:{gap:"8px"},children:[t.jsx("button",{className:"btn btn-success d-flex align-items-center border-0",style:te,onClick:()=>I(p),children:t.jsx("p",{className:`${s.styles["button-content"]} mb-0`,style:ee,children:R("welcome_email_resend")})}),t.jsx(N.Input,{id:"import-user",className:"d-none",type:"file",onChange:d=>j(d.target.files[0]),accept:"text/csv"}),t.jsx(Ie,{text:R("sync_roster_users"),onClick:E}),t.jsxs("button",{className:"btn btn-success d-flex align-items-center border-0 p-0",style:te,onClick:B,children:[t.jsx("div",{className:`${s.styles["button-icon"]}`,children:t.jsx("img",{src:"images/export-icon.svg",alt:""})}),t.jsx("p",{className:`${s.styles["button-content"]} mb-0`,style:ee,children:R("export_class_code_to_csv")})]}),t.jsxs("button",{className:"btn btn-success d-flex align-items-center border-0 p-0",style:te,onClick:D,children:[t.jsx("div",{className:`${s.styles["button-icon"]}`,children:t.jsx("img",{src:"images/export-icon.svg",alt:""})}),t.jsx("p",{className:`${s.styles["button-content"]} mb-0`,style:ee,children:R("export_to_csv")})]})]})]}),t.jsxs(N.Row,{className:"mb-2",children:[t.jsx(N.Col,{md:12,children:t.jsx("div",{style:{overflow:"auto"},children:t.jsxs(N.Table,{bordered:!0,hover:!0,striped:!0,size:"sm",children:[t.jsx("thead",{children:t.jsx(he,{headers:L,filters:l,fullName:v,onChangeFilters:c})}),t.jsxs("tbody",{children:[n&&n.length>0&&n.map(d=>{const a=(d.appType||"").toUpperCase(),y=a.includes("ES")&&a.includes("MS");return t.jsxs("tr",{children:[t.jsx("td",{className:"align-middle",children:t.jsx("input",{type:"checkbox",onChange:()=>o(d.id),checked:p.includes(d.id)??!1})}),t.jsx("td",{className:"align-middle",children:t.jsx(s.LinkEditButton,{label:`${d.fullName}`,onClick:()=>x(d.id)})}),t.jsx("td",{className:"align-middle",children:d.email}),t.jsx("td",{className:"align-middle",children:d.dateOfBirth!==s.DATE_MIN_VALUE&&ye(new Date,new Date(d.dateOfBirth))}),t.jsx("td",{className:"align-middle",children:y?t.jsxs(t.Fragment,{children:[t.jsxs("div",{children:[t.jsx(le,{label:"ES"}),ne(d.esRoles)]}),t.jsxs("div",{className:"mt-1",children:[t.jsx(le,{label:"MS"}),ne(d.msRoles)]})]}):!!d.roles&&ne(d.roles)}),t.jsx("td",{className:"align-middle text-uppercase",children:y?t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"4px",alignItems:"center",width:"fit-content"},children:[t.jsx(se,{label:"ES"}),t.jsx(se,{label:"MS"})]}):d.appType?t.jsx(se,{label:d.appType}):null}),t.jsx("td",{className:"align-middle",children:t.jsx(We,{isActive:d.isActive,t:R})}),t.jsx("td",{className:"align-middle",children:s.formatLocalTime(d?.createTime,"yyyy-MM-dd HH:mm")}),t.jsx("td",{children:i(d)}),t.jsx("td",{className:"align-middle",children:t.jsx(s.FaUsersCog,{style:{fontSize:"18px",margin:"0 10px",cursor:"pointer"},onClick:()=>f(d.id)})}),t.jsx("td",{className:"align-middle",style:{padding:"0 15px"},children:t.jsx(s.DeleteButtonIcon,{onClick:()=>S(d.id)})})]},`${d.id}_${d.appType||""}`)}),(!n||!n.length)&&t.jsx("tr",{children:t.jsx("td",{colSpan:12,className:"p-0",children:t.jsx(s.EmptyDataAlert,{className:"mb-0",label:R("user")})})})]})]})})}),t.jsx(N.Col,{md:12,children:t.jsx(s.CustomPagination,{filters:l,totalRecordCount:m,changePageSize:d=>c({pageSize:d}),changePage:d=>c({currentPage:d})})})]})]})},Xe=Object.freeze(Object.defineProperty({__proto__:null,default:ge},Symbol.toStringTag,{value:"Module"}));exports.AiOutlineDownload=Ue;exports.TableHeader=he;exports.UserList=ge;exports.UserList$1=Xe;exports.validateCsvApi=Ge;
|