mario-core 2.0.6-stage → 2.0.7-stage
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/index.js +1 -1
- package/dist/index.modern.js +19 -19
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
searchreplace visualblocks code fullscreen
|
|
7
7
|
insertdatetime media table paste code help wordcount media`,toolbar:"undo redo | formatselect | bold italic backcolor | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | removeformat | image",paste_data_images:!0},dN_={...Ys,images_upload_handler:async function(e,t){const _=new FormData;_.append("file",e.blob(),e.filename());try{const{data:o}=await Ri(_);t(o_(o.key))}catch{return}}},uN_={...Ys,images_upload_handler:async function(e,t){const _=new FormData;_.append("file",e.blob(),e.filename());try{const{data:o}=await oN_(_);t(o_(o.key))}catch{return}}},hN_={...Ys,height:Ln,images_upload_handler:async function(e,t){const _=new FormData;_.append("file",e.blob(),e.filename());try{const{data:o}=await aN_(_);t(o_(o.key))}catch{return}}},mN_={...Ys,height:Ln,media_live_embeds:!0,plugins:`advlist autolink lists link image charmap print preview anchor
|
|
8
8
|
searchreplace visualblocks code fullscreen
|
|
9
|
-
insertdatetime media table paste code help wordcount media`,toolbar:"undo redo | formatselect | bold italic backcolor | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | removeformat | image | media",images_upload_handler:async function(e,t){const _=new FormData;_.append("file",e.blob(),e.filename());try{const{data:o}=await Eo(_);t(o_(o.key))}catch{return}},file_picker_callback:function(e){var t=document.createElement("input");t.setAttribute("type","file"),t.setAttribute("accept","video/*"),t.onchange=async function(_){const o=_.target.files[0],{name:s}=o,c=new FormData;c.append("file",o,s);const{data:u}=await Eo(c);e(o_(u.key))},t.click()}},Mi={email:dN_,question:uN_,answer:hN_,tutorial:mN_},gN_={id:0,subject:"",categoryId:0,body:"",attachments:[]},pN_="/admin/email-template",yN_="Email template detail",fN_=4194304,wN_=e=>{let t;const _=Ee.useDispatch(),o=Ct.useNavigate(),[s,c]=v.useState(gN_),[u,g]=v.useState(!1),d=async()=>{localStorage.setItem(window.location.href,"true"),g(!0)},[p,x]=v.useState([]),[f,A]=v.useState([]),[T,q]=v.useState("");v.useEffect(()=>{e&&E()},[e]);const E=v.useCallback(async()=>{_(se(!0));try{const J=await Ij_(e);c({id:J.data.id,subject:J.data.subject,categoryId:J.data.category.id,body:J.data.body,attachments:J.data.attachments||[]}),document.title=J.data.subject,t&&t.editor.execCommand("mceSetContent",!1,J.data.body)}catch(J){_(Q({type:"danger",message:J.response?.data?.title||J.message}))}_(se(!1))},[e]),k=async()=>{_(se(!0));try{const F=(await jj_()).data;F&&q(F.key)}catch(J){_(Q({type:"danger",message:J.response?.data?.title||"Get key failed"}))}_(se(!1))},C=J=>t=J,N=J=>{t&&t.editor.execCommand("mceInsertContent",!1,` ${J.label}`)},P=v.useCallback(()=>{o(pN_)},[]),D=v.useCallback(async J=>{_(se(!0));try{if(f&&f.length){const L=(await H()).map(Z=>({key:Z.data.key,name:Z.data.name}));J.attachments=[...J.attachments,...L]}await(e?Ej_:Aj_)(J),_(Q({type:"success",message:`${e?"Update":"Create"} template successfully`})),P()}catch(F){_(Q({type:"danger",message:F.response?.data?.title||F.message}))}_(se(!1))},[e,f]),B=()=>{const J=document.getElementsByClassName("input-attachment"),F=document.createElement("input");document.getElementById("email-detail")?.append(F),F.className="input-attachment",F.id=`inputAttachment-${J.length+1}`,F.type="file",F.style.display="none",F.setAttribute("multiple","multiple"),F.addEventListener("change",R),F.click()},R=()=>{const J=[];let F=0;const z=document.getElementsByClassName("input-attachment");for(const L of z)for(const Z of L.files)F+=Z.size,F>fN_&&(_(Q({type:"danger",message:"Max attachment size is 4MB"})),F-=Z.size,L.remove());for(const L of z)for(const Z of L.files){const{name:ne}=Z;!p.includes(Z)&&!J.some(de=>de.name===ne)&&J.push({name:ne,inputId:L.id})}A(J)},W=(J,F)=>{if(f.filter(z=>z.inputId===J).length===1){document.getElementById(J)?.remove();let L=f.filter(Z=>Z.inputId===J);f.filter(Z=>Z.inputId!==L.inputId),p.push(L),x([...p]),A([...f]);return}x([...p,F])};v.useEffect(()=>{R()},[p]);const H=async()=>{const J=document.getElementsByClassName("input-attachment"),F=[];for(const z of J)for(const L of z.files){const{name:Z}=L,ne=new FormData;ne.append("file",L,Z),F.push(Ri(ne))}return Promise.all(F)};return v.useEffect(()=>{document.title=yN_,k(),g(!1),localStorage.getItem(window.location.href)&&localStorage.removeItem(window.location.href)},[]),{emailTemplateDetail:s,setEditorRef:C,addParams:N,backToList:P,confirmData:D,edited:u,setEdited:g,setEditedTrue:d,onAttachFile:B,updateAttachment:R,fileUpload:f,removeAttachment:W,tinyMCEKey:T}},vN_=ct.object({subject:ct.string().required("Template subject is required"),categoryId:ct.number().required("Template category is required").test("test category id","Template category is required",e=>e>=1),comment:ct.string(),body:ct.string().required("Template body is required")}),bN_="create_email_template",$N_="edit_email_template",kN_=()=>{const{id:e}=Ct.useParams(),{t}=at.useTranslation(),{emailTemplateDetail:_,setEditorRef:o,addParams:s,backToList:c,confirmData:u,edited:g,setEdited:d,setEditedTrue:p,onAttachFile:x,fileUpload:f,removeAttachment:A}=wN_(parseInt(e||"0")),T=t(e?$N_:bN_),q=t(e?"update":"create"),E=Ee.useSelector(k=>k.mailCategory.mailCategoryList);return n.jsx(d_.Formik,{initialValues:_,enableReinitialize:!0,validationSchema:vN_,onSubmit:k=>{u(k),d(!1),localStorage.getItem(window.location.href)&&localStorage.removeItem(window.location.href)},children:k=>{const{values:C,touched:N,errors:P,setFieldValue:D,handleChange:B,handleBlur:R,handleSubmit:W}=k;return n.jsxs("div",{className:"animated fadeIn detail-buttons-padding",id:"email-detail",children:[n.jsx(Us,{when:g}),n.jsx("h5",{className:"mb-2",style:{textTransform:"capitalize"},children:T}),n.jsxs(w.Row,{className:"my-2",children:[n.jsxs(w.Col,{md:8,children:[n.jsx(Ht,{text:t("mail_subject")}),n.jsx(w.Input,{placeholder:t("mail_subject_nm"),name:"subject",value:C.subject,onChange:H=>{B(H),p()},onBlur:R("subject"),className:"selector-input"}),N.subject&&P.subject&&n.jsx(Nt,{text:P.subject})]}),n.jsxs(w.Col,{md:4,children:[n.jsx(Ht,{text:t("category")}),n.jsx(Gj_,{onChange:H=>{D("categoryId",H.value),p()},id:C.categoryId}),N.categoryId&&P.categoryId&&n.jsx(Nt,{text:P.categoryId})]})]}),n.jsxs(w.Row,{className:"mb-2",children:[n.jsx(w.Col,{md:8,children:n.jsxs(w.Row,{children:[n.jsxs(w.Col,{md:12,className:"mb-2",children:[n.jsx(Ht,{text:t("mail_body")}),(_.body||!e)&&n.jsx(ld.Editor,{tinymceScriptSrc:"/tinymce/tinymce.min.js",ref:H=>o(H),initialValue:_.body,init:Mi.email,onEditorChange:H=>{D("body",H),p()}}),N.body&&P.body&&n.jsx(Nt,{text:P.body})]}),n.jsx(w.Col,{md:12,children:n.jsxs(w.Row,{children:[n.jsx(w.Col,{md:3,children:n.jsx(w.Button,{color:"link",size:"sm",className:"pl-0",onClick:x,children:t("add_attachment")})}),n.jsx(w.Col,{md:12,children:n.jsxs(w.Row,{children:[C.attachments.map(H=>n.jsx(w.Col,{md:2,children:n.jsx(Ao,{label:H.name,onRemove:()=>D("attachments",C.attachments.filter(J=>J.name!==H.name))})},H.key)),f.map((H,J)=>n.jsx(w.Col,{md:2,className:"d-flex align-items-center",children:n.jsx(Ao,{label:H.name,onRemove:()=>A(H.inputId,H.name)})},J))]})})]})})]})}),n.jsxs(w.Col,{md:4,children:[n.jsx(w.Label,{children:t("mail_params")}),n.jsx(Bj_,{onClick:H=>s(H),isResetPasswordTemplate:C.categoryId==(E&&E.length>0&&E.filter(H=>H.name=="Reset password")[0].id)})]})]}),n.jsx(Hn,{confirmText:q,onConfirm:W,onCancel:c})]})}})},xN_=(e,t)=>{const{header:_,children:o,onConfirm:s,onCancel:c,confirmText:u,cancelText:g,noFooter:d,size:p,edited:x,setEditedFalse:f}=e,[A,T]=v.useState(!1),q=Ee.useDispatch(),{t:E}=at.useTranslation(),k=D=>{try{q(Yt({isOpen:!0,type:"warning",message:"Are you sure to cancel?",onConfirm:async()=>{D()}}))}catch(B){q(Q({type:"danger",message:B.response?.data?.title||B.message}))}},C=()=>{f&&f(),T(!A),A&&c&&c()},N=v.useCallback((D,B)=>{D?k(()=>{C(),B&&B()}):(C(),B&&B())},[A]),P=v.useCallback(()=>{N(!!x,()=>{c&&c()})},[N,c,x]);return v.useImperativeHandle(t,()=>({toggle:N})),n.jsxs(w.Modal,{isOpen:A,toggle:()=>N(!!x),size:p,zIndex:1202,style:{marginTop:"8rem"},children:[n.jsx(w.ModalHeader,{toggle:()=>N(!!x),children:_}),n.jsx(w.ModalBody,{children:o}),!d&&n.jsxs(w.ModalFooter,{className:"text-right",children:[s&&n.jsx(w.Button,{color:"primary",onClick:s,children:u||E("confirm")}),n.jsx(w.Button,{onClick:P,children:g||E("cancel")})]})]})},Xs=v.forwardRef(xN_),Dt=({defaultValue:e,options:t,isDisabled:_,scrollBottom:o,...s})=>{const c=e!==null&&typeof e<"u"&&t.find(u=>u.value===e)||null;return n.jsx(u_,{isDisabled:_,options:t,value:c,menuPlacement:o?"top":"auto",...s})},ps=`${ft}/api/Skill`,Di=e=>he.get(ps,{params:e}),CN_=e=>he.get(`${ps}/${e}`),SN_=e=>he.post(ps,e),IN_=e=>he.put(`${ps}/${e.id}`,e),AN_=e=>he.delete(`${ps}/${e}`),EN_=e=>{const[t,_]=v.useState([]);v.useEffect(()=>{o()},[]);const o=async()=>{try{const g=await Di();_(g.data.items)}catch(g){console.error(g.message)}},{id:s,isDisabled:c}=e,u=t.map(g=>({id:g.id,value:g.id,label:g.path?`${g.path}/${g.name}`:g.name}));return n.jsx(Dt,{options:u,defaultValue:s,...e,isDisabled:c})},TN_=ct.object({name:ct.string().required("Name is required"),description:ct.string()}),jN_=(e,t)=>{const{header:_,confirmText:o,onConfirm:s,skillDetail:c,onCancel:u,edited:g,setEdited:d,setEditedTrue:p,setEditedFalse:x,isDisabled:f}=e,{t:A}=at.useTranslation();return n.jsx(d_.Formik,{initialValues:c,enableReinitialize:!0,validationSchema:TN_,onSubmit:(T,q)=>{s(T),q.resetForm()},children:T=>{const{values:q,touched:E,errors:k,handleChange:C,handleBlur:N,handleSubmit:P,resetForm:D}=T;return n.jsx(Xs,{header:_,confirmText:o,onConfirm:P,ref:t,onCancel:()=>{u(),D()},edited:g,setEdited:d,setEditedFalse:x,children:n.jsxs(w.Row,{children:[n.jsxs(w.Col,{md:12,className:"mb-2",children:[n.jsx(Ht,{text:A("name")}),n.jsx(w.Input,{name:"name",placeholder:A("name"),value:q.name,onChange:B=>{C(B),p()},onBlur:N("name")}),E.name&&k.name&&n.jsx(Nt,{text:k.name})]}),n.jsxs(w.Col,{md:12,className:"mb-2",children:[n.jsx(w.Label,{children:A("description")}),n.jsx(w.Input,{type:"textarea",rows:5,name:"description",placeholder:A("description"),value:q.description,onChange:B=>{C(B),p()},onBlur:N("description")})]}),n.jsxs(w.Col,{md:12,className:"mb-2",children:[n.jsx(w.Label,{children:A("parent_category")}),n.jsx(EN_,{isDisabled:f,onChange:B=>{T.setFieldValue("parentSkillId",B.value),p()},id:q.parentSkillId})]})]})})}})},NN_=v.forwardRef(jN_),Oi=K.createAction("skills/setSkillList"),qN_="Skill list",PN_=()=>{const e=Ee.useSelector(d=>d.skills.skillList),t=Ee.useSelector(d=>d.skills.totalItems),{t:_}=at.useTranslation(),{filters:o,changeFilters:s}=Ws(),c=Ee.useDispatch(),u=v.useCallback(async()=>{c(se(!0));try{const d=await Di(o),{items:p,totalItems:x}=d.data;c(Oi({skillList:p,totalItems:x}))}catch(d){c(Q({type:"danger",message:d.response?.data?.title||d.message}))}c(se(!1))},[c,o]),g=v.useCallback(d=>{c(se(!0));try{c(Yt({isOpen:!0,type:"warning",message:_("do_you_want_to_remove_this_skill"),onConfirm:async()=>{try{await AN_(d),c(Q({type:"success",message:_("remove_skill_successfully")})),s({currentPage:1})}catch(p){c(Q({type:"danger",message:p.response?.data?.title||p.message||"Error occured"}))}}}))}catch(p){c(Q({type:"danger",message:p.response?.data?.title||p.message||"Error occured"}))}c(se(!1))},[o]);return v.useEffect(()=>{document.title=qN_},[]),v.useEffect(()=>{u()},[o]),{skillList:e,totalItems:t,filters:o,changeFilters:s,getData:u,removeData:g}},ks={name:"",description:"",path:"",parentSkillId:null},RN_=()=>{const e=Ee.useDispatch(),[t,_]=v.useState(0),[o,s]=v.useState(ks),[c,u]=v.useState(!1),g=async()=>{localStorage.setItem(window.location.href,"true"),u(!0)},d=async()=>{localStorage.getItem(window.location.href)&&localStorage.removeItem(window.location.href),u(!1)};v.useEffect(()=>{t?x():s(ks)},[t]);const p=()=>{_(0),s(ks)};v.useEffect(()=>{d()},[]);const x=v.useCallback(async()=>{e(se(!0));try{const A=await CN_(t);s(A.data)}catch(A){e(Q({type:"danger",message:A.response?.data?.title||A.message}))}e(se(!1))},[t]),f=v.useCallback(async(A,T)=>{e(se(!0));try{await(t?IN_:SN_)(A),e(Q({type:"success",message:`${t?"Update":"Create"} skill successfully`})),T&&T(),t&&_(0)}catch(q){e(Q({type:"danger",message:q.response?.data?.title||q.message}))}e(se(!1))},[t,o]);return{id:t,setId:_,skillDetail:o,confirmData:f,initValue:ks,reset:p,edited:c,setEdited:u,setEditedTrue:g,setEditedFalse:d}},LN_=()=>{const e=v.useRef(null),{t}=at.useTranslation(),{skillList:_,totalItems:o,filters:s,changeFilters:c,getData:u,removeData:g}=PN_(),{id:d,setId:p,skillDetail:x,confirmData:f,reset:A,edited:T,setEdited:q,setEditedTrue:E,setEditedFalse:k}=RN_(),C=B=>{p(B||0),e&&e.current&&e.current.toggle()},N=B=>{f(B,()=>{e&&e.current&&e.current.toggle(),u()}),k()},P=B=>{g(B)},D=()=>A();return n.jsxs("div",{className:"fadeIn animated",children:[n.jsx(NN_,{ref:e,header:t(d?"edit_skill":"create_skill"),confirmText:t(d?"update":"create"),onCancel:D,onConfirm:N,skillDetail:x,edited:T,setEdited:q,setEditedTrue:E,setEditedFalse:k,isDisabled:d}),n.jsx(Us,{when:T}),n.jsxs(w.Row,{className:"my-2",children:[n.jsx(w.Col,{md:4,children:n.jsx(zs,{text:t("create_skill"),onClick:()=>C()})}),n.jsxs(w.Col,{md:4,className:"d-flex align-items-center justify-content-end",children:[t("total_of_skills"),": ",o]})]}),n.jsxs(w.Row,{className:"mb-2",children:[n.jsx(w.Col,{md:8,children:_&&_.length>0?n.jsxs(w.Table,{bordered:!0,hover:!0,striped:!0,responsive:!0,size:"sm",children:[n.jsx("thead",{children:n.jsxs("tr",{children:[n.jsx("th",{className:"align-top",children:t("name")}),n.jsx("th",{className:"align-top",children:t("description")}),n.jsx("th",{className:"text-center",children:t("action")})]})}),n.jsx("tbody",{children:_.map(B=>n.jsxs("tr",{children:[n.jsxs("td",{className:"align-middle",children:[n.jsx(ms,{label:B.name,onClick:()=>C(B.id)}),!!B.path&&n.jsx("p",{className:"mb-0 pl-3",children:n.jsx("i",{children:B.path})})]}),n.jsx("td",{className:"align-middle",children:B.description}),n.jsx("td",{className:"text-center align-middle",children:n.jsx(Hs,{onClick:()=>P(B.id)})})]},B.id))})]}):n.jsx(Q_,{label:t("skill")})}),n.jsx(w.Col,{md:8,className:"text-right",children:n.jsx(G_,{totalRecordCount:o,filters:s,changePageSize:B=>c({pageSize:B}),changePage:B=>c({currentPage:B})})})]})]})};function N_(e){"@babel/helpers - typeof";return N_=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},N_(e)}function Bi(e,t){if(t.length<e)throw new TypeError(e+" argument"+(e>1?"s":"")+" required, but only "+t.length+" present")}function xn(e){Bi(1,arguments);var t=Object.prototype.toString.call(e);return e instanceof Date||N_(e)==="object"&&t==="[object Date]"?new Date(e.getTime()):typeof e=="number"||t==="[object Number]"?new Date(e):((typeof e=="string"||t==="[object String]")&&typeof console<"u"&&(console.warn("Starting with v2.0.0-beta.1 date-fns doesn't accept strings as date arguments. Please use `parseISO` to parse strings. See: https://github.com/date-fns/date-fns/blob/master/docs/upgradeGuide.md#string-arguments"),console.warn(new Error().stack)),new Date(NaN))}function MN_(e,t){Bi(2,arguments);var _=xn(e),o=xn(t);return _.getFullYear()-o.getFullYear()}const ls=K.createAction("users/setUserList"),Gi=K.createAction("users/setStudentList"),a_=`${ft}/api/user`,DN_=`${ft}/api/Account/changePassword`,Vn=`${ft}/api/account`,q_=`${ft}/api/User`,Fi=`${ft}/api/usersOneRoster`,Wn=`${ft}/api/mappingRosterUsers`,ON_=e=>he.get(`${Wn}`,{params:e}),BN_=e=>he.get(`${Wn}/filters`,{params:e}),GN_=e=>he.get(`${q_}/student-filters`,{params:e}),FN_=e=>he.get(`${q_}/export-csv`,{params:e}),To=e=>he.get(`${a_}/detail-user/${e}`),zN_=e=>he.post(`${a_}`,e),HN_=e=>he.put(`${a_}/${e.id}`,e),VN_=e=>he.put(`${a_}/update-status-all`,e),WN_=e=>he.delete(`${q_}/delete-item-user/${e}`),UN_=e=>he.post(DN_,e),YN_=e=>he.post(`${Vn}/forgotchangepassword`,e),XN_=e=>he.post(`${q_}/switch-user/${e}`),ZN_=e=>he.get(`${Fi}`,{params:e}),JN_=e=>he.get(`${Fi}/${e}`),QN_=()=>he.put(`${q_}/sync-roster-user`),KN_=e=>he.post(`${Vn}/reset-password-for-admin`,e),eq_=e=>he.get(`${q_}/student-assign`,{params:e}),tq_=()=>he.get(`${ft}/api/counselor`),_q_=()=>he.get(`${ft}/api/assistant`),sq_=()=>he.get(`${ft}/api/secondaryTeacher`),zi=e=>he.get(`${a_}/all/teacher`,{params:e}),os=e=>he.post(`${a_}/student-assign`,e),nq_=e=>he.get(`${ft}/api/user/check-role-data/${e}`),oq_=(e,t)=>he.post(`${q_}/change-grade-for-student`,{studentUserId:e,gradeLevel:t}),aq_=e=>he.put(`${a_}/change-multi-teachers`,e),iq_=e=>he.put(`${a_}/change-multi-counselors`,e),rq_=e=>he.put(`${a_}/change-assistants`,e),cq_=e=>he.put(`${a_}/change-secondary-teachers`,e),lq_=(e,t)=>he.put(`${a_}/update-user-grade/${e}`,{gradeLevel:t}),dq_=e=>he.get(`${Wn}/all-userId`,{params:e}),uq_=e=>he.post(`${Vn}/re-send-welcome-mail`,e),hq_=e=>he.post(`${q_}/remove-bulk-staff`,e);var $t=(e=>(e[e.Id=0]="Id",e[e.Name=1]="Name",e[e.Email=2]="Email",e[e.Age=3]="Age",e[e.Role=4]="Role",e[e.Status=5]="Status",e[e.CreatedAt=6]="CreatedAt",e[e.RosterUser=7]="RosterUser",e[e.Grade=8]="Grade",e[e.Teacher=9]="Teacher",e[e.Assistant=10]="Assistant",e[e.Counselor=11]="Counselor",e[e.SecondaryTeacher=12]="SecondaryTeacher",e))($t||{}),Mt=(e=>(e[e.Id=0]="Id",e[e.Name=1]="Name",e[e.Email=2]="Email",e[e.Role=3]="Role",e[e.RosterUser=4]="RosterUser",e[e.Status=5]="Status",e[e.Grade=6]="Grade",e[e.Teacher=7]="Teacher",e[e.Assistant=8]="Assistant",e[e.Counselor=9]="Counselor",e[e.SecondaryTeacher=10]="SecondaryTeacher",e))(Mt||{}),bt=(e=>(e[e.Teacher=0]="Teacher",e[e.Assistant=1]="Assistant",e[e.Counselor=2]="Counselor",e[e.SecondaryTeacher=3]="SecondaryTeacher",e))(bt||{});const mq_={[$t.Id]:"filter-id",[$t.Name]:"filter-name",[$t.Email]:"filter-email",[$t.Age]:"filter-age",[$t.Role]:"filter-role",[$t.Status]:"filter-status",[$t.CreatedAt]:"filter-createdAt",[$t.RosterUser]:"filter-roster",[$t.Grade]:"filter-grade",[$t.Teacher]:"filter-teacher",[$t.Assistant]:"filter-assistant",[$t.Counselor]:"filter-counselor",[$t.SecondaryTeacher]:"filter-secondary"},gq_=[{name:"name",isCenter:!0,sortBy:$t.Name,searchBy:Mt.Name,className:"align-top",getOption:e=>({label:e||"empty",value:e})},{name:"email",isCenter:!0,sortBy:$t.Email,searchBy:Mt.Email,className:"align-top",getOption:e=>({label:e||"empty",value:e})},{name:"age",isCenter:!0,sortBy:$t.Age,className:"align-top"},{name:"role",isCenter:!0,sortBy:$t.Role,searchBy:Mt.Role,className:"align-top",getOption:e=>({label:e?e?.replace?.("SecondaryTeacher","SupportTeacher"):"empty",value:e})},{name:"active_status",isCenter:!0,sortBy:$t.Status,searchBy:Mt.Status,className:"align-top",options:[{label:"Active",value:"true"},{label:"Inactive",value:"false"}]},{name:"created_time",isCenter:!0,sortBy:$t.CreatedAt,className:"align-top"},{name:"information_roster_sourced_id_full_name_email",isCenter:!0,sortBy:$t.RosterUser,searchBy:Mt.RosterUser,className:"align-top",getOption:e=>({label:e||"empty",value:e})},{name:"impersonate",isCenter:!0,className:"align-top"},{name:"delete",isCenter:!0,className:"align-top"}],Hi={value:10},pq_={searchString:"",currentPage:1,pageSize:Hi.value},yq_={searchString:"",currentPage:1,pageSize:Hi.value},fq_={currentPage:1,pageSize:200},wq_="data:text/csv;charset=utf-8,",xs={assistantId:"",counselors:[],secondaryTeacherId:"",teacher:[],assistantEmail:"",secondaryTeacherEmail:""},vq_={studentId:0,id:"",email:"",fullName:"",gradeLevel:"",phoneNumber:"",isActive:!0,dateOfBirth:"",profileImageFileName:"",quote:"",assistantName:"",assistantEmail:"",assistantUserId:"",counselors:[],secondaryTeacherName:"",secondaryTeacherEmail:"",secondaryTeacherUserId:"",teachers:[]},jo=[{label:"K",value:"K"},{label:"G",value:"G"},{label:"1",value:"1"},{label:"2",value:"2"},{label:"3",value:"3"},{label:"4",value:"4"},{label:"5",value:"5"},{label:"6",value:"6"},{label:"7",value:"7"},{label:"8",value:"8"},{label:"9",value:"9"},{label:"10",value:"10"},{label:"11",value:"11"},{label:"12",value:"12"},...Dn?[{label:"12/13",value:"12/13"}]:[],{label:"13",value:"13"}],bq_=["K","G","1","2","3","4","5","6","7","8","9","10","11","12",...Dn?["12/13"]:[],"13"],No=[{label:"K",value:"K"},{label:"G",value:"G"},{label:"1",value:"1"},{label:"2",value:"2"},{label:"3",value:"3"},{label:"4",value:"4"},{label:"5",value:"5"},{label:"6",value:"6"},{label:"7",value:"7"},{label:"8",value:"8"},{label:"9",value:"9"},{label:"10",value:"10"},{label:"11",value:"11"},{label:"12",value:"12"},...Dn?[{label:"12/13",value:"12/13"}]:[],{label:"13",value:"13"}],qo={assistantRemoveUserId:[],counselorRemoveUserIds:[],teacherRemoveUserIds:[],teacherSwitchDataUserId:"",assistantSwitchDataUserId:"",counselorSwitchDataUserId:"",supportTeacherRemoveUserIds:[],supportTeacherSwitchDataUserId:""},Vi={id:"",firstName:"",lastName:"",email:"",fullName:"",roles:[]},$q_=()=>{const[e,t]=v.useState(pq_);return{filters:e,setFilters:t,changeFilters:o=>{const s={...e,...o};s.searchString&&o.searchString&&o.searchString!=e.searchString&&(s.currentPage=1),t(s)}}},kq_="/admin/user",xq_="/admin/create-user",Cq_="User list",Po="/home",Sq_="/home",Iq_="/admin/home",Aq_="/parent",Eq_="/admin/schools",Tq_="/list-student",jq_=()=>{const e=Ct.useNavigate(),_=new URLSearchParams(location.search).get("query"),o=Ee.useSelector(R=>R.users.userList),s=Ee.useSelector(R=>R.users.totalItems),{filters:c,changeFilters:u}=$q_(),g=_||"",[d,p]=v.useState([]),x=window.location.host.includes("-district"),f=Ee.useDispatch(),{t:A}=at.useTranslation(),T=R=>{const W=d.find(H=>H==R);p(W?d.filter(H=>H!=R):d.concat([R]))},q=v.useCallback(async()=>{if(d.length!=0){p([]);return}if(c.searchBy!==void 0&&c.searchByStrings!==void 0&&c.searchByStrings.length===0){f(ls({userList:[],totalItems:0}));return}f(se(!0));try{const R=await dq_(c);p(R.data||[])}catch(R){f(Q({type:"danger",message:R.response?.data?.title||R.message}))}f(se(!1))},[f,c,d]),E=v.useCallback(async()=>{if(c.searchBy!==void 0&&c.searchByStrings!==void 0&&c.searchByStrings.length===0){f(ls({userList:[],totalItems:0}));return}f(se(!0));try{const R=await ON_(c),{items:W,totalItems:H}=R.data;for(const J of W)J.roles=J.roles.map(F=>F!=w_.EDUTEACHER?F:"EduTeacher");f(ls({userList:W,totalItems:H}))}catch(R){f(Q({type:"danger",message:R.response?.data?.title||R.message}))}f(se(!1))},[f,c]),k=async()=>{f(se(!0));try{const R=await QN_();R.data?(f(Q({type:"success",message:`${R.data} user${R.data>1?"s have":" has"} been synchronized`})),E()):f(Q({type:"success",message:"Users synchronized"}))}catch(R){f(Q({type:"danger",message:R.response?.data?.title||R.message}))}f(se(!1))},C=R=>{if(!R)return"";const W=[],{sourcedId:H,rosterUser:J}=R;if(H&&J&&W.push(H),J){const{givenName:F,middleName:z,familyName:L,email:Z}=J,ne=[];L&&ne.push(L),z&&ne.push(z),F&&ne.push(F),W.push(ne.join(" ")||""),W.push(Z||"")}return W.join(" / ")};v.useEffect(()=>{document.title=Cq_},[]),v.useEffect(()=>{u({...c,searchString:g})},[g]),v.useEffect(()=>{E()},[JSON.stringify(c)]);const N=v.useCallback(R=>{f(se(!0));try{f(Yt({isOpen:!0,type:"warning",message:A("do_you_want_to_remove_this_user"),onConfirm:async()=>{await WN_(R),f(Q({type:"success",message:"Remove user successfully"})),c.currentPage!==1?u({currentPage:1}):E()}}))}catch(W){f(Q({type:"danger",message:W.response?.data?.title||W.message}))}f(se(!1))},[JSON.stringify(c)]),P=R=>{const W=sessionStorage.getItem(B_),{token:H,id:J,firstName:F,lastName:z,roles:L,email:Z,profileImageFileName:ne}=R.data;W?sessionStorage.setItem(jt,H):localStorage.setItem(jt,H),L.includes("Admin")&&localStorage.setItem("ROLES","Admin"),localStorage.removeItem(Mn),f(Fs({id:J,firstName:F,lastName:z,roles:L,email:Z,profileImageFileName:ne})),x?e(Eq_):L.includes("Admin")?e(Iq_):L.includes("Teacher")||L.includes("Assistant")?e(Po):L.includes("Student")?e(Sq_):L.includes("Parent")?e(Aq_):L.includes("EduTeacher")?e(Tq_):(L.includes("Counselor")||L.includes("SecondaryTeacher"))&&e(Po)},D=v.useCallback(async R=>{try{const H=(await XN_(R)).data;f(Yt({isOpen:!0,type:"warning",message:A("do_you_want_to_impersonate_this_user"),onConfirm:async()=>{f(se(!0));try{const J={email:H.email,password:"default",accessToken:H.token,loginType:Y_.Impersonate},F=await Ci(J);localStorage.clear(),P(F)}catch(J){Q({type:"danger",message:J.response?.data?.title||J.message})}f(se(!1))}}))}catch(W){f(Q({type:"danger",message:W.response?.data?.title||W.message}))}},[c]);return{userList:o,totalItems:s,filters:c,queryName:_,fullName:g,getData:E,removeData:N,changeFilters:u,reDirectDetailPage:R=>{const W=R?`${kq_}/${R}`:xq_;e(W)},switchUser:D,handleSyncRosterUsers:k,rosterUserInfo:C,userIds:d,onSelectAllUser:q,onSelectUser:T}},Nq_="_searchBox_1jz8j_1",qq_={searchBox:Nq_},Pq_=({initValue:e,onSearch:t,placeholder:_="Type something to search",className:o="",style:s={}})=>{const[c,u]=v.useState(e);v.useEffect(()=>{u(e)},[e]);const g=v.useCallback(d=>{d.key==="Enter"&&t(c)},[c,t]);return n.jsx(w.Input,{placeholder:_,value:c,onChange:d=>u(d.target.value),onKeyUp:g,className:`${o} ${qq_.searchBox}`,style:s})},K_=v.memo(Pq_),Rq_={height:38},Wi=({text:e,initValue:t,onClick:_,onSearch:o,placeholder:s="Type something to search"})=>n.jsxs("div",{className:"d-flex align-items-center",style:{gap:"8px"},children:[n.jsx("div",{children:n.jsx(zs,{text:e,onClick:_})}),n.jsx("div",{className:"flex-grow-1 ml-2",children:n.jsx(K_,{initValue:t,onSearch:o,placeholder:s,style:Rq_})})]}),Ro={YYYY:"yyyy",YY:"yy",MMMM:"MMMM",MMM:"MMM",MM:"MM",M:"M",Do:"do",DD:"dd",D:"d",HH:"HH",hh:"hh",mm:"mm",ss:"ss",A:"a"},Lq_=e=>e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),an=new Map,Mq_=(e="yyyy-MM-dd")=>{if(an.has(e))return an.get(e);const t=Object.keys(Ro).sort((_,o)=>o.length-_.length).reduce((_,o)=>{const s=new RegExp(Lq_(o),"g");return _.replace(s,Ro[o])},e);return an.set(e,t),t},Dq_=e=>/[zZ]|[+-]\d{2}(:?\d{2})?$|[+-]\d{4}$/.test(e);function ys(e,t){if(!e||e===Rn)return"";try{const _=e.includes("T")?e:e.replace(" ","T"),o=Dq_(_)?_:`${_}Z`,s=new Date(o);if(Number.isNaN(s.getTime()))return"";const c=Mq_(t);return c.includes("hh")&&!c.includes("a")&&console.warn("12-hour format without AM/PM:",t),v_.format(s,c)}catch{return""}}const Oq_={fontWeight:500},Bq_={height:38,background:"#316cd9"},Gq_=({text:e,onClick:t,className:_=""})=>n.jsxs(w.Button,{onClick:t,color:"primary",style:Bq_,className:`d-flex align-items-center ${_} gap-2`,children:[n.jsx(wj_,{}),n.jsx("span",{style:Oq_,children:e})]});function Fq_(e){return Rt({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 zq_(e){return Rt({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 Hq_(e){return Rt({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 Lo(e){return Rt({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 Vq_(e){return Rt({attr:{viewBox:"0 0 1024 1024"},child:[{tag:"path",attr:{d:"M942.2 486.2C847.4 286.5 704.1 186 512 186c-192.2 0-335.4 100.5-430.2 300.3a60.3 60.3 0 0 0 0 51.5C176.6 737.5 319.9 838 512 838c192.2 0 335.4-100.5 430.2-300.3 7.7-16.2 7.7-35 0-51.5zM512 766c-161.3 0-279.4-81.8-362.7-254C232.6 339.8 350.7 258 512 258c161.3 0 279.4 81.8 362.7 254C791.5 684.2 673.4 766 512 766zm-4-430c-97.2 0-176 78.8-176 176s78.8 176 176 176 176-78.8 176-176-78.8-176-176-176zm0 288c-61.9 0-112-50.1-112-112s50.1-112 112-112 112 50.1 112 112-50.1 112-112 112z"}}]})(e)}function Ui(e){return Rt({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 Yi(e){return Rt({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 Wq_=(e,t)=>{v.useEffect(()=>{function _(o){e.current&&!e.current.contains(o.target)&&t?.()}return document.addEventListener("mousedown",_),()=>{document.removeEventListener("mousedown",_)}},[e.current])},Uq_=e=>{const{isOpen:t,sortBy:_,filters:o,users:s,searchBy:c,defaultOptions:u,selectedOptions:g,searchKey:d,onChangeSearchKey:p,onOptionsChange:x,onSearch:f,onClose:A,onChangeFilters:T,getOption:q}=e,[E,k]=v.useState(),[C,N]=v.useState([]),P=v.useRef(null),D=v.useRef(null);Wq_(P,A);const{t:B}=at.useTranslation(),R=v.useCallback(()=>{if(!t)return;const Oe=d?.trim?.()??"";c!=null&&!u&&f?.(Oe,c),c!=null&&u&&N(u.filter(Be=>Be.label.toLowerCase().includes(Oe.toLowerCase())))},[c,d,JSON.stringify(u),t]),W=()=>{D.current&&clearTimeout(D.current),D.current=setTimeout(R,500)},H=Oe=>{const Be=Oe.target.value;p(Be)},J=v.useCallback(()=>{x?.(E,c),A?.()},[JSON.stringify(E)]),F=v.useCallback(Oe=>{const Be=Oe.target.value??"";let ce=E??[],Qe=ce.indexOf(Be);Qe>-1?ce.splice(Qe,1):ce=[...ce,Be],k(ce==null?ce:[...ce])},[JSON.stringify(E)]),z=v.useCallback(Oe=>{const Be=Oe.target.checked;k(Be?void 0:[])},[]),L=v.useCallback(()=>{T?.({...o,sortBy:_,isDescending:!0}),A?.()},[JSON.stringify(o),c]),Z=v.useCallback(()=>{T?.({...o,sortBy:_,isDescending:!1}),A?.()},[JSON.stringify(o),c]),ne=v.useMemo(()=>q?s.map(Oe=>q(Oe,B)):[],[JSON.stringify(s),JSON.stringify(q)]),de=o?.isDescending==!1&&o.sortBy===_,Ne=!!o?.isDescending&&o.sortBy===_;return v.useEffect(()=>{o?.searchBy!==c?k(void 0):k(g)},[JSON.stringify(g),o?.searchBy]),v.useEffect(()=>{N(u||[])},[JSON.stringify(u)]),v.useEffect(()=>{W()},[d,t]),{ref:P,options:ne,inputRef:D,sOptions:E,isAscending:de,isDescending:Ne,filteredOptions:C,searchKey:d,handleSearch:R,handleApplyFilter:J,handleOptionSelected:F,handleOptionSelectedAll:z,handleSortDesc:L,handleSortAsc:Z,handleChangeSearchKey:H}},Yq_=e=>{const{defaultOptions:t,onClose:_,getOption:o}=e,{ref:s,inputRef:c,options:u,sOptions:g,isAscending:d,isDescending:p,filteredOptions:x,searchKey:f,handleChangeSearchKey:A,handleApplyFilter:T,handleOptionSelected:q,handleOptionSelectedAll:E,handleSortDesc:k,handleSortAsc:C}=Uq_(e);return n.jsx(w.Popover,{...e,hideArrow:!0,className:V["popover-zindex"],children:n.jsx(w.PopoverBody,{className:"pb-3",children:n.jsxs("div",{ref:s,className:V.popover,children:[n.jsxs("div",{className:`d-flex flex-column ${V.popover__sort}`,children:[n.jsx(w.Label,{className:"font-weight-bold",children:"Sort"}),n.jsxs("div",{className:`px-1 ${V.popover__sort__item} ${d&&V["popover__sort__item--active"]}`,onClick:C,children:[n.jsx(Ui,{className:"mr-1"}),"Ascending"]}),n.jsxs("div",{className:`px-1 mt-1 ${V.popover__sort__item} ${p&&V["popover__sort__item--active"]}`,onClick:k,children:[n.jsx(Yi,{className:"mr-1"}),"Descending"]})]}),(typeof o<"u"||!!t)&&n.jsxs(v.Fragment,{children:[n.jsx("div",{className:"border border-top-1 border-bottom-0 mx-1 my-2"}),n.jsxs("div",{className:"d-flex flex-column",children:[n.jsx(w.Label,{className:"font-weight-bold",children:"Filter"}),n.jsxs("div",{className:`position-relative px-1 ${V.popover__search}`,children:[n.jsx(zq_,{className:`position-absolute ${V.popover__search__icon}`}),n.jsx(w.Input,{ref:c,className:V.popover__search__input,value:f,onChange:A})]}),n.jsxs("div",{className:`mx-1 mt-2 p-2 bg-light ${V.popover__options}`,children:[n.jsxs(w.FormGroup,{className:"d-flex align-items-center",check:!0,style:{gap:"8px"},children:[n.jsx(w.Input,{type:"checkbox",onChange:E,checked:g==null})," ",n.jsx(w.Label,{check:!0,children:"(Select all)"})]}),!!o&&!t&&u.map(N=>n.jsxs(w.FormGroup,{className:"d-flex align-items-center",check:!0,style:{gap:"8px"},children:[n.jsx(w.Input,{type:"checkbox",value:N.value,onChange:q,checked:g?.includes(N.value)||g==null})," ",n.jsx(w.Label,{check:!0,children:N.label})]},N.value)),!!t&&x.map(N=>n.jsxs(w.FormGroup,{className:"d-flex align-items-center",check:!0,style:{gap:"8px"},children:[n.jsx(w.Input,{type:"checkbox",value:N.value,onChange:q,checked:g?.includes(N.value)||g==null})," ",n.jsx(w.Label,{check:!0,children:N.label})]},N.value))]})]}),n.jsxs("div",{className:"d-flex justify-content-end mt-3",style:{gap:"8px"},children:[n.jsx(w.Button,{color:"primary",className:"mr-2",size:"sm",onClick:T,children:"Apply Filter"}),n.jsx(w.Button,{color:"secondary",size:"sm",onClick:_,children:"Cancel"})]})]})]})})})},Xq_=({data:e,popoverId:t,filters:_,searchString:o,users:s,selectedOptions:c,onOptionsChange:u,onSearch:g,onChangeFilters:d,onOpenFilter:p,onClose:x,isCenter:f,isActive:A=!1})=>{const{t:T}=at.useTranslation(),[q,E]=v.useState(""),k=v.useMemo(()=>e.sortBy!=null?mq_[e.sortBy]:"",[e.sortBy]),C=v.useMemo(()=>t===k,[k,t]),N=()=>{p?.(k,e.searchBy,q,e.sortBy)},P=D=>{E(D)};return n.jsx("th",{className:e.className,children:k&&e.sortBy!==void 0?n.jsxs("div",{className:`w-100 d-flex ${f?"justify-content-center":"justify-content-between"} align-items-center ${V["table-filter-icon"]}`,children:[T(e.name),n.jsxs("div",{className:"ml-2 p-1",id:k,onClick:N,style:{cursor:"pointer"},children:[e.sortBy!==void 0&&e.sortBy===_?.sortBy&&n.jsx("span",{children:_.isDescending?n.jsx(Yi,{}):n.jsx(Ui,{})}),_?.searchByStrings?.length&&e.searchBy===_?.searchBy?n.jsx(Hq_,{color:A?"#007bff":"#242424"}):n.jsx(Fq_,{color:A?"#007bff":"#242424"})]}),n.jsx(Yq_,{placement:"bottom-end",target:k,users:s,isOpen:C,filters:_,sortBy:e.sortBy,searchKey:q,searchBy:e.searchBy,searchString:o,defaultOptions:e.options,selectedOptions:c,onClose:x,onSearch:g,getOption:e.getOption,onChangeFilters:d,onOptionsChange:u,onChangeSearchKey:P})]}):T(e.name)})},Zq_=e=>{const{filters:t,onChangeFilters:_,isStudentFilter:o,teacherOptions:s,assistantOptions:c,counselorOptions:u,secondaryTeacherOptions:g}=e,[d,p]=v.useState(),[x,f]=v.useState([]),[A,T]=v.useState({...fq_,isDescending:t.isDescending,searchString:t.searchString}),q=Ee.useDispatch(),E=Ct.useLocation(),k=v.useCallback(async B=>{try{const W=(o?await GN_(A):await BN_({...A,byStudent:B})).data?.items||[];f(W)}catch(R){q(Q({type:"danger",message:R.response?.data?.title||R.message}))}},[JSON.stringify(A),o]),C=v.useCallback((B,R,W,H)=>{p(B),T({...A,searchBy:R,searchStringBy:W,isDescending:t.sortBy===H?t.isDescending:void 0,searchString:t.searchString})},[JSON.stringify(A),t.isDescending,t.searchString]),N=()=>{p("")},P=v.useCallback((B,R)=>{T({...A,searchBy:R,searchStringBy:B})},[JSON.stringify(A)]),D=v.useCallback((B,R)=>{R&&_?.({...t,[Mt[R]]:B})},[JSON.stringify(t)]);return v.useEffect(()=>{if(!E.pathname.includes("users/assign-student"))return;const B=W=>W.sort((H,J)=>H.localeCompare(J)),R=A.searchStringBy?.toLowerCase()||"";if(A.searchBy===Mt.Grade)f(bq_);else{let W=[];switch(A.searchBy){case Mt.Name:k(!0);break;case Mt.Teacher:W=s?.map(z=>z.label).filter(Boolean)||[];break;case Mt.Assistant:W=c?.map(z=>z.label).filter(Boolean)||[];break;case Mt.Counselor:W=u?.map(z=>z.label).filter(Boolean)||[];break;case Mt.SecondaryTeacher:W=g?.map(z=>z.label).filter(Boolean)||[];break}const H=Array.from(new Set(W)),J=R?H.filter(z=>z.toLowerCase().includes(R)):H,F=B(J);f(F)}},[JSON.stringify(A),s,c,u,g,E.pathname]),v.useEffect(()=>{!(E.pathname.includes("users/assign-student")&&A.searchBy!==void 0)&&A.searchBy!==void 0&&k()},[JSON.stringify(A),E.pathname]),{popoverFilters:A,popoverId:d,users:x,handleFilterIcon:C,handleCloseFilter:N,handleSearch:P,handleChangeFilters:D}},Xi=({headers:e,filters:t,onChangeFilters:_,isStudentFilter:o,teacherOptions:s=[],assistantOptions:c=[],counselorOptions:u=[],secondaryTeacherOptions:g=[]})=>{const{popoverId:d,users:p,handleFilterIcon:x,handleCloseFilter:f,handleSearch:A,handleChangeFilters:T}=Zq_({filters:t,onChangeFilters:_,isStudentFilter:o,teacherOptions:s,assistantOptions:c,counselorOptions:u,secondaryTeacherOptions:g}),q=Object.entries(t).filter(([C,N])=>N!==""&&!(Array.isArray(N)&&N.length===0)&&N!==null&&N!==void 0).map(([C])=>C),E=Object.entries(Mt).filter(([C,N])=>isNaN(Number(C))),k=q.map(C=>E.find(([N])=>N===C)).filter(C=>!!C);return n.jsx("tr",{children:e.map(C=>C.onSelectAll?n.jsx("th",{className:`align-middle text-center ${C.className}`,children:n.jsx("input",{type:"checkbox",onChange:()=>C.onSelectAll?.(),checked:C.isCheckAll??!1})},C.name):n.jsx(Xq_,{users:p,data:C,isCenter:C.isCenter,filters:t,popoverId:d,selectedOptions:t.searchByStrings,onSearch:A,onClose:f,onOpenFilter:x,onChangeFilters:_,onOptionsChange:T,isActive:typeof C.searchBy=="number"&&k.some(([N,P])=>P===C.searchBy)},C.name))})},Jq_=()=>{const e=Ee.useDispatch(),t=Ee.useSelector(c=>c?.common?.user?.schoolName)||"",_=async c=>{e(se(!0));try{const g=(await FN_(c)).data,d=o(g),p=document.createElement("a");p.href=d,p.download=`${t}_Users_Report.csv`,p.click()}catch(u){e(Q({type:"danger",message:u.response?.data?.title||u.message}))}e(se(!1))},o=c=>{let u=`First Name,Last Name,Email,Phone,Age,Grade,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
|
|
9
|
+
insertdatetime media table paste code help wordcount media`,toolbar:"undo redo | formatselect | bold italic backcolor | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | removeformat | image | media",images_upload_handler:async function(e,t){const _=new FormData;_.append("file",e.blob(),e.filename());try{const{data:o}=await Eo(_);t(o_(o.key))}catch{return}},file_picker_callback:function(e){var t=document.createElement("input");t.setAttribute("type","file"),t.setAttribute("accept","video/*"),t.onchange=async function(_){const o=_.target.files[0],{name:s}=o,c=new FormData;c.append("file",o,s);const{data:u}=await Eo(c);e(o_(u.key))},t.click()}},Mi={email:dN_,question:uN_,answer:hN_,tutorial:mN_},gN_={id:0,subject:"",categoryId:0,body:"",attachments:[]},pN_="/admin/email-template",yN_="Email template detail",fN_=4194304,wN_=e=>{let t;const _=Ee.useDispatch(),o=Ct.useNavigate(),[s,c]=v.useState(gN_),[u,g]=v.useState(!1),d=async()=>{localStorage.setItem(window.location.href,"true"),g(!0)},[p,x]=v.useState([]),[f,A]=v.useState([]),[T,q]=v.useState("");v.useEffect(()=>{e&&E()},[e]);const E=v.useCallback(async()=>{_(se(!0));try{const J=await Ij_(e);c({id:J.data.id,subject:J.data.subject,categoryId:J.data.category.id,body:J.data.body,attachments:J.data.attachments||[]}),document.title=J.data.subject,t&&t.editor.execCommand("mceSetContent",!1,J.data.body)}catch(J){_(Q({type:"danger",message:J.response?.data?.title||J.message}))}_(se(!1))},[e]),k=async()=>{_(se(!0));try{const F=(await jj_()).data;F&&q(F.key)}catch(J){_(Q({type:"danger",message:J.response?.data?.title||"Get key failed"}))}_(se(!1))},C=J=>t=J,N=J=>{t&&t.editor.execCommand("mceInsertContent",!1,` ${J.label}`)},P=v.useCallback(()=>{o(pN_)},[]),D=v.useCallback(async J=>{_(se(!0));try{if(f&&f.length){const L=(await H()).map(Z=>({key:Z.data.key,name:Z.data.name}));J.attachments=[...J.attachments,...L]}await(e?Ej_:Aj_)(J),_(Q({type:"success",message:`${e?"Update":"Create"} template successfully`})),P()}catch(F){_(Q({type:"danger",message:F.response?.data?.title||F.message}))}_(se(!1))},[e,f]),B=()=>{const J=document.getElementsByClassName("input-attachment"),F=document.createElement("input");document.getElementById("email-detail")?.append(F),F.className="input-attachment",F.id=`inputAttachment-${J.length+1}`,F.type="file",F.style.display="none",F.setAttribute("multiple","multiple"),F.addEventListener("change",R),F.click()},R=()=>{const J=[];let F=0;const z=document.getElementsByClassName("input-attachment");for(const L of z)for(const Z of L.files)F+=Z.size,F>fN_&&(_(Q({type:"danger",message:"Max attachment size is 4MB"})),F-=Z.size,L.remove());for(const L of z)for(const Z of L.files){const{name:ne}=Z;!p.includes(Z)&&!J.some(de=>de.name===ne)&&J.push({name:ne,inputId:L.id})}A(J)},W=(J,F)=>{if(f.filter(z=>z.inputId===J).length===1){document.getElementById(J)?.remove();let L=f.filter(Z=>Z.inputId===J);f.filter(Z=>Z.inputId!==L.inputId),p.push(L),x([...p]),A([...f]);return}x([...p,F])};v.useEffect(()=>{R()},[p]);const H=async()=>{const J=document.getElementsByClassName("input-attachment"),F=[];for(const z of J)for(const L of z.files){const{name:Z}=L,ne=new FormData;ne.append("file",L,Z),F.push(Ri(ne))}return Promise.all(F)};return v.useEffect(()=>{document.title=yN_,k(),g(!1),localStorage.getItem(window.location.href)&&localStorage.removeItem(window.location.href)},[]),{emailTemplateDetail:s,setEditorRef:C,addParams:N,backToList:P,confirmData:D,edited:u,setEdited:g,setEditedTrue:d,onAttachFile:B,updateAttachment:R,fileUpload:f,removeAttachment:W,tinyMCEKey:T}},vN_=ct.object({subject:ct.string().required("Template subject is required"),categoryId:ct.number().required("Template category is required").test("test category id","Template category is required",e=>e>=1),comment:ct.string(),body:ct.string().required("Template body is required")}),bN_="create_email_template",$N_="edit_email_template",kN_=()=>{const{id:e}=Ct.useParams(),{t}=at.useTranslation(),{emailTemplateDetail:_,setEditorRef:o,addParams:s,backToList:c,confirmData:u,edited:g,setEdited:d,setEditedTrue:p,onAttachFile:x,fileUpload:f,removeAttachment:A}=wN_(parseInt(e||"0")),T=t(e?$N_:bN_),q=t(e?"update":"create"),E=Ee.useSelector(k=>k.mailCategory.mailCategoryList);return n.jsx(d_.Formik,{initialValues:_,enableReinitialize:!0,validationSchema:vN_,onSubmit:k=>{u(k),d(!1),localStorage.getItem(window.location.href)&&localStorage.removeItem(window.location.href)},children:k=>{const{values:C,touched:N,errors:P,setFieldValue:D,handleChange:B,handleBlur:R,handleSubmit:W}=k;return n.jsxs("div",{className:"animated fadeIn detail-buttons-padding",id:"email-detail",children:[n.jsx(Us,{when:g}),n.jsx("h5",{className:"mb-2",style:{textTransform:"capitalize"},children:T}),n.jsxs(w.Row,{className:"my-2",children:[n.jsxs(w.Col,{md:8,children:[n.jsx(Ht,{text:t("mail_subject")}),n.jsx(w.Input,{placeholder:t("mail_subject_nm"),name:"subject",value:C.subject,onChange:H=>{B(H),p()},onBlur:R("subject"),className:"selector-input"}),N.subject&&P.subject&&n.jsx(Nt,{text:P.subject})]}),n.jsxs(w.Col,{md:4,children:[n.jsx(Ht,{text:t("category")}),n.jsx(Gj_,{onChange:H=>{D("categoryId",H.value),p()},id:C.categoryId}),N.categoryId&&P.categoryId&&n.jsx(Nt,{text:P.categoryId})]})]}),n.jsxs(w.Row,{className:"mb-2",children:[n.jsx(w.Col,{md:8,children:n.jsxs(w.Row,{children:[n.jsxs(w.Col,{md:12,className:"mb-2",children:[n.jsx(Ht,{text:t("mail_body")}),(_.body||!e)&&n.jsx(ld.Editor,{tinymceScriptSrc:"/tinymce/tinymce.min.js",ref:H=>o(H),initialValue:_.body,init:Mi.email,onEditorChange:H=>{D("body",H),p()}}),N.body&&P.body&&n.jsx(Nt,{text:P.body})]}),n.jsx(w.Col,{md:12,children:n.jsxs(w.Row,{children:[n.jsx(w.Col,{md:3,children:n.jsx(w.Button,{color:"link",size:"sm",className:"pl-0",onClick:x,children:t("add_attachment")})}),n.jsx(w.Col,{md:12,children:n.jsxs(w.Row,{children:[C.attachments.map(H=>n.jsx(w.Col,{md:2,children:n.jsx(Ao,{label:H.name,onRemove:()=>D("attachments",C.attachments.filter(J=>J.name!==H.name))})},H.key)),f.map((H,J)=>n.jsx(w.Col,{md:2,className:"d-flex align-items-center",children:n.jsx(Ao,{label:H.name,onRemove:()=>A(H.inputId,H.name)})},J))]})})]})})]})}),n.jsxs(w.Col,{md:4,children:[n.jsx(w.Label,{children:t("mail_params")}),n.jsx(Bj_,{onClick:H=>s(H),isResetPasswordTemplate:C.categoryId==(E&&E.length>0&&E.filter(H=>H.name=="Reset password")[0].id)})]})]}),n.jsx(Hn,{confirmText:q,onConfirm:W,onCancel:c})]})}})},xN_=(e,t)=>{const{header:_,children:o,onConfirm:s,onCancel:c,confirmText:u,cancelText:g,noFooter:d,size:p,edited:x,setEditedFalse:f}=e,[A,T]=v.useState(!1),q=Ee.useDispatch(),{t:E}=at.useTranslation(),k=D=>{try{q(Yt({isOpen:!0,type:"warning",message:"Are you sure to cancel?",onConfirm:async()=>{D()}}))}catch(B){q(Q({type:"danger",message:B.response?.data?.title||B.message}))}},C=()=>{f&&f(),T(!A),A&&c&&c()},N=v.useCallback((D,B)=>{D?k(()=>{C(),B&&B()}):(C(),B&&B())},[A]),P=v.useCallback(()=>{N(!!x,()=>{c&&c()})},[N,c,x]);return v.useImperativeHandle(t,()=>({toggle:N})),n.jsxs(w.Modal,{isOpen:A,toggle:()=>N(!!x),size:p,zIndex:1202,style:{marginTop:"8rem"},children:[n.jsx(w.ModalHeader,{toggle:()=>N(!!x),children:_}),n.jsx(w.ModalBody,{children:o}),!d&&n.jsxs(w.ModalFooter,{className:"text-right",children:[s&&n.jsx(w.Button,{color:"primary",onClick:s,children:u||E("confirm")}),n.jsx(w.Button,{onClick:P,children:g||E("cancel")})]})]})},Xs=v.forwardRef(xN_),Dt=({defaultValue:e,options:t,isDisabled:_,scrollBottom:o,...s})=>{const c=e!==null&&typeof e<"u"&&t.find(u=>u.value===e)||null;return n.jsx(u_,{isDisabled:_,options:t,value:c,menuPlacement:o?"top":"auto",...s})},ps=`${ft}/api/Skill`,Di=e=>he.get(ps,{params:e}),CN_=e=>he.get(`${ps}/${e}`),SN_=e=>he.post(ps,e),IN_=e=>he.put(`${ps}/${e.id}`,e),AN_=e=>he.delete(`${ps}/${e}`),EN_=e=>{const[t,_]=v.useState([]);v.useEffect(()=>{o()},[]);const o=async()=>{try{const g=await Di();_(g.data.items)}catch(g){console.error(g.message)}},{id:s,isDisabled:c}=e,u=t.map(g=>({id:g.id,value:g.id,label:g.path?`${g.path}/${g.name}`:g.name}));return n.jsx(Dt,{options:u,defaultValue:s,...e,isDisabled:c})},TN_=ct.object({name:ct.string().required("Name is required"),description:ct.string()}),jN_=(e,t)=>{const{header:_,confirmText:o,onConfirm:s,skillDetail:c,onCancel:u,edited:g,setEdited:d,setEditedTrue:p,setEditedFalse:x,isDisabled:f}=e,{t:A}=at.useTranslation();return n.jsx(d_.Formik,{initialValues:c,enableReinitialize:!0,validationSchema:TN_,onSubmit:(T,q)=>{s(T),q.resetForm()},children:T=>{const{values:q,touched:E,errors:k,handleChange:C,handleBlur:N,handleSubmit:P,resetForm:D}=T;return n.jsx(Xs,{header:_,confirmText:o,onConfirm:P,ref:t,onCancel:()=>{u(),D()},edited:g,setEdited:d,setEditedFalse:x,children:n.jsxs(w.Row,{children:[n.jsxs(w.Col,{md:12,className:"mb-2",children:[n.jsx(Ht,{text:A("name")}),n.jsx(w.Input,{name:"name",placeholder:A("name"),value:q.name,onChange:B=>{C(B),p()},onBlur:N("name")}),E.name&&k.name&&n.jsx(Nt,{text:k.name})]}),n.jsxs(w.Col,{md:12,className:"mb-2",children:[n.jsx(w.Label,{children:A("description")}),n.jsx(w.Input,{type:"textarea",rows:5,name:"description",placeholder:A("description"),value:q.description,onChange:B=>{C(B),p()},onBlur:N("description")})]}),n.jsxs(w.Col,{md:12,className:"mb-2",children:[n.jsx(w.Label,{children:A("parent_category")}),n.jsx(EN_,{isDisabled:f,onChange:B=>{T.setFieldValue("parentSkillId",B.value),p()},id:q.parentSkillId})]})]})})}})},NN_=v.forwardRef(jN_),Oi=K.createAction("skills/setSkillList"),qN_="Skill list",PN_=()=>{const e=Ee.useSelector(d=>d.skills.skillList),t=Ee.useSelector(d=>d.skills.totalItems),{t:_}=at.useTranslation(),{filters:o,changeFilters:s}=Ws(),c=Ee.useDispatch(),u=v.useCallback(async()=>{c(se(!0));try{const d=await Di(o),{items:p,totalItems:x}=d.data;c(Oi({skillList:p,totalItems:x}))}catch(d){c(Q({type:"danger",message:d.response?.data?.title||d.message}))}c(se(!1))},[c,o]),g=v.useCallback(d=>{c(se(!0));try{c(Yt({isOpen:!0,type:"warning",message:_("do_you_want_to_remove_this_skill"),onConfirm:async()=>{try{await AN_(d),c(Q({type:"success",message:_("remove_skill_successfully")})),s({currentPage:1})}catch(p){c(Q({type:"danger",message:p.response?.data?.title||p.message||"Error occured"}))}}}))}catch(p){c(Q({type:"danger",message:p.response?.data?.title||p.message||"Error occured"}))}c(se(!1))},[o]);return v.useEffect(()=>{document.title=qN_},[]),v.useEffect(()=>{u()},[o]),{skillList:e,totalItems:t,filters:o,changeFilters:s,getData:u,removeData:g}},ks={name:"",description:"",path:"",parentSkillId:null},RN_=()=>{const e=Ee.useDispatch(),[t,_]=v.useState(0),[o,s]=v.useState(ks),[c,u]=v.useState(!1),g=async()=>{localStorage.setItem(window.location.href,"true"),u(!0)},d=async()=>{localStorage.getItem(window.location.href)&&localStorage.removeItem(window.location.href),u(!1)};v.useEffect(()=>{t?x():s(ks)},[t]);const p=()=>{_(0),s(ks)};v.useEffect(()=>{d()},[]);const x=v.useCallback(async()=>{e(se(!0));try{const A=await CN_(t);s(A.data)}catch(A){e(Q({type:"danger",message:A.response?.data?.title||A.message}))}e(se(!1))},[t]),f=v.useCallback(async(A,T)=>{e(se(!0));try{await(t?IN_:SN_)(A),e(Q({type:"success",message:`${t?"Update":"Create"} skill successfully`})),T&&T(),t&&_(0)}catch(q){e(Q({type:"danger",message:q.response?.data?.title||q.message}))}e(se(!1))},[t,o]);return{id:t,setId:_,skillDetail:o,confirmData:f,initValue:ks,reset:p,edited:c,setEdited:u,setEditedTrue:g,setEditedFalse:d}},LN_=()=>{const e=v.useRef(null),{t}=at.useTranslation(),{skillList:_,totalItems:o,filters:s,changeFilters:c,getData:u,removeData:g}=PN_(),{id:d,setId:p,skillDetail:x,confirmData:f,reset:A,edited:T,setEdited:q,setEditedTrue:E,setEditedFalse:k}=RN_(),C=B=>{p(B||0),e&&e.current&&e.current.toggle()},N=B=>{f(B,()=>{e&&e.current&&e.current.toggle(),u()}),k()},P=B=>{g(B)},D=()=>A();return n.jsxs("div",{className:"fadeIn animated",children:[n.jsx(NN_,{ref:e,header:t(d?"edit_skill":"create_skill"),confirmText:t(d?"update":"create"),onCancel:D,onConfirm:N,skillDetail:x,edited:T,setEdited:q,setEditedTrue:E,setEditedFalse:k,isDisabled:d}),n.jsx(Us,{when:T}),n.jsxs(w.Row,{className:"my-2",children:[n.jsx(w.Col,{md:4,children:n.jsx(zs,{text:t("create_skill"),onClick:()=>C()})}),n.jsxs(w.Col,{md:4,className:"d-flex align-items-center justify-content-end",children:[t("total_of_skills"),": ",o]})]}),n.jsxs(w.Row,{className:"mb-2",children:[n.jsx(w.Col,{md:8,children:_&&_.length>0?n.jsxs(w.Table,{bordered:!0,hover:!0,striped:!0,responsive:!0,size:"sm",children:[n.jsx("thead",{children:n.jsxs("tr",{children:[n.jsx("th",{className:"align-top",children:t("name")}),n.jsx("th",{className:"align-top",children:t("description")}),n.jsx("th",{className:"text-center",children:t("action")})]})}),n.jsx("tbody",{children:_.map(B=>n.jsxs("tr",{children:[n.jsxs("td",{className:"align-middle",children:[n.jsx(ms,{label:B.name,onClick:()=>C(B.id)}),!!B.path&&n.jsx("p",{className:"mb-0 pl-3",children:n.jsx("i",{children:B.path})})]}),n.jsx("td",{className:"align-middle",children:B.description}),n.jsx("td",{className:"text-center align-middle",children:n.jsx(Hs,{onClick:()=>P(B.id)})})]},B.id))})]}):n.jsx(Q_,{label:t("skill")})}),n.jsx(w.Col,{md:8,className:"text-right",children:n.jsx(G_,{totalRecordCount:o,filters:s,changePageSize:B=>c({pageSize:B}),changePage:B=>c({currentPage:B})})})]})]})};function N_(e){"@babel/helpers - typeof";return N_=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},N_(e)}function Bi(e,t){if(t.length<e)throw new TypeError(e+" argument"+(e>1?"s":"")+" required, but only "+t.length+" present")}function xn(e){Bi(1,arguments);var t=Object.prototype.toString.call(e);return e instanceof Date||N_(e)==="object"&&t==="[object Date]"?new Date(e.getTime()):typeof e=="number"||t==="[object Number]"?new Date(e):((typeof e=="string"||t==="[object String]")&&typeof console<"u"&&(console.warn("Starting with v2.0.0-beta.1 date-fns doesn't accept strings as date arguments. Please use `parseISO` to parse strings. See: https://github.com/date-fns/date-fns/blob/master/docs/upgradeGuide.md#string-arguments"),console.warn(new Error().stack)),new Date(NaN))}function MN_(e,t){Bi(2,arguments);var _=xn(e),o=xn(t);return _.getFullYear()-o.getFullYear()}const ls=K.createAction("users/setUserList"),Gi=K.createAction("users/setStudentList"),a_=`${ft}/api/user`,DN_=`${ft}/api/Account/changePassword`,Vn=`${ft}/api/account`,q_=`${ft}/api/User`,Fi=`${ft}/api/usersOneRoster`,Wn=`${ft}/api/mappingRosterUsers`,ON_=e=>he.get(`${Wn}`,{params:e}),BN_=e=>he.get(`${Wn}/filters`,{params:e}),GN_=e=>he.get(`${q_}/student-filters`,{params:e}),FN_=e=>he.get(`${q_}/export-csv`,{params:e}),To=e=>he.get(`${a_}/detail-user/${e}`),zN_=e=>he.post(`${a_}`,e),HN_=e=>he.put(`${a_}/${e.id}`,e),VN_=e=>he.put(`${a_}/update-status-all`,e),WN_=e=>he.delete(`${q_}/delete-item-user/${e}`),UN_=e=>he.post(DN_,e),YN_=e=>he.post(`${Vn}/forgotchangepassword`,e),XN_=e=>he.post(`${q_}/switch-user/${e}`),ZN_=e=>he.get(`${Fi}`,{params:e}),JN_=e=>he.get(`${Fi}/${e}`),QN_=()=>he.put(`${q_}/sync-roster-user`),KN_=e=>he.post(`${Vn}/reset-password-for-admin`,e),eq_=e=>he.get(`${q_}/student-assign`,{params:e}),tq_=()=>he.get(`${ft}/api/counselor`),_q_=()=>he.get(`${ft}/api/assistant`),sq_=()=>he.get(`${ft}/api/secondaryTeacher`),zi=e=>he.get(`${a_}/all/teacher`,{params:e}),os=e=>he.post(`${a_}/student-assign`,e),nq_=e=>he.get(`${ft}/api/user/check-role-data/${e}`),oq_=(e,t)=>he.post(`${q_}/change-grade-for-student`,{studentUserId:e,gradeLevel:t}),aq_=e=>he.put(`${a_}/change-multi-teachers`,e),iq_=e=>he.put(`${a_}/change-multi-counselors`,e),rq_=e=>he.put(`${a_}/change-assistants`,e),cq_=e=>he.put(`${a_}/change-secondary-teachers`,e),lq_=(e,t)=>he.put(`${a_}/update-user-grade/${e}`,{gradeLevel:t}),dq_=e=>he.get(`${Wn}/all-userId`,{params:e}),uq_=e=>he.post(`${Vn}/re-send-welcome-mail`,e),hq_=e=>he.post(`${q_}/remove-bulk-staff`,e);var $t=(e=>(e[e.Id=0]="Id",e[e.Name=1]="Name",e[e.Email=2]="Email",e[e.Age=3]="Age",e[e.Role=4]="Role",e[e.Status=5]="Status",e[e.CreatedAt=6]="CreatedAt",e[e.RosterUser=7]="RosterUser",e[e.Grade=8]="Grade",e[e.Teacher=9]="Teacher",e[e.Assistant=10]="Assistant",e[e.Counselor=11]="Counselor",e[e.SecondaryTeacher=12]="SecondaryTeacher",e))($t||{}),Mt=(e=>(e[e.Id=0]="Id",e[e.Name=1]="Name",e[e.Email=2]="Email",e[e.Role=3]="Role",e[e.RosterUser=4]="RosterUser",e[e.Status=5]="Status",e[e.Grade=6]="Grade",e[e.Teacher=7]="Teacher",e[e.Assistant=8]="Assistant",e[e.Counselor=9]="Counselor",e[e.SecondaryTeacher=10]="SecondaryTeacher",e))(Mt||{}),bt=(e=>(e[e.Teacher=0]="Teacher",e[e.Assistant=1]="Assistant",e[e.Counselor=2]="Counselor",e[e.SecondaryTeacher=3]="SecondaryTeacher",e))(bt||{});const mq_={[$t.Id]:"filter-id",[$t.Name]:"filter-name",[$t.Email]:"filter-email",[$t.Age]:"filter-age",[$t.Role]:"filter-role",[$t.Status]:"filter-status",[$t.CreatedAt]:"filter-createdAt",[$t.RosterUser]:"filter-roster",[$t.Grade]:"filter-grade",[$t.Teacher]:"filter-teacher",[$t.Assistant]:"filter-assistant",[$t.Counselor]:"filter-counselor",[$t.SecondaryTeacher]:"filter-secondary"},gq_=[{name:"name",isCenter:!0,sortBy:$t.Name,searchBy:Mt.Name,className:"align-top",getOption:e=>({label:e||"empty",value:e})},{name:"email",isCenter:!0,sortBy:$t.Email,searchBy:Mt.Email,className:"align-top",getOption:e=>({label:e||"empty",value:e})},{name:"age",isCenter:!0,sortBy:$t.Age,className:"align-top"},{name:"role",isCenter:!0,sortBy:$t.Role,searchBy:Mt.Role,className:"align-top",getOption:e=>({label:e?e?.replace?.("SecondaryTeacher","SupportTeacher"):"empty",value:e})},{name:"active_status",isCenter:!0,sortBy:$t.Status,searchBy:Mt.Status,className:"align-top",options:[{label:"Active",value:"true"},{label:"Inactive",value:"false"}]},{name:"created_time",isCenter:!0,sortBy:$t.CreatedAt,className:"align-top"},{name:"information_roster_sourced_id_full_name_email",isCenter:!0,sortBy:$t.RosterUser,searchBy:Mt.RosterUser,className:"align-top",getOption:e=>({label:e||"empty",value:e})},{name:"impersonate",isCenter:!0,className:"align-top"},{name:"delete",isCenter:!0,className:"align-top"}],Hi={value:10},pq_={searchString:"",currentPage:1,pageSize:Hi.value},yq_={searchString:"",currentPage:1,pageSize:Hi.value},fq_={currentPage:1,pageSize:200},wq_="data:text/csv;charset=utf-8,",xs={assistantId:"",counselors:[],secondaryTeacherId:"",teacher:[],assistantEmail:"",secondaryTeacherEmail:""},vq_={studentId:0,id:"",email:"",fullName:"",gradeLevel:"",phoneNumber:"",isActive:!0,dateOfBirth:"",profileImageFileName:"",quote:"",assistantName:"",assistantEmail:"",assistantUserId:"",counselors:[],secondaryTeacherName:"",secondaryTeacherEmail:"",secondaryTeacherUserId:"",teachers:[]},jo=[{label:"K",value:"K"},{label:"G",value:"G"},{label:"1",value:"1"},{label:"2",value:"2"},{label:"3",value:"3"},{label:"4",value:"4"},{label:"5",value:"5"},{label:"6",value:"6"},{label:"7",value:"7"},{label:"8",value:"8"},{label:"9",value:"9"},{label:"10",value:"10"},{label:"11",value:"11"},{label:"12",value:"12"},...Dn?[{label:"12/13",value:"12/13"}]:[],{label:"13",value:"13"}],bq_=["K","G","1","2","3","4","5","6","7","8","9","10","11","12",...Dn?["12/13"]:[],"13"],No=[{label:"K",value:"K"},{label:"G",value:"G"},{label:"1",value:"1"},{label:"2",value:"2"},{label:"3",value:"3"},{label:"4",value:"4"},{label:"5",value:"5"},{label:"6",value:"6"},{label:"7",value:"7"},{label:"8",value:"8"},{label:"9",value:"9"},{label:"10",value:"10"},{label:"11",value:"11"},{label:"12",value:"12"},...Dn?[{label:"12/13",value:"12/13"}]:[],{label:"13",value:"13"}],qo={assistantRemoveUserId:[],counselorRemoveUserIds:[],teacherRemoveUserIds:[],teacherSwitchDataUserId:"",assistantSwitchDataUserId:"",counselorSwitchDataUserId:"",supportTeacherRemoveUserIds:[],supportTeacherSwitchDataUserId:""},Vi={id:"",firstName:"",lastName:"",email:"",fullName:"",roles:[]},$q_=()=>{const[e,t]=v.useState(pq_);return{filters:e,setFilters:t,changeFilters:o=>{const s={...e,...o};s.searchString&&o.searchString&&o.searchString!=e.searchString&&(s.currentPage=1),t(s)}}},kq_="/admin/user",xq_="/admin/create-user",Cq_="User list",Po="/home",Sq_="/home",Iq_="/admin/home",Aq_="/parent",Eq_="/admin/schools",Tq_="/list-student",jq_=()=>{const e=Ct.useNavigate(),_=new URLSearchParams(location.search).get("query"),o=Ee.useSelector(R=>R.users.userList),s=Ee.useSelector(R=>R.users.totalItems),{filters:c,changeFilters:u}=$q_(),g=_||"",[d,p]=v.useState([]),x=window.location.host.includes("-district"),f=Ee.useDispatch(),{t:A}=at.useTranslation(),T=R=>{const W=d.find(H=>H==R);p(W?d.filter(H=>H!=R):d.concat([R]))},q=v.useCallback(async()=>{if(d.length!=0){p([]);return}if(c.searchBy!==void 0&&c.searchByStrings!==void 0&&c.searchByStrings.length===0){f(ls({userList:[],totalItems:0}));return}f(se(!0));try{const R=await dq_(c);p(R.data||[])}catch(R){f(Q({type:"danger",message:R.response?.data?.title||R.message}))}f(se(!1))},[f,c,d]),E=v.useCallback(async()=>{if(c.searchBy!==void 0&&c.searchByStrings!==void 0&&c.searchByStrings.length===0){f(ls({userList:[],totalItems:0}));return}f(se(!0));try{const R=await ON_(c),{items:W,totalItems:H}=R.data;for(const J of W)J.roles=J.roles.map(F=>F!=w_.EDUTEACHER?F:"EduTeacher");f(ls({userList:W,totalItems:H}))}catch(R){f(Q({type:"danger",message:R.response?.data?.title||R.message}))}f(se(!1))},[f,c]),k=async()=>{f(se(!0));try{const R=await QN_();R.data?(f(Q({type:"success",message:`${R.data} user${R.data>1?"s have":" has"} been synchronized`})),E()):f(Q({type:"success",message:"Users synchronized"}))}catch(R){f(Q({type:"danger",message:R.response?.data?.title||R.message}))}f(se(!1))},C=R=>{if(!R)return"";const W=[],{sourcedId:H,rosterUser:J}=R;if(H&&J&&W.push(H),J){const{givenName:F,middleName:z,familyName:L,email:Z}=J,ne=[];L&&ne.push(L),z&&ne.push(z),F&&ne.push(F),W.push(ne.join(" ")||""),W.push(Z||"")}return W.join(" / ")};v.useEffect(()=>{document.title=Cq_},[]),v.useEffect(()=>{u({...c,searchString:g})},[g]),v.useEffect(()=>{E()},[JSON.stringify(c)]);const N=v.useCallback(R=>{f(Yt({isOpen:!0,type:"warning",message:A("do_you_want_to_remove_this_user"),onConfirm:async()=>{f(se(!0));try{await WN_(R),f(Q({type:"success",message:"Remove user successfully"})),c.currentPage!==1?u({currentPage:1}):E()}catch(W){f(Q({type:"danger",message:W.response?.data?.title||W.message}))}f(se(!1))}}))},[JSON.stringify(c)]),P=R=>{const W=sessionStorage.getItem(B_),{token:H,id:J,firstName:F,lastName:z,roles:L,email:Z,profileImageFileName:ne}=R.data;W?sessionStorage.setItem(jt,H):localStorage.setItem(jt,H),L.includes("Admin")&&localStorage.setItem("ROLES","Admin"),localStorage.removeItem(Mn),f(Fs({id:J,firstName:F,lastName:z,roles:L,email:Z,profileImageFileName:ne})),x?e(Eq_):L.includes("Admin")?e(Iq_):L.includes("Teacher")||L.includes("Assistant")?e(Po):L.includes("Student")?e(Sq_):L.includes("Parent")?e(Aq_):L.includes("EduTeacher")?e(Tq_):(L.includes("Counselor")||L.includes("SecondaryTeacher"))&&e(Po)},D=v.useCallback(async R=>{try{const H=(await XN_(R)).data;f(Yt({isOpen:!0,type:"warning",message:A("do_you_want_to_impersonate_this_user"),onConfirm:async()=>{f(se(!0));try{const J={email:H.email,password:"default",accessToken:H.token,loginType:Y_.Impersonate},F=await Ci(J);localStorage.clear(),P(F)}catch(J){Q({type:"danger",message:J.response?.data?.title||J.message})}f(se(!1))}}))}catch(W){f(Q({type:"danger",message:W.response?.data?.title||W.message}))}},[c]);return{userList:o,totalItems:s,filters:c,queryName:_,fullName:g,getData:E,removeData:N,changeFilters:u,reDirectDetailPage:R=>{const W=R?`${kq_}/${R}`:xq_;e(W)},switchUser:D,handleSyncRosterUsers:k,rosterUserInfo:C,userIds:d,onSelectAllUser:q,onSelectUser:T}},Nq_="_searchBox_1jz8j_1",qq_={searchBox:Nq_},Pq_=({initValue:e,onSearch:t,placeholder:_="Type something to search",className:o="",style:s={}})=>{const[c,u]=v.useState(e);v.useEffect(()=>{u(e)},[e]);const g=v.useCallback(d=>{d.key==="Enter"&&t(c)},[c,t]);return n.jsx(w.Input,{placeholder:_,value:c,onChange:d=>u(d.target.value),onKeyUp:g,className:`${o} ${qq_.searchBox}`,style:s})},K_=v.memo(Pq_),Rq_={height:38},Wi=({text:e,initValue:t,onClick:_,onSearch:o,placeholder:s="Type something to search"})=>n.jsxs("div",{className:"d-flex align-items-center",style:{gap:"8px"},children:[n.jsx("div",{children:n.jsx(zs,{text:e,onClick:_})}),n.jsx("div",{className:"flex-grow-1 ml-2",children:n.jsx(K_,{initValue:t,onSearch:o,placeholder:s,style:Rq_})})]}),Ro={YYYY:"yyyy",YY:"yy",MMMM:"MMMM",MMM:"MMM",MM:"MM",M:"M",Do:"do",DD:"dd",D:"d",HH:"HH",hh:"hh",mm:"mm",ss:"ss",A:"a"},Lq_=e=>e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),an=new Map,Mq_=(e="yyyy-MM-dd")=>{if(an.has(e))return an.get(e);const t=Object.keys(Ro).sort((_,o)=>o.length-_.length).reduce((_,o)=>{const s=new RegExp(Lq_(o),"g");return _.replace(s,Ro[o])},e);return an.set(e,t),t},Dq_=e=>/[zZ]|[+-]\d{2}(:?\d{2})?$|[+-]\d{4}$/.test(e);function ys(e,t){if(!e||e===Rn)return"";try{const _=e.includes("T")?e:e.replace(" ","T"),o=Dq_(_)?_:`${_}Z`,s=new Date(o);if(Number.isNaN(s.getTime()))return"";const c=Mq_(t);return c.includes("hh")&&!c.includes("a")&&console.warn("12-hour format without AM/PM:",t),v_.format(s,c)}catch{return""}}const Oq_={fontWeight:500},Bq_={height:38,background:"#316cd9"},Gq_=({text:e,onClick:t,className:_=""})=>n.jsxs(w.Button,{onClick:t,color:"primary",style:Bq_,className:`d-flex align-items-center ${_} gap-2`,children:[n.jsx(wj_,{}),n.jsx("span",{style:Oq_,children:e})]});function Fq_(e){return Rt({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 zq_(e){return Rt({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 Hq_(e){return Rt({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 Lo(e){return Rt({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 Vq_(e){return Rt({attr:{viewBox:"0 0 1024 1024"},child:[{tag:"path",attr:{d:"M942.2 486.2C847.4 286.5 704.1 186 512 186c-192.2 0-335.4 100.5-430.2 300.3a60.3 60.3 0 0 0 0 51.5C176.6 737.5 319.9 838 512 838c192.2 0 335.4-100.5 430.2-300.3 7.7-16.2 7.7-35 0-51.5zM512 766c-161.3 0-279.4-81.8-362.7-254C232.6 339.8 350.7 258 512 258c161.3 0 279.4 81.8 362.7 254C791.5 684.2 673.4 766 512 766zm-4-430c-97.2 0-176 78.8-176 176s78.8 176 176 176 176-78.8 176-176-78.8-176-176-176zm0 288c-61.9 0-112-50.1-112-112s50.1-112 112-112 112 50.1 112 112-50.1 112-112 112z"}}]})(e)}function Ui(e){return Rt({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 Yi(e){return Rt({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 Wq_=(e,t)=>{v.useEffect(()=>{function _(o){e.current&&!e.current.contains(o.target)&&t?.()}return document.addEventListener("mousedown",_),()=>{document.removeEventListener("mousedown",_)}},[e.current])},Uq_=e=>{const{isOpen:t,sortBy:_,filters:o,users:s,searchBy:c,defaultOptions:u,selectedOptions:g,searchKey:d,onChangeSearchKey:p,onOptionsChange:x,onSearch:f,onClose:A,onChangeFilters:T,getOption:q}=e,[E,k]=v.useState(),[C,N]=v.useState([]),P=v.useRef(null),D=v.useRef(null);Wq_(P,A);const{t:B}=at.useTranslation(),R=v.useCallback(()=>{if(!t)return;const Oe=d?.trim?.()??"";c!=null&&!u&&f?.(Oe,c),c!=null&&u&&N(u.filter(Be=>Be.label.toLowerCase().includes(Oe.toLowerCase())))},[c,d,JSON.stringify(u),t]),W=()=>{D.current&&clearTimeout(D.current),D.current=setTimeout(R,500)},H=Oe=>{const Be=Oe.target.value;p(Be)},J=v.useCallback(()=>{x?.(E,c),A?.()},[JSON.stringify(E)]),F=v.useCallback(Oe=>{const Be=Oe.target.value??"";let ce=E??[],Qe=ce.indexOf(Be);Qe>-1?ce.splice(Qe,1):ce=[...ce,Be],k(ce==null?ce:[...ce])},[JSON.stringify(E)]),z=v.useCallback(Oe=>{const Be=Oe.target.checked;k(Be?void 0:[])},[]),L=v.useCallback(()=>{T?.({...o,sortBy:_,isDescending:!0}),A?.()},[JSON.stringify(o),c]),Z=v.useCallback(()=>{T?.({...o,sortBy:_,isDescending:!1}),A?.()},[JSON.stringify(o),c]),ne=v.useMemo(()=>q?s.map(Oe=>q(Oe,B)):[],[JSON.stringify(s),JSON.stringify(q)]),de=o?.isDescending==!1&&o.sortBy===_,Ne=!!o?.isDescending&&o.sortBy===_;return v.useEffect(()=>{o?.searchBy!==c?k(void 0):k(g)},[JSON.stringify(g),o?.searchBy]),v.useEffect(()=>{N(u||[])},[JSON.stringify(u)]),v.useEffect(()=>{W()},[d,t]),{ref:P,options:ne,inputRef:D,sOptions:E,isAscending:de,isDescending:Ne,filteredOptions:C,searchKey:d,handleSearch:R,handleApplyFilter:J,handleOptionSelected:F,handleOptionSelectedAll:z,handleSortDesc:L,handleSortAsc:Z,handleChangeSearchKey:H}},Yq_=e=>{const{defaultOptions:t,onClose:_,getOption:o}=e,{ref:s,inputRef:c,options:u,sOptions:g,isAscending:d,isDescending:p,filteredOptions:x,searchKey:f,handleChangeSearchKey:A,handleApplyFilter:T,handleOptionSelected:q,handleOptionSelectedAll:E,handleSortDesc:k,handleSortAsc:C}=Uq_(e);return n.jsx(w.Popover,{...e,hideArrow:!0,className:V["popover-zindex"],children:n.jsx(w.PopoverBody,{className:"pb-3",children:n.jsxs("div",{ref:s,className:V.popover,children:[n.jsxs("div",{className:`d-flex flex-column ${V.popover__sort}`,children:[n.jsx(w.Label,{className:"font-weight-bold",children:"Sort"}),n.jsxs("div",{className:`px-1 ${V.popover__sort__item} ${d&&V["popover__sort__item--active"]}`,onClick:C,children:[n.jsx(Ui,{className:"mr-1"}),"Ascending"]}),n.jsxs("div",{className:`px-1 mt-1 ${V.popover__sort__item} ${p&&V["popover__sort__item--active"]}`,onClick:k,children:[n.jsx(Yi,{className:"mr-1"}),"Descending"]})]}),(typeof o<"u"||!!t)&&n.jsxs(v.Fragment,{children:[n.jsx("div",{className:"border border-top-1 border-bottom-0 mx-1 my-2"}),n.jsxs("div",{className:"d-flex flex-column",children:[n.jsx(w.Label,{className:"font-weight-bold",children:"Filter"}),n.jsxs("div",{className:`position-relative px-1 ${V.popover__search}`,children:[n.jsx(zq_,{className:`position-absolute ${V.popover__search__icon}`}),n.jsx(w.Input,{ref:c,className:V.popover__search__input,value:f,onChange:A})]}),n.jsxs("div",{className:`mx-1 mt-2 p-2 bg-light ${V.popover__options}`,children:[n.jsxs(w.FormGroup,{className:"d-flex align-items-center",check:!0,style:{gap:"8px"},children:[n.jsx(w.Input,{type:"checkbox",onChange:E,checked:g==null})," ",n.jsx(w.Label,{check:!0,children:"(Select all)"})]}),!!o&&!t&&u.map(N=>n.jsxs(w.FormGroup,{className:"d-flex align-items-center",check:!0,style:{gap:"8px"},children:[n.jsx(w.Input,{type:"checkbox",value:N.value,onChange:q,checked:g?.includes(N.value)||g==null})," ",n.jsx(w.Label,{check:!0,children:N.label})]},N.value)),!!t&&x.map(N=>n.jsxs(w.FormGroup,{className:"d-flex align-items-center",check:!0,style:{gap:"8px"},children:[n.jsx(w.Input,{type:"checkbox",value:N.value,onChange:q,checked:g?.includes(N.value)||g==null})," ",n.jsx(w.Label,{check:!0,children:N.label})]},N.value))]})]}),n.jsxs("div",{className:"d-flex justify-content-end mt-3",style:{gap:"8px"},children:[n.jsx(w.Button,{color:"primary",className:"mr-2",size:"sm",onClick:T,children:"Apply Filter"}),n.jsx(w.Button,{color:"secondary",size:"sm",onClick:_,children:"Cancel"})]})]})]})})})},Xq_=({data:e,popoverId:t,filters:_,searchString:o,users:s,selectedOptions:c,onOptionsChange:u,onSearch:g,onChangeFilters:d,onOpenFilter:p,onClose:x,isCenter:f,isActive:A=!1})=>{const{t:T}=at.useTranslation(),[q,E]=v.useState(""),k=v.useMemo(()=>e.sortBy!=null?mq_[e.sortBy]:"",[e.sortBy]),C=v.useMemo(()=>t===k,[k,t]),N=()=>{p?.(k,e.searchBy,q,e.sortBy)},P=D=>{E(D)};return n.jsx("th",{className:e.className,children:k&&e.sortBy!==void 0?n.jsxs("div",{className:`w-100 d-flex ${f?"justify-content-center":"justify-content-between"} align-items-center ${V["table-filter-icon"]}`,children:[T(e.name),n.jsxs("div",{className:"ml-2 p-1",id:k,onClick:N,style:{cursor:"pointer"},children:[e.sortBy!==void 0&&e.sortBy===_?.sortBy&&n.jsx("span",{children:_.isDescending?n.jsx(Yi,{}):n.jsx(Ui,{})}),_?.searchByStrings?.length&&e.searchBy===_?.searchBy?n.jsx(Hq_,{color:A?"#007bff":"#242424"}):n.jsx(Fq_,{color:A?"#007bff":"#242424"})]}),n.jsx(Yq_,{placement:"bottom-end",target:k,users:s,isOpen:C,filters:_,sortBy:e.sortBy,searchKey:q,searchBy:e.searchBy,searchString:o,defaultOptions:e.options,selectedOptions:c,onClose:x,onSearch:g,getOption:e.getOption,onChangeFilters:d,onOptionsChange:u,onChangeSearchKey:P})]}):T(e.name)})},Zq_=e=>{const{filters:t,onChangeFilters:_,isStudentFilter:o,teacherOptions:s,assistantOptions:c,counselorOptions:u,secondaryTeacherOptions:g}=e,[d,p]=v.useState(),[x,f]=v.useState([]),[A,T]=v.useState({...fq_,isDescending:t.isDescending,searchString:t.searchString}),q=Ee.useDispatch(),E=Ct.useLocation(),k=v.useCallback(async B=>{try{const W=(o?await GN_(A):await BN_({...A,byStudent:B})).data?.items||[];f(W)}catch(R){q(Q({type:"danger",message:R.response?.data?.title||R.message}))}},[JSON.stringify(A),o]),C=v.useCallback((B,R,W,H)=>{p(B),T({...A,searchBy:R,searchStringBy:W,isDescending:t.sortBy===H?t.isDescending:void 0,searchString:t.searchString})},[JSON.stringify(A),t.isDescending,t.searchString]),N=()=>{p("")},P=v.useCallback((B,R)=>{T({...A,searchBy:R,searchStringBy:B})},[JSON.stringify(A)]),D=v.useCallback((B,R)=>{R&&_?.({...t,[Mt[R]]:B})},[JSON.stringify(t)]);return v.useEffect(()=>{if(!E.pathname.includes("users/assign-student"))return;const B=W=>W.sort((H,J)=>H.localeCompare(J)),R=A.searchStringBy?.toLowerCase()||"";if(A.searchBy===Mt.Grade)f(bq_);else{let W=[];switch(A.searchBy){case Mt.Name:k(!0);break;case Mt.Teacher:W=s?.map(z=>z.label).filter(Boolean)||[];break;case Mt.Assistant:W=c?.map(z=>z.label).filter(Boolean)||[];break;case Mt.Counselor:W=u?.map(z=>z.label).filter(Boolean)||[];break;case Mt.SecondaryTeacher:W=g?.map(z=>z.label).filter(Boolean)||[];break}const H=Array.from(new Set(W)),J=R?H.filter(z=>z.toLowerCase().includes(R)):H,F=B(J);f(F)}},[JSON.stringify(A),s,c,u,g,E.pathname]),v.useEffect(()=>{!(E.pathname.includes("users/assign-student")&&A.searchBy!==void 0)&&A.searchBy!==void 0&&k()},[JSON.stringify(A),E.pathname]),{popoverFilters:A,popoverId:d,users:x,handleFilterIcon:C,handleCloseFilter:N,handleSearch:P,handleChangeFilters:D}},Xi=({headers:e,filters:t,onChangeFilters:_,isStudentFilter:o,teacherOptions:s=[],assistantOptions:c=[],counselorOptions:u=[],secondaryTeacherOptions:g=[]})=>{const{popoverId:d,users:p,handleFilterIcon:x,handleCloseFilter:f,handleSearch:A,handleChangeFilters:T}=Zq_({filters:t,onChangeFilters:_,isStudentFilter:o,teacherOptions:s,assistantOptions:c,counselorOptions:u,secondaryTeacherOptions:g}),q=Object.entries(t).filter(([C,N])=>N!==""&&!(Array.isArray(N)&&N.length===0)&&N!==null&&N!==void 0).map(([C])=>C),E=Object.entries(Mt).filter(([C,N])=>isNaN(Number(C))),k=q.map(C=>E.find(([N])=>N===C)).filter(C=>!!C);return n.jsx("tr",{children:e.map(C=>C.onSelectAll?n.jsx("th",{className:`align-middle text-center ${C.className}`,children:n.jsx("input",{type:"checkbox",onChange:()=>C.onSelectAll?.(),checked:C.isCheckAll??!1})},C.name):n.jsx(Xq_,{users:p,data:C,isCenter:C.isCenter,filters:t,popoverId:d,selectedOptions:t.searchByStrings,onSearch:A,onClose:f,onOpenFilter:x,onChangeFilters:_,onOptionsChange:T,isActive:typeof C.searchBy=="number"&&k.some(([N,P])=>P===C.searchBy)},C.name))})},Jq_=()=>{const e=Ee.useDispatch(),t=Ee.useSelector(c=>c?.common?.user?.schoolName)||"",_=async c=>{e(se(!0));try{const g=(await FN_(c)).data,d=o(g),p=document.createElement("a");p.href=d,p.download=`${t}_Users_Report.csv`,p.click()}catch(u){e(Q({type:"danger",message:u.response?.data?.title||u.message}))}e(se(!1))},o=c=>{let u=`First Name,Last Name,Email,Phone,Age,Grade,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
|
|
10
10
|
`;const g=c.map(d=>{const p=d.dateOfBirth!==Rn?v_.differenceInCalendarYears(new Date,v_.parseISO(d.dateOfBirth)):"";return`${s(d.firstName)},${s(d.lastName)},${s(d.email)},${s(d.phoneNumber)},${p},${s(d.grade)},${s(d.roles.join(", ").replace("SecondaryTeacher","SupportTeacher"))},${d.isActive?"Active":"Inactive"},${ys(d?.createTime,"yyyy-MM-dd HH:mm")},${s(d.sourcedId)},${s(d.rosterUser?.status)},${s(d.rosterUser?.familyName)},${s(d.rosterUser?.middleName)},${s(d.rosterUser?.givenName)},${s(d.rosterUser?.email)},${s(d.rosterUser?.role)},${s(d.rosterUser?.grades)},${s(d.teachers)},${s(d.assistants)},${s(d.counselors)},${s(d.supportTeachers)},${s(d.eduTeachers)}`}).join(`
|
|
11
11
|
`);return`${wq_}${u}${encodeURIComponent(g)}`},s=c=>c?`"${c.replace(/"/g,'""').replaceAll(/\n/g," ")}"`:"";return{exportUsers:_}},Zi=`${ft}/api/ImportCsv/csv`,Zs=`${ft}/api/Teacher`,Qq_=(e,t)=>Ot.post(`${Zi}/${t}`,e),Mo=e=>Ot.post(`${Zi}/importClassReflection`,e),Kq_=(e,t)=>Ot.post(`${Zs}/adminImportStudentByTeacherId/${e}`,t),eP_=e=>Ot.post(`${Zs}/adminImport`,e),tP_=()=>he.get(`${Zs}/download-template-file-user`),_P_=(e,t)=>Ot.post(`${Zs}/validate-csv-template-student/${t}`,e);var Ji=(e=>(e.Students="students",e.Subjects="subjects",e.Grades="grades",e.Attendances="attendances",e.ClassReflection="classReflection",e.Others="others",e.AllUser="allUser",e))(Ji||{});const rn="csvupload",Do={teacherName:"",teacherEmail:"",studentIds:[],file:""},sP_=()=>{const e=Ee.useDispatch(),t=Ee.useSelector(F=>F.common.isLoading),[_,o]=v.useState(null),[s,c]=v.useState(),[u,g]=v.useState([]),[d,p]=v.useState(Do),[x,f]=v.useState(),A=window.location.hostname,T=A.includes("isb")||A.includes("stage"),[q,E]=v.useState(0),[k,C]=v.useState(""),N=async()=>{e(se(!0));try{const L=await tP_();var F=new Blob([L.data.content],{type:"text/csv"});const Z=window.URL.createObjectURL(F);var z=document.createElement("a");z.href=Z,z.setAttribute("download",L.data.nameFile),z.click(),e(Q({type:"success",message:"Download successfully"}))}catch(L){e(Q({type:"danger",message:L.message}))}e(se(!1))},P=v.useCallback(async F=>{if(!_||!F)return;e(se(!0));try{const ne=new FormData;if(ne.append("file",F,F.name),_=="allUser"){let Ne=(await F.text()).trim();const Oe=Ne.split(`
|
|
12
12
|
`).map(qe=>qe.trim()),Be=Oe.findIndex(qe=>qe.split(",").includes("FirstName"));if(Be===0)throw new Error("Invalid CSV: Missing header row.");Ne=Oe.slice(Be).join(`
|
package/dist/index.modern.js
CHANGED
|
@@ -15587,32 +15587,32 @@ const iP_ = {
|
|
|
15587
15587
|
}, [JSON.stringify(c)]);
|
|
15588
15588
|
const N = ae(
|
|
15589
15589
|
(R) => {
|
|
15590
|
-
f(
|
|
15591
|
-
|
|
15592
|
-
|
|
15593
|
-
|
|
15594
|
-
|
|
15595
|
-
|
|
15596
|
-
|
|
15597
|
-
|
|
15590
|
+
f(
|
|
15591
|
+
c_({
|
|
15592
|
+
isOpen: !0,
|
|
15593
|
+
type: "warning",
|
|
15594
|
+
message: C("do_you_want_to_remove_this_user"),
|
|
15595
|
+
onConfirm: async () => {
|
|
15596
|
+
f(_e(!0));
|
|
15597
|
+
try {
|
|
15598
15598
|
await Oq_(R), f(
|
|
15599
15599
|
Q({
|
|
15600
15600
|
type: "success",
|
|
15601
15601
|
message: "Remove user successfully"
|
|
15602
15602
|
})
|
|
15603
15603
|
), c.currentPage !== 1 ? u({ currentPage: 1 }) : S();
|
|
15604
|
+
} catch (H) {
|
|
15605
|
+
f(
|
|
15606
|
+
Q({
|
|
15607
|
+
type: "danger",
|
|
15608
|
+
message: H.response?.data?.title || H.message
|
|
15609
|
+
})
|
|
15610
|
+
);
|
|
15604
15611
|
}
|
|
15605
|
-
|
|
15606
|
-
|
|
15607
|
-
|
|
15608
|
-
|
|
15609
|
-
Q({
|
|
15610
|
-
type: "danger",
|
|
15611
|
-
message: H.response?.data?.title || H.message
|
|
15612
|
-
})
|
|
15613
|
-
);
|
|
15614
|
-
}
|
|
15615
|
-
f(_e(!1));
|
|
15612
|
+
f(_e(!1));
|
|
15613
|
+
}
|
|
15614
|
+
})
|
|
15615
|
+
);
|
|
15616
15616
|
},
|
|
15617
15617
|
[JSON.stringify(c)]
|
|
15618
15618
|
), P = (R) => {
|