mario-core 2.0.98-release → 2.0.100-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-BE7Tz-wC.js +1 -0
- package/dist/Dashboard-BVPTDKAu.mjs +206 -0
- package/dist/Dashboard-BXGj0ocj.mjs +206 -0
- package/dist/Dashboard-BmdK8dWK.mjs +206 -0
- package/dist/Dashboard-CGeGXuwV.mjs +206 -0
- package/dist/Dashboard-CexYkfqV.js +1 -0
- package/dist/Dashboard-CmPOEstn.js +1 -0
- package/dist/Dashboard-CutvaymS.js +1 -0
- package/dist/Dashboard-D-5G_YNh.mjs +206 -0
- package/dist/Dashboard-DEZdmPO5.js +1 -0
- package/dist/Dashboard-DJHQuJK8.mjs +206 -0
- package/dist/Dashboard-DQ5FoWMW.js +1 -0
- package/dist/Dashboard-DkxdQmm7.js +1 -0
- package/dist/Dashboard-F_oNZ1ED.mjs +206 -0
- package/dist/Dashboard-LQQNKTQR.mjs +206 -0
- package/dist/Dashboard-xUZwMhtb.js +1 -0
- package/dist/EmailTemplateDetail-8QQkBNYV.js +1 -0
- package/dist/EmailTemplateDetail-BMC8Bo5c.mjs +443 -0
- package/dist/EmailTemplateDetail-BijiTHup.js +1 -0
- package/dist/EmailTemplateDetail-C1dIeruZ.js +1 -0
- package/dist/EmailTemplateDetail-C39gty_Y.mjs +443 -0
- package/dist/EmailTemplateDetail-C9huuy7B.mjs +443 -0
- package/dist/EmailTemplateDetail-CbNeAmA2.mjs +443 -0
- package/dist/EmailTemplateDetail-CekNUyOs.mjs +443 -0
- package/dist/EmailTemplateDetail-CyAGy4Cv.js +1 -0
- package/dist/EmailTemplateDetail-CywZcrAW.js +1 -0
- package/dist/EmailTemplateDetail-DENmArIS.mjs +443 -0
- package/dist/EmailTemplateDetail-De1-TqqT.js +1 -0
- package/dist/EmailTemplateDetail-DhHPKZJb.js +1 -0
- package/dist/EmailTemplateDetail-DlyrGm4B.mjs +443 -0
- package/dist/EmailTemplateDetail-FvgSJs1A.js +1 -0
- package/dist/EmailTemplateDetail-sUkoiG9C.mjs +443 -0
- package/dist/EmailTemplateList-BONYsb7f.js +1 -0
- package/dist/EmailTemplateList-BQRYd0QB.mjs +170 -0
- package/dist/EmailTemplateList-BYwRH-DJ.mjs +170 -0
- package/dist/EmailTemplateList-B_SfhEej.js +1 -0
- package/dist/EmailTemplateList-C19OX7Cw.js +1 -0
- package/dist/EmailTemplateList-C4ffDlup.js +1 -0
- package/dist/EmailTemplateList-CA5uvsLr.js +1 -0
- package/dist/EmailTemplateList-Cn4tUiuG.mjs +170 -0
- package/dist/EmailTemplateList-DFy70sCo.mjs +170 -0
- package/dist/EmailTemplateList-DGwpwvQQ.mjs +170 -0
- package/dist/EmailTemplateList-DIzrlY7K.mjs +170 -0
- package/dist/EmailTemplateList-DPZB3oNQ.js +1 -0
- package/dist/EmailTemplateList-DTkzDmy-.js +1 -0
- package/dist/EmailTemplateList-X20GY4Pt.mjs +170 -0
- package/dist/EmailTemplateList-bNLQgu0y.mjs +170 -0
- package/dist/EmailTemplateList-sY4bOBQm.js +1 -0
- package/dist/GalleryList-6spc98uu.js +1 -0
- package/dist/GalleryList-BCrPPGGW.mjs +329 -0
- package/dist/GalleryList-BIl_P7eK.js +1 -0
- package/dist/GalleryList-BRh6IfWc.js +1 -0
- package/dist/GalleryList-BVDBa2lH.js +1 -0
- package/dist/GalleryList-Byohd3LQ.mjs +329 -0
- package/dist/GalleryList-C0c1Lcei.mjs +329 -0
- package/dist/GalleryList-CJHiz314.mjs +329 -0
- package/dist/GalleryList-DFFOzuli.mjs +329 -0
- package/dist/GalleryList-DZlLHEfU.mjs +329 -0
- package/dist/GalleryList-DmU0bLzG.js +1 -0
- package/dist/GalleryList-OM7afuEA.js +1 -0
- package/dist/GalleryList-ftKYDPMF.mjs +329 -0
- package/dist/GalleryList-jhhAfVvA.js +1 -0
- package/dist/GalleryList-nAAKlOwO.mjs +329 -0
- package/dist/GalleryList-zgcCqEZv.js +1 -0
- package/dist/Login-B7k7o5pF.js +1 -0
- package/dist/Login-BH5OwKv2.mjs +1684 -0
- package/dist/Login-BJuO-SJY.mjs +1684 -0
- package/dist/Login-CJ3aEabk.mjs +1684 -0
- package/dist/Login-CVLUBeZy.mjs +1684 -0
- package/dist/Login-CjImvzwC.mjs +1684 -0
- package/dist/Login-Cw5c4Hje.js +1 -0
- package/dist/Login-D6nwKqRG.js +1 -0
- package/dist/Login-DCT8Zla6.js +1 -0
- package/dist/Login-DCm7LqZh.js +1 -0
- package/dist/Login-DXnaw-U9.js +1 -0
- package/dist/Login-GWyk-eIV.mjs +1684 -0
- package/dist/Login-LXbnE_J4.js +1 -0
- package/dist/Login-cjknCuG9.mjs +1684 -0
- package/dist/Login-jH_kVfj0.mjs +1684 -0
- package/dist/Login-sxZN5lh5.js +1 -0
- package/dist/NotificationList-8-zhewjE.mjs +3982 -0
- package/dist/NotificationList-B5Tfc1vh.js +2 -0
- package/dist/NotificationList-BOG92unY.js +2 -0
- package/dist/NotificationList-BPJUTdNT.mjs +3982 -0
- package/dist/NotificationList-BnttapwN.mjs +3982 -0
- package/dist/NotificationList-C-MUJ7k1.js +2 -0
- package/dist/NotificationList-CQxjO1xN.js +2 -0
- package/dist/NotificationList-CXqG_d0Q.js +2 -0
- package/dist/NotificationList-DTAqMlBa.mjs +3982 -0
- package/dist/NotificationList-DcJvSG4E.js +2 -0
- package/dist/NotificationList-Ds-_PCAt.mjs +3982 -0
- package/dist/NotificationList-GPz6hiiE.mjs +3982 -0
- package/dist/NotificationList-h3voWCem.mjs +3982 -0
- package/dist/NotificationList-nTKZ6iw-.js +2 -0
- package/dist/NotificationList-tFXBjkrF.mjs +3982 -0
- package/dist/NotificationList-uCXmEjtE.js +2 -0
- package/dist/SkillList-B8LVobTk.mjs +386 -0
- package/dist/SkillList-BDzfvD0h.mjs +386 -0
- package/dist/SkillList-B_AU-13O.js +1 -0
- package/dist/SkillList-CDPuumBK.mjs +386 -0
- package/dist/SkillList-CYxkPG8D.js +1 -0
- package/dist/SkillList-CssotCzD.mjs +386 -0
- package/dist/SkillList-CvSUFyiA.js +1 -0
- package/dist/SkillList-D3HXlb9M.js +1 -0
- package/dist/SkillList-DAvTpv0U.js +1 -0
- package/dist/SkillList-DIQD_psl.mjs +386 -0
- package/dist/SkillList-DLOPODfJ.js +1 -0
- package/dist/SkillList-DbE2-E8h.mjs +386 -0
- package/dist/SkillList-DfDTfoeS.js +1 -0
- package/dist/SkillList-DsfWuKg-.mjs +386 -0
- package/dist/SkillList-OnpDgA5G.mjs +386 -0
- package/dist/SkillList-z-eSMnyB.js +1 -0
- package/dist/TeacherSelector-9wlVivPC.js +1 -0
- package/dist/TeacherSelector-B0XXXfse.mjs +30 -0
- package/dist/TeacherSelector-B_92BUDL.js +1 -0
- package/dist/TeacherSelector-CCUv-98Y.js +1 -0
- package/dist/TeacherSelector-CcNAb-MB.js +1 -0
- package/dist/TeacherSelector-CfPGIjnG.js +1 -0
- package/dist/TeacherSelector-Cr3_G_mY.js +1 -0
- package/dist/TeacherSelector-DPFFHSxN.js +1 -0
- package/dist/TeacherSelector-DYOMerDb.mjs +30 -0
- package/dist/TeacherSelector-Dj7mKMoQ.mjs +30 -0
- package/dist/TeacherSelector-DzZEWMyC.mjs +30 -0
- package/dist/TeacherSelector-WfvYnekz.js +1 -0
- package/dist/TeacherSelector-XhHBkMav.mjs +30 -0
- package/dist/TeacherSelector-jcdLTZMD.mjs +30 -0
- package/dist/TeacherSelector-mc9vDN0y.mjs +30 -0
- package/dist/TeacherSelector-xeguITZI.mjs +30 -0
- package/dist/TheContent-BIkZzjYE.mjs +38 -0
- package/dist/TheContent-BPStknsT.js +1 -0
- package/dist/TheContent-C4_dsK-o.js +1 -0
- package/dist/TheContent-CRlLFgZL.mjs +38 -0
- package/dist/TheContent-C_5jY9Fd.mjs +38 -0
- package/dist/TheContent-Cf9YuFhh.mjs +38 -0
- package/dist/TheContent-DBeQ0QXk.js +1 -0
- package/dist/TheContent-DE3BPetK.mjs +38 -0
- package/dist/TheContent-DGQuGUy9.js +1 -0
- package/dist/TheContent-DKplh020.js +1 -0
- package/dist/TheContent-DiY3IBgx.js +1 -0
- package/dist/TheContent-Du3gLW0v.mjs +38 -0
- package/dist/TheContent-Qb9Fb-da.js +1 -0
- package/dist/TheContent-XwBj9mee.mjs +38 -0
- package/dist/TheContent-auxjGmbD.js +1 -0
- package/dist/TheContent-qo1QGRKN.mjs +38 -0
- package/dist/UserContainer-6ETSA4kk.js +5 -0
- package/dist/UserContainer-B0J1Lb8F.js +5 -0
- package/dist/UserContainer-BC1Nx-rS.mjs +2902 -0
- package/dist/UserContainer-C5eQoMmH.js +5 -0
- package/dist/UserContainer-CLZeqc2d.mjs +2902 -0
- package/dist/UserContainer-C_IJbndj.js +5 -0
- package/dist/UserContainer-D0XoTyu2.js +5 -0
- package/dist/UserContainer-DLTqrlwR.mjs +2902 -0
- package/dist/UserContainer-DPz98BAp.mjs +2902 -0
- package/dist/UserContainer-DV_rmkvG.js +5 -0
- package/dist/UserContainer-Db8akIWX.js +5 -0
- package/dist/UserContainer-SYTWVZx1.mjs +2902 -0
- package/dist/UserContainer-dA1dr-0t.mjs +2902 -0
- package/dist/UserContainer-lwLlvGmM.js +5 -0
- package/dist/UserContainer-t_fMY56w.mjs +2902 -0
- package/dist/UserContainer-wsy9oAed.mjs +2902 -0
- package/dist/UserDetail-BN-MRyhQ.js +1 -0
- package/dist/UserDetail-BSNeQSgi.js +1 -0
- package/dist/UserDetail-BsMedbV3.mjs +903 -0
- package/dist/UserDetail-Bt2fAo7o.mjs +903 -0
- package/dist/UserDetail-BxMRSoJh.mjs +903 -0
- package/dist/UserDetail-C6wPT9Mx.mjs +903 -0
- package/dist/UserDetail-C7_3F9NS.js +1 -0
- package/dist/UserDetail-CCxUFgKF.js +1 -0
- package/dist/UserDetail-CHXjVqLB.js +1 -0
- package/dist/UserDetail-CUDDWqBi.mjs +903 -0
- package/dist/UserDetail-DMo9JbeW.js +1 -0
- package/dist/UserDetail-DthL7O9f.mjs +903 -0
- package/dist/UserDetail-IMiq5963.js +1 -0
- package/dist/UserDetail-Ug9AHbbp.mjs +903 -0
- package/dist/UserDetail-ZjC-PMUl.js +1 -0
- package/dist/UserDetail-cbyui91i.mjs +903 -0
- package/dist/UserList-1FQoQqeL.mjs +1252 -0
- package/dist/UserList-1OAuKhh-.js +7 -0
- package/dist/UserList-B01JYovI.mjs +1252 -0
- package/dist/UserList-B2yKOlpQ.mjs +1252 -0
- package/dist/UserList-BBjWqp1-.js +7 -0
- package/dist/UserList-BhJnNp3r.js +7 -0
- package/dist/UserList-C8Qh7KpY.js +7 -0
- package/dist/UserList-DPO2AbqO.mjs +1252 -0
- package/dist/UserList-DQ6zP5rh.js +7 -0
- package/dist/UserList-DXyaNhnd.mjs +1252 -0
- package/dist/UserList-D_GlbCU6.mjs +1252 -0
- package/dist/UserList-Deb2KYP9.js +7 -0
- package/dist/UserList-DmbGHyhL.mjs +1252 -0
- package/dist/UserList-Ds_1RDEb.mjs +1252 -0
- package/dist/UserList-UkUSW1xc.js +7 -0
- package/dist/UserList-vyiB7JTj.js +7 -0
- package/dist/constants-3UvJHA17.mjs +286 -0
- package/dist/constants-BACMK5hA.js +1 -0
- package/dist/constants-BILr1a3t.js +1 -0
- package/dist/constants-BZtXaq-n.mjs +286 -0
- package/dist/constants-BmCYcPr9.js +1 -0
- package/dist/constants-BxS1hwUo.mjs +286 -0
- package/dist/constants-CSKbcUia.mjs +286 -0
- package/dist/constants-CbfEFtSw.js +1 -0
- package/dist/constants-CoDDxmrF.mjs +286 -0
- package/dist/constants-Cz9bXp0n.mjs +286 -0
- package/dist/constants-DI2zgQsc.mjs +286 -0
- package/dist/constants-DRKzJlEG.js +1 -0
- package/dist/constants-DnR9HwqE.js +1 -0
- package/dist/constants-LxsGpdp7.mjs +286 -0
- package/dist/constants-V_8cOeQZ.js +1 -0
- package/dist/constants-fG8OJgka.js +1 -0
- package/dist/index-8-tOP3u8.js +15 -0
- package/dist/index-9T737TY5.mjs +19133 -0
- package/dist/index-AMnSCGum.js +15 -0
- package/dist/index-B3i6X8ri.mjs +19133 -0
- package/dist/index-BjUmah1D.mjs +19113 -0
- package/dist/index-C2r-UaCo.mjs +19133 -0
- package/dist/index-C8fNfHyM.js +15 -0
- package/dist/index-D9-Ga9sC.mjs +19133 -0
- package/dist/index-DVYWdYDu.js +15 -0
- package/dist/index-DWFRxH0g.js +15 -0
- package/dist/index-DsKvKD9f.mjs +19073 -0
- package/dist/index-Js3ivY3E.js +15 -0
- package/dist/index-g0i4I-UC.js +15 -0
- package/dist/index-j6AfCwnN.mjs +19113 -0
- package/dist/index-nsMJX1tN.mjs +19133 -0
- package/dist/index-zAGSNpMb.js +15 -0
- package/dist/index.js +1 -1
- package/dist/index.modern.js +1 -1
- package/dist/mailCategoryService-BGBzytxF.js +1 -0
- package/dist/mailCategoryService-BIXXOzMs.mjs +11 -0
- package/dist/mailCategoryService-BLU8aExX.js +1 -0
- package/dist/mailCategoryService-CFGoXvP3.mjs +11 -0
- package/dist/mailCategoryService-CGUO5ONE.mjs +11 -0
- package/dist/mailCategoryService-CaoRQeDg.mjs +11 -0
- package/dist/mailCategoryService-CeMO9hpm.mjs +11 -0
- package/dist/mailCategoryService-Cf9BhF09.js +1 -0
- package/dist/mailCategoryService-CsIBOwkv.js +1 -0
- package/dist/mailCategoryService-D7cXi3kx.mjs +11 -0
- package/dist/mailCategoryService-D8t2Pgn2.js +1 -0
- package/dist/mailCategoryService-DusgPUPZ.js +1 -0
- package/dist/mailCategoryService-DzNRiJ8O.mjs +11 -0
- package/dist/mailCategoryService-KGpciCNX.js +1 -0
- package/dist/mailCategoryService-iPjnG0hI.mjs +11 -0
- package/dist/mailCategoryService-pn4IdqS2.js +1 -0
- package/dist/mario-core.css +1 -1
- package/dist/userService--nEN7XIf.mjs +56 -0
- package/dist/userService-BNlww_O3.js +1 -0
- package/dist/userService-Br3qttMz.mjs +56 -0
- package/dist/userService-C-Affz_0.js +1 -0
- package/dist/userService-C0qA8Izq.js +1 -0
- package/dist/userService-CJGYpkqn.js +1 -0
- package/dist/userService-CJZkWIQm.mjs +56 -0
- package/dist/userService-COFqATbD.mjs +56 -0
- package/dist/userService-CPgfiPs8.js +1 -0
- package/dist/userService-CUN5BIDJ.mjs +56 -0
- package/dist/userService-D-Bwf7lN.mjs +56 -0
- package/dist/userService-DDn6vOqd.mjs +56 -0
- package/dist/userService-DIJrzbzO.js +1 -0
- package/dist/userService-DnowdDLU.mjs +56 -0
- package/dist/userService-Dv2QkdOI.js +1 -0
- package/dist/userService-MYXpUjgd.js +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";const t=require("react/jsx-runtime"),N=require("reactstrap"),z=require("./userService-Dv2QkdOI.js"),Y=require("react-i18next"),u=require("react"),H=require("react-redux"),ie=require("react-router-dom"),s=require("./index-DVYWdYDu.js"),F=require("./constants-CbfEFtSw.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(F.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:o}=Se(),x=m||"",[f,E]=u.useState([]),i=window.location.host.includes("-district"),c=H.useDispatch(),{t:p}=Y.useTranslation(),w=a=>{const y=f.find(g=>g==a);E(y?f.filter(g=>g!=a):f.concat([a]))},_=u.useMemo(()=>(l||[]).length>0&&(l||[]).every(a=>f.includes(a.id)),[l,f]),I=u.useCallback(()=>{if(_){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,_,f]),j=u.useCallback(async()=>{if(S.searchBy!==void 0&&S.searchByStrings!==void 0&&S.searchByStrings.length===0){c(s.setUserList({userList:[],totalItems:0}));return}c(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"));c(s.setUserList({userList:y,totalItems:g}))}catch(a){c(s.setAlert({type:"danger",message:a.response?.data?.title||a.message}))}c(s.setLoading(!1))},[c,S]),C=async()=>{c(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.");c(s.setModal({isOpen:!0,type:"success",message:y}))}catch(a){c(s.setModal({isOpen:!0,type:"danger",message:a.response?.data?.message||a.response?.data?.title||a.message}))}c(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:R,email:D}=r,$=[];R&&$.push(R),O&&$.push(O),h&&$.push(h),y.push($.join(" ")||""),y.push(D||"")}return y.join(" / ")};u.useEffect(()=>{document.title=Ce},[]),u.useEffect(()=>{o({...S,searchString:x})},[x]),u.useEffect(()=>{j()},[JSON.stringify(S)]);const A=u.useCallback(a=>{c(s.setModal({isOpen:!0,type:"warning",message:p("do_you_want_to_remove_this_user"),onConfirm:async()=>{c(s.setLoading(!0));try{await z.remove(a),c(s.setAlert({type:"success",message:"Remove user successfully"})),S.currentPage!==1?o({currentPage:1}):j()}catch(y){c(s.setAlert({type:"danger",message:y.response?.data?.title||y.message}))}c(s.setLoading(!1))}}))},[JSON.stringify(S)]),k=[{role:"Admin",path:Ee},{role:"Teacher",path:W},{role:"Assistant",path:W},{role:"Student",path:be},{role:"Parent",path:je},{role:"EduTeacher",path:_e},{role:"Counselor",path:W},{role:"SecondaryTeacher",path:W}],T=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||[],R=(a.data.appType||"").toUpperCase();r.length===0&&h.length===0&&O.length>0&&(R.includes("ES")&&!R.includes("MS")?h=O:R.includes("MS")&&!R.includes("ES")?r=O:(r=O,h=O));let D="MS",$="/home",U=!1;for(const{role:V,path:J}of k){const G=r.includes(V),q=h.includes(V);if(!(!G&&!q)){D=G?"MS":"ES",$=J,U=!0;break}}U||(D=r.length>0?"MS":h.length>0?"ES":"MS");const B=D==="ES"?h:r;y?sessionStorage.setItem(s.ACCESS_TOKEN,g):localStorage.setItem(s.ACCESS_TOKEN,g),B.includes("Admin")?localStorage.setItem("ROLES","Admin"):B.length>0&&localStorage.setItem("ROLES",B.toString()),localStorage.removeItem(s.NOTIFICATION_ALERT_KEY),i&&($=Ne);const P=D==="ES"&&!B.includes("Admin")?`/es${$}`:$;window.location.href=P},L=u.useCallback(async a=>{try{const g=(await z.switchAccountUser(a)).data;c(s.setModal({isOpen:!0,type:"warning",message:p("do_you_want_to_impersonate_this_user"),onConfirm:async()=>{c(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 R=0;R<localStorage.length;R++){const D=localStorage.key(R);D&&(D==="SELECTED_TIER"||D.startsWith("SELECTED_TIER_"))&&(O[D]=localStorage.getItem(D)||"")}localStorage.clear(),Object.keys(O).forEach(R=>{localStorage.setItem(R,O[R])}),T(h)}catch(r){s.setAlert({type:"danger",message:r.response?.data?.title||r.message})}c(s.setLoading(!1))}}))}catch(y){c(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:A,changeFilters:o,reDirectDetailPage:a=>{const y=a?`${xe}/${a}`:ve;e(y)},switchUser:L,handleSyncRosterUsers:C,rosterUserInfo:b,userIds:f,onSelectAllUser:I,onSelectUser:w,isCheckAll:_}},Re={fontWeight:500},Ie={height:38,background:"#316cd9"},Le=({text:e,onClick:n,className:m=""})=>t.jsxs(N.Button,{onClick:n,color:"primary",style:Ie,className:`d-flex align-items-center ${m} gap-2`,children:[t.jsx(s.FaSyncAlt,{}),t.jsx("span",{style:Re,children:e})]});function Oe(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 Te(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:o,selectedOptions:x,searchKey:f,onChangeSearchKey:E,onOptionsChange:i,onSearch:c,onClose:p,onChangeFilters:w,getOption:_}=e,[I,j]=u.useState(),[C,b]=u.useState([]),A=u.useRef(null),k=u.useRef(null);Be(A,p);const{t:T}=Y.useTranslation(),L=u.useCallback(()=>{if(!n)return;const U=f?.trim?.()??"";S!=null&&!o&&c?.(U,S),S!=null&&o&&b(o.filter(B=>B.label.toLowerCase().includes(U.toLowerCase())))},[S,f,JSON.stringify(o),n]),d=()=>{k.current&&clearTimeout(k.current),k.current=setTimeout(L,500)},a=U=>{const B=U.target.value;E(B)},y=u.useCallback(()=>{i?.(I,S),p?.()},[JSON.stringify(I)]),g=u.useCallback(U=>{const B=U.target.value??"";let P=I??[],V=P.indexOf(B);V>-1?P.splice(V,1):P=[...P,B],j(P==null?P:[...P])},[JSON.stringify(I)]),r=u.useCallback(U=>{const B=U.target.checked;j(B?void 0:[])},[]),h=u.useCallback(()=>{w?.({...l,sortBy:m,isDescending:!0}),p?.()},[JSON.stringify(l),S]),O=u.useCallback(()=>{w?.({...l,sortBy:m,isDescending:!1}),p?.()},[JSON.stringify(l),S]),R=u.useMemo(()=>_?v.map(U=>_(U,T)):[],[JSON.stringify(v),JSON.stringify(_)]),D=l?.isDescending==!1&&l.sortBy===m,$=!!l?.isDescending&&l.sortBy===m;return u.useEffect(()=>{l?.searchBy!==S?j(void 0):j(x)},[JSON.stringify(x),l?.searchBy]),u.useEffect(()=>{b(o||[])},[JSON.stringify(o)]),u.useEffect(()=>{d()},[f,n]),{ref:A,options:R,inputRef:k,sOptions:I,isAscending:D,isDescending:$,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:o,sOptions:x,isAscending:f,isDescending:E,filteredOptions:i,searchKey:c,handleChangeSearchKey:p,handleApplyFilter:w,handleOptionSelected:_,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:c,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&&o.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:_,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:_,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:w,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:o,onSearch:x,onChangeFilters:f,onOpenFilter:E,onClose:i,isCenter:c,isActive:p=!1})=>{const{t:w}=Y.useTranslation(),[_,I]=u.useState(""),j=u.useMemo(()=>e.sortBy!=null?F.userOrders[e.sortBy]:"",[e.sortBy]),C=u.useMemo(()=>n===j,[j,n]),b=()=>{E?.(j,e.searchBy,_,e.sortBy)},A=k=>{I(k)};return t.jsx("th",{className:e.className,children:j&&e.sortBy!==void 0?t.jsxs("div",{className:`w-100 d-flex ${c?"justify-content-center":"justify-content-between"} align-items-center ${s.styles["table-filter-icon"]}`,children:[w(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(Te,{color:p?"#007bff":"#242424"}):t.jsx(Oe,{color:p?"#007bff":"#242424"})]}),t.jsx(De,{placement:"bottom-end",target:j,users:v,isOpen:C,filters:m,sortBy:e.sortBy,searchKey:_,searchBy:e.searchBy,searchString:l,defaultOptions:e.options,selectedOptions:S,onClose:i,onSearch:x,getOption:e.getOption,onChangeFilters:f,onOptionsChange:o,onChangeSearchKey:A})]}):w(e.name)})},Fe=e=>{const{filters:n,onChangeFilters:m,isStudentFilter:l,teacherOptions:v,assistantOptions:S,counselorOptions:o,secondaryTeacherOptions:x}=e,[f,E]=u.useState(),[i,c]=u.useState([]),[p,w]=u.useState({...F.DEFAULT_FILTER_POPOVER,isDescending:n.isDescending,searchString:n.searchString}),_=H.useDispatch(),I=ie.useLocation(),j=u.useCallback(async T=>{try{const d=(l?await z.getStudentFilter(p):await z.getFilterRosterUser({...p,byStudent:T})).data?.items||[];c(d)}catch(L){_(s.setAlert({type:"danger",message:L.response?.data?.title||L.message}))}},[JSON.stringify(p),l]),C=u.useCallback((T,L,d,a)=>{E(T),w({...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("")},A=u.useCallback((T,L)=>{w({...p,searchBy:L,searchStringBy:T})},[JSON.stringify(p)]),k=u.useCallback((T,L)=>{L&&m?.({...n,[F.SearchBy[L]]:T})},[JSON.stringify(n)]);return u.useEffect(()=>{if(!I.pathname.includes("users/assign-student"))return;const T=d=>d.sort((a,y)=>a.localeCompare(y)),L=p.searchStringBy?.toLowerCase()||"";if(p.searchBy===F.SearchBy.Grade)c(F.GRADE);else{let d=[];switch(p.searchBy){case F.SearchBy.Name:j(!0);break;case F.SearchBy.Teacher:d=v?.map(r=>r.label).filter(Boolean)||[];break;case F.SearchBy.Assistant:d=S?.map(r=>r.label).filter(Boolean)||[];break;case F.SearchBy.Counselor:d=o?.map(r=>r.label).filter(Boolean)||[];break;case F.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=T(y);c(g)}},[JSON.stringify(p),v,S,o,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:A,handleChangeFilters:k}},he=({headers:e,filters:n,onChangeFilters:m,isStudentFilter:l,teacherOptions:v=[],assistantOptions:S=[],counselorOptions:o=[],secondaryTeacherOptions:x=[]})=>{const{popoverId:f,users:E,handleFilterIcon:i,handleCloseFilter:c,handleSearch:p,handleChangeFilters:w}=Fe({filters:n,onChangeFilters:m,isStudentFilter:l,teacherOptions:v,assistantOptions:S,counselorOptions:o,secondaryTeacherOptions:x}),_=Object.entries(n).filter(([C,b])=>b!==""&&!(Array.isArray(b)&&b.length===0)&&b!==null&&b!==void 0).map(([C])=>C),I=Object.entries(F.SearchBy).filter(([C,b])=>isNaN(Number(C))),j=_.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:c,onOpenFilter:i,onChangeFilters:m,onOptionsChange:w,isActive:typeof C.searchBy=="number"&&j.some(([b,A])=>A===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),c=document.createElement("a");c.href=i,c.download=`${n}_Users_Report.csv`,c.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 c=i.dateOfBirth!==s.DATE_MIN_VALUE?ae.differenceInCalendarYears(new Date,ae.parseISO(i.dateOfBirth)):"";return`${o(i.firstName)},${o(i.lastName)},${o(i.email)},${o(i.phoneNumber)},${c},${o(i.grade)},${o(i.appType||"")},${o(i.roles.join(", ").replace("SecondaryTeacher","SupportTeacher"))},${i.isActive?"Active":"Inactive"},${s.formatLocalTime(i?.createTime,"yyyy-MM-dd HH:mm")},${o(i.sourcedId)},${o(i.rosterUser?.status)},${o(i.rosterUser?.familyName)},${o(i.rosterUser?.middleName)},${o(i.rosterUser?.givenName)},${o(i.rosterUser?.email)},${o(i.rosterUser?.role)},${o(i.rosterUser?.grades)},${o(i.teachers)},${o(i.assistants)},${o(i.counselors)},${o(i.supportTeachers)},${o(i.eduTeachers)}`}).join(`
|
|
3
|
+
`);return`${F.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),c=document.createElement("a");c.href=i,c.download="Classcode.csv",c.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 c=(Array.isArray(x)?x:[]).filter(p=>p.roles&&p.roles.includes("Teacher")).map(p=>`${o(p.fullName)},${o(p.email)},${o(p?.assignCode||"")}`).join(`
|
|
5
|
+
`);return`${F.CSV_PREFIX}${f}${encodeURIComponent(c)}`},o=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),oe=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",ce={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(),[o,x]=u.useState([]),[f,E]=u.useState(ce),[i,c]=u.useState(),p=window.location.hostname,w=p.includes("isb")||p.includes("stage"),[_,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))},A=u.useCallback(async g=>{if(!m||!g)return;e(s.setLoading(!0));try{const R=new FormData;if(R.append("file",g,g.name),m=="allUser"){let $=(await g.text()).trim();const U=$.split(`
|
|
6
|
+
`).map(M=>M.trim()),B=U.findIndex(M=>M.split(",").includes("FirstName"));if(B===0)throw new Error("Invalid CSV: Missing header row.");$=U.slice(B).join(`
|
|
7
|
+
`);const P=re.parse($,{header:!0,skipEmptyLines:!0}),V=P.meta.fields,J=P.data;if(!V)throw new Error("Unable to determine header from CSV file");const G=20,q=[];for(let M=0;M<J.length;M+=G){const Q=J.slice(M,M+G),K=re.unparse({fields:V,data:Q});q.push(K)}for(let M=0;M<q.length;M++){const Q=new Blob([q[M]],{type:"text/csv"}),K=new FormData;K.append("file",Q,`students_chunk${M+1}.csv`),await He(K)}}else w?m=="classReflection"&&await oe(R):await Pe(R,m.toString());e(s.setAlert({type:"success",message:"Import CSV successfully"}))}catch(R){e(s.setAlert({type:"danger",message:R.response?.data?.title||R.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]),k=async g=>{if(!_){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(_,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="")},T=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 oe(h),e(s.setAlert({type:"success",message:"Import CSV successfully"})),E(ce)}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=>{c(g),C(g?.name||"")},a=()=>{if(!i){e(s.setAlert({type:"danger",message:"Select CSV to import"}));return}k(i)};return{isLoading:n,id:Z,setType:l,upload:A,initImportReflection:f,setInitImportReflection:E,onConfirm:T,CSVType:pe,dataFile:v,setDataFile:S,setArrStudent:x,arrStudent:o,isCheckDomainIBS:w,onChangeTeacher:L,uploadByTeacherId:k,setDataFileImportStudent:d,onUpLoadStudentFile:a,defaultTeacher:_,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:o,reDirectDetailPage:x,switchUser:f,handleSyncRosterUsers:E,rosterUserInfo:i,onSelectUser:c,userIds:p,onSelectAllUser:w,isCheckAll:_}=Ae(),{handleSendMultiUsers:I}=Je(),{upload:j}=qe(),{exportUsers:C,exportClassCodes:b}=Me(),{t:A}=Y.useTranslation(),k=()=>C(l),T=()=>b(l),L=[{name:"",isCenter:!0,onSelectAll:w,isCheckAll:_}].concat(F.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:A(`${Ye}`)}),t.jsxs(N.Row,{className:"my-2",children:[t.jsx(N.Col,{md:8,children:t.jsx(s.SearchBoxContainer,{text:A("create_user"),onClick:()=>x(),initValue:e||"",onSearch:d=>o({searchString:d}),placeholder:A("type_something_to_search_by_user_name")})}),t.jsxs(N.Col,{md:4,className:"d-flex justify-content-end align-items-center",children:[A("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:A("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(Le,{text:A("sync_roster_users"),onClick:E}),t.jsxs("button",{className:"btn btn-success d-flex align-items-center border-0 p-0",style:te,onClick:T,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:A("export_class_code_to_csv")})]}),t.jsxs("button",{className:"btn btn-success d-flex align-items-center border-0 p-0",style:te,onClick:k,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:A("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:o})}),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:()=>c(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:A})}),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:A("user")})})})]})]})})}),t.jsx(N.Col,{md:12,children:t.jsx(s.CustomPagination,{filters:l,totalRecordCount:m,changePageSize:d=>o({pageSize:d}),changePage:d=>o({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;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";const t=require("react/jsx-runtime"),N=require("reactstrap"),z=require("./userService-DIJrzbzO.js"),Y=require("react-i18next"),u=require("react"),H=require("react-redux"),ie=require("react-router-dom"),s=require("./index-zAGSNpMb.js"),F=require("./constants-DRKzJlEG.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(F.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:o}=Se(),x=m||"",[f,E]=u.useState([]),i=window.location.host.includes("-district"),c=H.useDispatch(),{t:p}=Y.useTranslation(),w=a=>{const y=f.find(g=>g==a);E(y?f.filter(g=>g!=a):f.concat([a]))},_=u.useMemo(()=>(l||[]).length>0&&(l||[]).every(a=>f.includes(a.id)),[l,f]),I=u.useCallback(()=>{if(_){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,_,f]),j=u.useCallback(async()=>{if(S.searchBy!==void 0&&S.searchByStrings!==void 0&&S.searchByStrings.length===0){c(s.setUserList({userList:[],totalItems:0}));return}c(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"));c(s.setUserList({userList:y,totalItems:g}))}catch(a){c(s.setAlert({type:"danger",message:a.response?.data?.title||a.message}))}c(s.setLoading(!1))},[c,S]),C=async()=>{c(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.");c(s.setModal({isOpen:!0,type:"success",message:y}))}catch(a){c(s.setModal({isOpen:!0,type:"danger",message:a.response?.data?.message||a.response?.data?.title||a.message}))}c(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:R,email:D}=r,$=[];R&&$.push(R),O&&$.push(O),h&&$.push(h),y.push($.join(" ")||""),y.push(D||"")}return y.join(" / ")};u.useEffect(()=>{document.title=Ce},[]),u.useEffect(()=>{o({...S,searchString:x})},[x]),u.useEffect(()=>{j()},[JSON.stringify(S)]);const A=u.useCallback(a=>{c(s.setModal({isOpen:!0,type:"warning",message:p("do_you_want_to_remove_this_user"),onConfirm:async()=>{c(s.setLoading(!0));try{await z.remove(a),c(s.setAlert({type:"success",message:"Remove user successfully"})),S.currentPage!==1?o({currentPage:1}):j()}catch(y){c(s.setAlert({type:"danger",message:y.response?.data?.title||y.message}))}c(s.setLoading(!1))}}))},[JSON.stringify(S)]),k=[{role:"Admin",path:Ee},{role:"Teacher",path:W},{role:"Assistant",path:W},{role:"Student",path:be},{role:"Parent",path:je},{role:"EduTeacher",path:_e},{role:"Counselor",path:W},{role:"SecondaryTeacher",path:W}],T=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||[],R=(a.data.appType||"").toUpperCase();r.length===0&&h.length===0&&O.length>0&&(R.includes("ES")&&!R.includes("MS")?h=O:R.includes("MS")&&!R.includes("ES")?r=O:(r=O,h=O));let D="MS",$="/home",U=!1;for(const{role:V,path:J}of k){const G=r.includes(V),q=h.includes(V);if(!(!G&&!q)){D=G?"MS":"ES",$=J,U=!0;break}}U||(D=r.length>0?"MS":h.length>0?"ES":"MS");const B=D==="ES"?h:r;y?sessionStorage.setItem(s.ACCESS_TOKEN,g):localStorage.setItem(s.ACCESS_TOKEN,g),B.includes("Admin")?localStorage.setItem("ROLES","Admin"):B.length>0&&localStorage.setItem("ROLES",B.toString()),localStorage.removeItem(s.NOTIFICATION_ALERT_KEY),i&&($=Ne);const P=D==="ES"&&!B.includes("Admin")?`/es${$}`:$;window.location.href=P},L=u.useCallback(async a=>{try{const g=(await z.switchAccountUser(a)).data;c(s.setModal({isOpen:!0,type:"warning",message:p("do_you_want_to_impersonate_this_user"),onConfirm:async()=>{c(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 R=0;R<localStorage.length;R++){const D=localStorage.key(R);D&&(D==="SELECTED_TIER"||D.startsWith("SELECTED_TIER_"))&&(O[D]=localStorage.getItem(D)||"")}localStorage.clear(),Object.keys(O).forEach(R=>{localStorage.setItem(R,O[R])}),T(h)}catch(r){s.setAlert({type:"danger",message:r.response?.data?.title||r.message})}c(s.setLoading(!1))}}))}catch(y){c(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:A,changeFilters:o,reDirectDetailPage:a=>{const y=a?`${xe}/${a}`:ve;e(y)},switchUser:L,handleSyncRosterUsers:C,rosterUserInfo:b,userIds:f,onSelectAllUser:I,onSelectUser:w,isCheckAll:_}},Re={fontWeight:500},Ie={height:38,background:"#316cd9"},Le=({text:e,onClick:n,className:m=""})=>t.jsxs(N.Button,{onClick:n,color:"primary",style:Ie,className:`d-flex align-items-center ${m} gap-2`,children:[t.jsx(s.FaSyncAlt,{}),t.jsx("span",{style:Re,children:e})]});function Oe(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 Te(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:o,selectedOptions:x,searchKey:f,onChangeSearchKey:E,onOptionsChange:i,onSearch:c,onClose:p,onChangeFilters:w,getOption:_}=e,[I,j]=u.useState(),[C,b]=u.useState([]),A=u.useRef(null),k=u.useRef(null);Be(A,p);const{t:T}=Y.useTranslation(),L=u.useCallback(()=>{if(!n)return;const U=f?.trim?.()??"";S!=null&&!o&&c?.(U,S),S!=null&&o&&b(o.filter(B=>B.label.toLowerCase().includes(U.toLowerCase())))},[S,f,JSON.stringify(o),n]),d=()=>{k.current&&clearTimeout(k.current),k.current=setTimeout(L,500)},a=U=>{const B=U.target.value;E(B)},y=u.useCallback(()=>{i?.(I,S),p?.()},[JSON.stringify(I)]),g=u.useCallback(U=>{const B=U.target.value??"";let P=I??[],V=P.indexOf(B);V>-1?P.splice(V,1):P=[...P,B],j(P==null?P:[...P])},[JSON.stringify(I)]),r=u.useCallback(U=>{const B=U.target.checked;j(B?void 0:[])},[]),h=u.useCallback(()=>{w?.({...l,sortBy:m,isDescending:!0}),p?.()},[JSON.stringify(l),S]),O=u.useCallback(()=>{w?.({...l,sortBy:m,isDescending:!1}),p?.()},[JSON.stringify(l),S]),R=u.useMemo(()=>_?v.map(U=>_(U,T)):[],[JSON.stringify(v),JSON.stringify(_)]),D=l?.isDescending==!1&&l.sortBy===m,$=!!l?.isDescending&&l.sortBy===m;return u.useEffect(()=>{l?.searchBy!==S?j(void 0):j(x)},[JSON.stringify(x),l?.searchBy]),u.useEffect(()=>{b(o||[])},[JSON.stringify(o)]),u.useEffect(()=>{d()},[f,n]),{ref:A,options:R,inputRef:k,sOptions:I,isAscending:D,isDescending:$,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:o,sOptions:x,isAscending:f,isDescending:E,filteredOptions:i,searchKey:c,handleChangeSearchKey:p,handleApplyFilter:w,handleOptionSelected:_,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:c,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&&o.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:_,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:_,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:w,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:o,onSearch:x,onChangeFilters:f,onOpenFilter:E,onClose:i,isCenter:c,isActive:p=!1})=>{const{t:w}=Y.useTranslation(),[_,I]=u.useState(""),j=u.useMemo(()=>e.sortBy!=null?F.userOrders[e.sortBy]:"",[e.sortBy]),C=u.useMemo(()=>n===j,[j,n]),b=()=>{E?.(j,e.searchBy,_,e.sortBy)},A=k=>{I(k)};return t.jsx("th",{className:e.className,children:j&&e.sortBy!==void 0?t.jsxs("div",{className:`w-100 d-flex ${c?"justify-content-center":"justify-content-between"} align-items-center ${s.styles["table-filter-icon"]}`,children:[w(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(Te,{color:p?"#007bff":"#242424"}):t.jsx(Oe,{color:p?"#007bff":"#242424"})]}),t.jsx(De,{placement:"bottom-end",target:j,users:v,isOpen:C,filters:m,sortBy:e.sortBy,searchKey:_,searchBy:e.searchBy,searchString:l,defaultOptions:e.options,selectedOptions:S,onClose:i,onSearch:x,getOption:e.getOption,onChangeFilters:f,onOptionsChange:o,onChangeSearchKey:A})]}):w(e.name)})},Fe=e=>{const{filters:n,onChangeFilters:m,isStudentFilter:l,teacherOptions:v,assistantOptions:S,counselorOptions:o,secondaryTeacherOptions:x}=e,[f,E]=u.useState(),[i,c]=u.useState([]),[p,w]=u.useState({...F.DEFAULT_FILTER_POPOVER,isDescending:n.isDescending,searchString:n.searchString}),_=H.useDispatch(),I=ie.useLocation(),j=u.useCallback(async T=>{try{const d=(l?await z.getStudentFilter(p):await z.getFilterRosterUser({...p,byStudent:T})).data?.items||[];c(d)}catch(L){_(s.setAlert({type:"danger",message:L.response?.data?.title||L.message}))}},[JSON.stringify(p),l]),C=u.useCallback((T,L,d,a)=>{E(T),w({...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("")},A=u.useCallback((T,L)=>{w({...p,searchBy:L,searchStringBy:T})},[JSON.stringify(p)]),k=u.useCallback((T,L)=>{L&&m?.({...n,[F.SearchBy[L]]:T})},[JSON.stringify(n)]);return u.useEffect(()=>{if(!I.pathname.includes("users/assign-student"))return;const T=d=>d.sort((a,y)=>a.localeCompare(y)),L=p.searchStringBy?.toLowerCase()||"";if(p.searchBy===F.SearchBy.Grade)c(F.GRADE);else{let d=[];switch(p.searchBy){case F.SearchBy.Name:j(!0);break;case F.SearchBy.Teacher:d=v?.map(r=>r.label).filter(Boolean)||[];break;case F.SearchBy.Assistant:d=S?.map(r=>r.label).filter(Boolean)||[];break;case F.SearchBy.Counselor:d=o?.map(r=>r.label).filter(Boolean)||[];break;case F.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=T(y);c(g)}},[JSON.stringify(p),v,S,o,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:A,handleChangeFilters:k}},he=({headers:e,filters:n,onChangeFilters:m,isStudentFilter:l,teacherOptions:v=[],assistantOptions:S=[],counselorOptions:o=[],secondaryTeacherOptions:x=[]})=>{const{popoverId:f,users:E,handleFilterIcon:i,handleCloseFilter:c,handleSearch:p,handleChangeFilters:w}=Fe({filters:n,onChangeFilters:m,isStudentFilter:l,teacherOptions:v,assistantOptions:S,counselorOptions:o,secondaryTeacherOptions:x}),_=Object.entries(n).filter(([C,b])=>b!==""&&!(Array.isArray(b)&&b.length===0)&&b!==null&&b!==void 0).map(([C])=>C),I=Object.entries(F.SearchBy).filter(([C,b])=>isNaN(Number(C))),j=_.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:c,onOpenFilter:i,onChangeFilters:m,onOptionsChange:w,isActive:typeof C.searchBy=="number"&&j.some(([b,A])=>A===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),c=document.createElement("a");c.href=i,c.download=`${n}_Users_Report.csv`,c.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 c=i.dateOfBirth!==s.DATE_MIN_VALUE?ae.differenceInCalendarYears(new Date,ae.parseISO(i.dateOfBirth)):"";return`${o(i.firstName)},${o(i.lastName)},${o(i.email)},${o(i.phoneNumber)},${c},${o(i.grade)},${o(i.appType||"")},${o(i.roles.join(", ").replace("SecondaryTeacher","SupportTeacher"))},${i.isActive?"Active":"Inactive"},${s.formatLocalTime(i?.createTime,"yyyy-MM-dd HH:mm")},${o(i.sourcedId)},${o(i.rosterUser?.status)},${o(i.rosterUser?.familyName)},${o(i.rosterUser?.middleName)},${o(i.rosterUser?.givenName)},${o(i.rosterUser?.email)},${o(i.rosterUser?.role)},${o(i.rosterUser?.grades)},${o(i.teachers)},${o(i.assistants)},${o(i.counselors)},${o(i.supportTeachers)},${o(i.eduTeachers)}`}).join(`
|
|
3
|
+
`);return`${F.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),c=document.createElement("a");c.href=i,c.download="Classcode.csv",c.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 c=(Array.isArray(x)?x:[]).filter(p=>p.roles&&p.roles.includes("Teacher")).map(p=>`${o(p.fullName)},${o(p.email)},${o(p?.assignCode||"")}`).join(`
|
|
5
|
+
`);return`${F.CSV_PREFIX}${f}${encodeURIComponent(c)}`},o=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),oe=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",ce={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(),[o,x]=u.useState([]),[f,E]=u.useState(ce),[i,c]=u.useState(),p=window.location.hostname,w=p.includes("isb")||p.includes("stage"),[_,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))},A=u.useCallback(async g=>{if(!m||!g)return;e(s.setLoading(!0));try{const R=new FormData;if(R.append("file",g,g.name),m=="allUser"){let $=(await g.text()).trim();const U=$.split(`
|
|
6
|
+
`).map(M=>M.trim()),B=U.findIndex(M=>M.split(",").includes("FirstName"));if(B===0)throw new Error("Invalid CSV: Missing header row.");$=U.slice(B).join(`
|
|
7
|
+
`);const P=re.parse($,{header:!0,skipEmptyLines:!0}),V=P.meta.fields,J=P.data;if(!V)throw new Error("Unable to determine header from CSV file");const G=20,q=[];for(let M=0;M<J.length;M+=G){const Q=J.slice(M,M+G),K=re.unparse({fields:V,data:Q});q.push(K)}for(let M=0;M<q.length;M++){const Q=new Blob([q[M]],{type:"text/csv"}),K=new FormData;K.append("file",Q,`students_chunk${M+1}.csv`),await He(K)}}else w?m=="classReflection"&&await oe(R):await Pe(R,m.toString());e(s.setAlert({type:"success",message:"Import CSV successfully"}))}catch(R){e(s.setAlert({type:"danger",message:R.response?.data?.title||R.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]),k=async g=>{if(!_){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(_,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="")},T=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 oe(h),e(s.setAlert({type:"success",message:"Import CSV successfully"})),E(ce)}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=>{c(g),C(g?.name||"")},a=()=>{if(!i){e(s.setAlert({type:"danger",message:"Select CSV to import"}));return}k(i)};return{isLoading:n,id:Z,setType:l,upload:A,initImportReflection:f,setInitImportReflection:E,onConfirm:T,CSVType:pe,dataFile:v,setDataFile:S,setArrStudent:x,arrStudent:o,isCheckDomainIBS:w,onChangeTeacher:L,uploadByTeacherId:k,setDataFileImportStudent:d,onUpLoadStudentFile:a,defaultTeacher:_,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:o,reDirectDetailPage:x,switchUser:f,handleSyncRosterUsers:E,rosterUserInfo:i,onSelectUser:c,userIds:p,onSelectAllUser:w,isCheckAll:_}=Ae(),{handleSendMultiUsers:I}=Je(),{upload:j}=qe(),{exportUsers:C,exportClassCodes:b}=Me(),{t:A}=Y.useTranslation(),k=()=>C(l),T=()=>b(l),L=[{name:"",isCenter:!0,onSelectAll:w,isCheckAll:_}].concat(F.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:A(`${Ye}`)}),t.jsxs(N.Row,{className:"my-2",children:[t.jsx(N.Col,{md:8,children:t.jsx(s.SearchBoxContainer,{text:A("create_user"),onClick:()=>x(),initValue:e||"",onSearch:d=>o({searchString:d}),placeholder:A("type_something_to_search_by_user_name")})}),t.jsxs(N.Col,{md:4,className:"d-flex justify-content-end align-items-center",children:[A("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:A("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(Le,{text:A("sync_roster_users"),onClick:E}),t.jsxs("button",{className:"btn btn-success d-flex align-items-center border-0 p-0",style:te,onClick:T,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:A("export_class_code_to_csv")})]}),t.jsxs("button",{className:"btn btn-success d-flex align-items-center border-0 p-0",style:te,onClick:k,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:A("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:o})}),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:()=>c(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:A})}),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:A("user")})})})]})]})})}),t.jsx(N.Col,{md:12,children:t.jsx(s.CustomPagination,{filters:l,totalRecordCount:m,changePageSize:d=>o({pageSize:d}),changePage:d=>o({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;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";const t=require("react/jsx-runtime"),N=require("reactstrap"),z=require("./userService-MYXpUjgd.js"),Y=require("react-i18next"),u=require("react"),H=require("react-redux"),ie=require("react-router-dom"),s=require("./index-g0i4I-UC.js"),F=require("./constants-fG8OJgka.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(F.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:o}=Se(),x=m||"",[f,E]=u.useState([]),i=window.location.host.includes("-district"),c=H.useDispatch(),{t:p}=Y.useTranslation(),w=a=>{const y=f.find(g=>g==a);E(y?f.filter(g=>g!=a):f.concat([a]))},_=u.useMemo(()=>(l||[]).length>0&&(l||[]).every(a=>f.includes(a.id)),[l,f]),I=u.useCallback(()=>{if(_){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,_,f]),j=u.useCallback(async()=>{if(S.searchBy!==void 0&&S.searchByStrings!==void 0&&S.searchByStrings.length===0){c(s.setUserList({userList:[],totalItems:0}));return}c(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"));c(s.setUserList({userList:y,totalItems:g}))}catch(a){c(s.setAlert({type:"danger",message:a.response?.data?.title||a.message}))}c(s.setLoading(!1))},[c,S]),C=async()=>{c(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.");c(s.setModal({isOpen:!0,type:"success",message:y}))}catch(a){c(s.setModal({isOpen:!0,type:"danger",message:a.response?.data?.message||a.response?.data?.title||a.message}))}c(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:R,email:D}=r,$=[];R&&$.push(R),O&&$.push(O),h&&$.push(h),y.push($.join(" ")||""),y.push(D||"")}return y.join(" / ")};u.useEffect(()=>{document.title=Ce},[]),u.useEffect(()=>{o({...S,searchString:x})},[x]),u.useEffect(()=>{j()},[JSON.stringify(S)]);const A=u.useCallback(a=>{c(s.setModal({isOpen:!0,type:"warning",message:p("do_you_want_to_remove_this_user"),onConfirm:async()=>{c(s.setLoading(!0));try{await z.remove(a),c(s.setAlert({type:"success",message:"Remove user successfully"})),S.currentPage!==1?o({currentPage:1}):j()}catch(y){c(s.setAlert({type:"danger",message:y.response?.data?.title||y.message}))}c(s.setLoading(!1))}}))},[JSON.stringify(S)]),k=[{role:"Admin",path:Ee},{role:"Teacher",path:W},{role:"Assistant",path:W},{role:"Student",path:be},{role:"Parent",path:je},{role:"EduTeacher",path:_e},{role:"Counselor",path:W},{role:"SecondaryTeacher",path:W}],T=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||[],R=(a.data.appType||"").toUpperCase();r.length===0&&h.length===0&&O.length>0&&(R.includes("ES")&&!R.includes("MS")?h=O:R.includes("MS")&&!R.includes("ES")?r=O:(r=O,h=O));let D="MS",$="/home",U=!1;for(const{role:V,path:J}of k){const G=r.includes(V),q=h.includes(V);if(!(!G&&!q)){D=G?"MS":"ES",$=J,U=!0;break}}U||(D=r.length>0?"MS":h.length>0?"ES":"MS");const B=D==="ES"?h:r;y?sessionStorage.setItem(s.ACCESS_TOKEN,g):localStorage.setItem(s.ACCESS_TOKEN,g),B.includes("Admin")?localStorage.setItem("ROLES","Admin"):B.length>0&&localStorage.setItem("ROLES",B.toString()),localStorage.removeItem(s.NOTIFICATION_ALERT_KEY),i&&($=Ne);const P=D==="ES"&&!B.includes("Admin")?`/es${$}`:$;window.location.href=P},L=u.useCallback(async a=>{try{const g=(await z.switchAccountUser(a)).data;c(s.setModal({isOpen:!0,type:"warning",message:p("do_you_want_to_impersonate_this_user"),onConfirm:async()=>{c(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 R=0;R<localStorage.length;R++){const D=localStorage.key(R);D&&(D==="SELECTED_TIER"||D.startsWith("SELECTED_TIER_"))&&(O[D]=localStorage.getItem(D)||"")}localStorage.clear(),Object.keys(O).forEach(R=>{localStorage.setItem(R,O[R])}),T(h)}catch(r){s.setAlert({type:"danger",message:r.response?.data?.title||r.message})}c(s.setLoading(!1))}}))}catch(y){c(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:A,changeFilters:o,reDirectDetailPage:a=>{const y=a?`${xe}/${a}`:ve;e(y)},switchUser:L,handleSyncRosterUsers:C,rosterUserInfo:b,userIds:f,onSelectAllUser:I,onSelectUser:w,isCheckAll:_}},Re={fontWeight:500},Ie={height:38,background:"#316cd9"},Le=({text:e,onClick:n,className:m=""})=>t.jsxs(N.Button,{onClick:n,color:"primary",style:Ie,className:`d-flex align-items-center ${m} gap-2`,children:[t.jsx(s.FaSyncAlt,{}),t.jsx("span",{style:Re,children:e})]});function Oe(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 Te(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:o,selectedOptions:x,searchKey:f,onChangeSearchKey:E,onOptionsChange:i,onSearch:c,onClose:p,onChangeFilters:w,getOption:_}=e,[I,j]=u.useState(),[C,b]=u.useState([]),A=u.useRef(null),k=u.useRef(null);Be(A,p);const{t:T}=Y.useTranslation(),L=u.useCallback(()=>{if(!n)return;const U=f?.trim?.()??"";S!=null&&!o&&c?.(U,S),S!=null&&o&&b(o.filter(B=>B.label.toLowerCase().includes(U.toLowerCase())))},[S,f,JSON.stringify(o),n]),d=()=>{k.current&&clearTimeout(k.current),k.current=setTimeout(L,500)},a=U=>{const B=U.target.value;E(B)},y=u.useCallback(()=>{i?.(I,S),p?.()},[JSON.stringify(I)]),g=u.useCallback(U=>{const B=U.target.value??"";let P=I??[],V=P.indexOf(B);V>-1?P.splice(V,1):P=[...P,B],j(P==null?P:[...P])},[JSON.stringify(I)]),r=u.useCallback(U=>{const B=U.target.checked;j(B?void 0:[])},[]),h=u.useCallback(()=>{w?.({...l,sortBy:m,isDescending:!0}),p?.()},[JSON.stringify(l),S]),O=u.useCallback(()=>{w?.({...l,sortBy:m,isDescending:!1}),p?.()},[JSON.stringify(l),S]),R=u.useMemo(()=>_?v.map(U=>_(U,T)):[],[JSON.stringify(v),JSON.stringify(_)]),D=l?.isDescending==!1&&l.sortBy===m,$=!!l?.isDescending&&l.sortBy===m;return u.useEffect(()=>{l?.searchBy!==S?j(void 0):j(x)},[JSON.stringify(x),l?.searchBy]),u.useEffect(()=>{b(o||[])},[JSON.stringify(o)]),u.useEffect(()=>{d()},[f,n]),{ref:A,options:R,inputRef:k,sOptions:I,isAscending:D,isDescending:$,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:o,sOptions:x,isAscending:f,isDescending:E,filteredOptions:i,searchKey:c,handleChangeSearchKey:p,handleApplyFilter:w,handleOptionSelected:_,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:c,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&&o.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:_,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:_,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:w,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:o,onSearch:x,onChangeFilters:f,onOpenFilter:E,onClose:i,isCenter:c,isActive:p=!1})=>{const{t:w}=Y.useTranslation(),[_,I]=u.useState(""),j=u.useMemo(()=>e.sortBy!=null?F.userOrders[e.sortBy]:"",[e.sortBy]),C=u.useMemo(()=>n===j,[j,n]),b=()=>{E?.(j,e.searchBy,_,e.sortBy)},A=k=>{I(k)};return t.jsx("th",{className:e.className,children:j&&e.sortBy!==void 0?t.jsxs("div",{className:`w-100 d-flex ${c?"justify-content-center":"justify-content-between"} align-items-center ${s.styles["table-filter-icon"]}`,children:[w(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(Te,{color:p?"#007bff":"#242424"}):t.jsx(Oe,{color:p?"#007bff":"#242424"})]}),t.jsx(De,{placement:"bottom-end",target:j,users:v,isOpen:C,filters:m,sortBy:e.sortBy,searchKey:_,searchBy:e.searchBy,searchString:l,defaultOptions:e.options,selectedOptions:S,onClose:i,onSearch:x,getOption:e.getOption,onChangeFilters:f,onOptionsChange:o,onChangeSearchKey:A})]}):w(e.name)})},Fe=e=>{const{filters:n,onChangeFilters:m,isStudentFilter:l,teacherOptions:v,assistantOptions:S,counselorOptions:o,secondaryTeacherOptions:x}=e,[f,E]=u.useState(),[i,c]=u.useState([]),[p,w]=u.useState({...F.DEFAULT_FILTER_POPOVER,isDescending:n.isDescending,searchString:n.searchString}),_=H.useDispatch(),I=ie.useLocation(),j=u.useCallback(async T=>{try{const d=(l?await z.getStudentFilter(p):await z.getFilterRosterUser({...p,byStudent:T})).data?.items||[];c(d)}catch(L){_(s.setAlert({type:"danger",message:L.response?.data?.title||L.message}))}},[JSON.stringify(p),l]),C=u.useCallback((T,L,d,a)=>{E(T),w({...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("")},A=u.useCallback((T,L)=>{w({...p,searchBy:L,searchStringBy:T})},[JSON.stringify(p)]),k=u.useCallback((T,L)=>{L&&m?.({...n,[F.SearchBy[L]]:T})},[JSON.stringify(n)]);return u.useEffect(()=>{if(!I.pathname.includes("users/assign-student"))return;const T=d=>d.sort((a,y)=>a.localeCompare(y)),L=p.searchStringBy?.toLowerCase()||"";if(p.searchBy===F.SearchBy.Grade)c(F.GRADE);else{let d=[];switch(p.searchBy){case F.SearchBy.Name:j(!0);break;case F.SearchBy.Teacher:d=v?.map(r=>r.label).filter(Boolean)||[];break;case F.SearchBy.Assistant:d=S?.map(r=>r.label).filter(Boolean)||[];break;case F.SearchBy.Counselor:d=o?.map(r=>r.label).filter(Boolean)||[];break;case F.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=T(y);c(g)}},[JSON.stringify(p),v,S,o,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:A,handleChangeFilters:k}},he=({headers:e,filters:n,onChangeFilters:m,isStudentFilter:l,teacherOptions:v=[],assistantOptions:S=[],counselorOptions:o=[],secondaryTeacherOptions:x=[]})=>{const{popoverId:f,users:E,handleFilterIcon:i,handleCloseFilter:c,handleSearch:p,handleChangeFilters:w}=Fe({filters:n,onChangeFilters:m,isStudentFilter:l,teacherOptions:v,assistantOptions:S,counselorOptions:o,secondaryTeacherOptions:x}),_=Object.entries(n).filter(([C,b])=>b!==""&&!(Array.isArray(b)&&b.length===0)&&b!==null&&b!==void 0).map(([C])=>C),I=Object.entries(F.SearchBy).filter(([C,b])=>isNaN(Number(C))),j=_.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:c,onOpenFilter:i,onChangeFilters:m,onOptionsChange:w,isActive:typeof C.searchBy=="number"&&j.some(([b,A])=>A===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),c=document.createElement("a");c.href=i,c.download=`${n}_Users_Report.csv`,c.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 c=i.dateOfBirth!==s.DATE_MIN_VALUE?ae.differenceInCalendarYears(new Date,ae.parseISO(i.dateOfBirth)):"";return`${o(i.firstName)},${o(i.lastName)},${o(i.email)},${o(i.phoneNumber)},${c},${o(i.grade)},${o(i.appType||"")},${o(i.roles.join(", ").replace("SecondaryTeacher","SupportTeacher"))},${i.isActive?"Active":"Inactive"},${s.formatLocalTime(i?.createTime,"yyyy-MM-dd HH:mm")},${o(i.sourcedId)},${o(i.rosterUser?.status)},${o(i.rosterUser?.familyName)},${o(i.rosterUser?.middleName)},${o(i.rosterUser?.givenName)},${o(i.rosterUser?.email)},${o(i.rosterUser?.role)},${o(i.rosterUser?.grades)},${o(i.teachers)},${o(i.assistants)},${o(i.counselors)},${o(i.supportTeachers)},${o(i.eduTeachers)}`}).join(`
|
|
3
|
+
`);return`${F.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),c=document.createElement("a");c.href=i,c.download="Classcode.csv",c.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 c=(Array.isArray(x)?x:[]).filter(p=>p.roles&&p.roles.includes("Teacher")).map(p=>`${o(p.fullName)},${o(p.email)},${o(p?.assignCode||"")}`).join(`
|
|
5
|
+
`);return`${F.CSV_PREFIX}${f}${encodeURIComponent(c)}`},o=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),oe=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",ce={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(),[o,x]=u.useState([]),[f,E]=u.useState(ce),[i,c]=u.useState(),p=window.location.hostname,w=p.includes("isb")||p.includes("stage"),[_,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))},A=u.useCallback(async g=>{if(!m||!g)return;e(s.setLoading(!0));try{const R=new FormData;if(R.append("file",g,g.name),m=="allUser"){let $=(await g.text()).trim();const U=$.split(`
|
|
6
|
+
`).map(M=>M.trim()),B=U.findIndex(M=>M.split(",").includes("FirstName"));if(B===0)throw new Error("Invalid CSV: Missing header row.");$=U.slice(B).join(`
|
|
7
|
+
`);const P=re.parse($,{header:!0,skipEmptyLines:!0}),V=P.meta.fields,J=P.data;if(!V)throw new Error("Unable to determine header from CSV file");const G=20,q=[];for(let M=0;M<J.length;M+=G){const Q=J.slice(M,M+G),K=re.unparse({fields:V,data:Q});q.push(K)}for(let M=0;M<q.length;M++){const Q=new Blob([q[M]],{type:"text/csv"}),K=new FormData;K.append("file",Q,`students_chunk${M+1}.csv`),await He(K)}}else w?m=="classReflection"&&await oe(R):await Pe(R,m.toString());e(s.setAlert({type:"success",message:"Import CSV successfully"}))}catch(R){e(s.setAlert({type:"danger",message:R.response?.data?.title||R.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]),k=async g=>{if(!_){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(_,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="")},T=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 oe(h),e(s.setAlert({type:"success",message:"Import CSV successfully"})),E(ce)}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=>{c(g),C(g?.name||"")},a=()=>{if(!i){e(s.setAlert({type:"danger",message:"Select CSV to import"}));return}k(i)};return{isLoading:n,id:Z,setType:l,upload:A,initImportReflection:f,setInitImportReflection:E,onConfirm:T,CSVType:pe,dataFile:v,setDataFile:S,setArrStudent:x,arrStudent:o,isCheckDomainIBS:w,onChangeTeacher:L,uploadByTeacherId:k,setDataFileImportStudent:d,onUpLoadStudentFile:a,defaultTeacher:_,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:o,reDirectDetailPage:x,switchUser:f,handleSyncRosterUsers:E,rosterUserInfo:i,onSelectUser:c,userIds:p,onSelectAllUser:w,isCheckAll:_}=Ae(),{handleSendMultiUsers:I}=Je(),{upload:j}=qe(),{exportUsers:C,exportClassCodes:b}=Me(),{t:A}=Y.useTranslation(),k=()=>C(l),T=()=>b(l),L=[{name:"",isCenter:!0,onSelectAll:w,isCheckAll:_}].concat(F.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:A(`${Ye}`)}),t.jsxs(N.Row,{className:"my-2",children:[t.jsx(N.Col,{md:8,children:t.jsx(s.SearchBoxContainer,{text:A("create_user"),onClick:()=>x(),initValue:e||"",onSearch:d=>o({searchString:d}),placeholder:A("type_something_to_search_by_user_name")})}),t.jsxs(N.Col,{md:4,className:"d-flex justify-content-end align-items-center",children:[A("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:A("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(Le,{text:A("sync_roster_users"),onClick:E}),t.jsxs("button",{className:"btn btn-success d-flex align-items-center border-0 p-0",style:te,onClick:T,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:A("export_class_code_to_csv")})]}),t.jsxs("button",{className:"btn btn-success d-flex align-items-center border-0 p-0",style:te,onClick:k,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:A("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:o})}),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:()=>c(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:A})}),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:A("user")})})})]})]})})}),t.jsx(N.Col,{md:12,children:t.jsx(s.CustomPagination,{filters:l,totalRecordCount:m,changePageSize:d=>o({pageSize:d}),changePage:d=>o({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;
|