mario-core 2.0.97-release → 2.0.98-release

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. package/dist/Dashboard-D2zLzwFR.mjs +206 -0
  2. package/dist/Dashboard-dOwpd3sn.js +1 -0
  3. package/dist/EmailTemplateDetail-D07dUCZL.js +1 -0
  4. package/dist/EmailTemplateDetail-uNlh3Otz.mjs +443 -0
  5. package/dist/EmailTemplateList-B5ee4Byb.js +1 -0
  6. package/dist/EmailTemplateList-EZ_sAp6W.mjs +170 -0
  7. package/dist/GalleryList-CdyApn-m.mjs +329 -0
  8. package/dist/GalleryList-DFuoYp_Q.js +1 -0
  9. package/dist/Login-8c69l-hn.js +1 -0
  10. package/dist/Login-MzPc2sA6.mjs +1684 -0
  11. package/dist/NotificationList-BP871ggG.mjs +3982 -0
  12. package/dist/NotificationList-CzX65qMV.js +2 -0
  13. package/dist/SkillList-C-aJeufd.mjs +386 -0
  14. package/dist/SkillList-hMvqDcsQ.js +1 -0
  15. package/dist/TeacherSelector-CV9c0Cn8.js +1 -0
  16. package/dist/TeacherSelector-XuYxdZgr.mjs +30 -0
  17. package/dist/TheContent-BfT4R2Gc.mjs +38 -0
  18. package/dist/TheContent-BicDxizL.js +1 -0
  19. package/dist/UserContainer-DR6lGYNl.js +5 -0
  20. package/dist/UserContainer-Ip-sYnrv.mjs +2902 -0
  21. package/dist/UserDetail-iw6l5L3a.mjs +903 -0
  22. package/dist/UserDetail-uR6dMDOB.js +1 -0
  23. package/dist/UserList-DLC9FDWG.mjs +1252 -0
  24. package/dist/UserList-DUiZTiTR.js +7 -0
  25. package/dist/constants-DUelcmx7.js +1 -0
  26. package/dist/constants-QjFnVl1d.mjs +286 -0
  27. package/dist/index--POWjYN0.mjs +19073 -0
  28. package/dist/index-KWXe_Hjz.js +15 -0
  29. package/dist/index.js +1 -1
  30. package/dist/index.modern.js +1 -1
  31. package/dist/mailCategoryService-B9Yboyna.mjs +11 -0
  32. package/dist/mailCategoryService-DAw3X_PE.js +1 -0
  33. package/dist/services/userService.d.ts +1 -0
  34. package/dist/userService-DEwtByu1.js +1 -0
  35. package/dist/userService-DxucAe6U.mjs +56 -0
  36. package/package.json +1 -1
@@ -0,0 +1,386 @@
1
+ import { jsx as t, jsxs as h } from "react/jsx-runtime";
2
+ import { useState as N, useEffect as I, forwardRef as V, useCallback as _, useRef as q } from "react";
3
+ import { Row as B, Col as y, Input as M, Label as P, Table as z } from "reactstrap";
4
+ import { useTranslation as R } from "react-i18next";
5
+ import { i as E, B as O, $ as Q, a0 as H, Y as J, E as K, J as X, b as f, a1 as Y, c as S, O as G, X as W, P as Z, Q as ee, S as te, T as se, U as ae } from "./index--POWjYN0.mjs";
6
+ import { Formik as le } from "formik";
7
+ import * as T from "yup";
8
+ import { useSelector as j, useDispatch as A } from "react-redux";
9
+ const L = `${O}/api/Skill`, U = (e) => E.get(L, { params: e }), ne = (e) => E.get(`${L}/${e}`), ie = (e) => E.post(L, e), re = (e) => E.put(`${L}/${e.id}`, e), oe = (e) => E.delete(`${L}/${e}`), ce = (e) => {
10
+ const [s, c] = N([]);
11
+ I(() => {
12
+ o();
13
+ }, []);
14
+ const o = async () => {
15
+ try {
16
+ const i = await U();
17
+ c(i.data.items);
18
+ } catch (i) {
19
+ console.error(i.message);
20
+ }
21
+ }, { id: m, isDisabled: l } = e, u = s.map((i) => ({
22
+ id: i.id,
23
+ value: i.id,
24
+ label: i.path ? `${i.path}/${i.name}` : i.name
25
+ }));
26
+ return /* @__PURE__ */ t(
27
+ Q,
28
+ {
29
+ options: u,
30
+ defaultValue: m,
31
+ ...e,
32
+ isDisabled: l
33
+ }
34
+ );
35
+ }, de = T.object({
36
+ name: T.string().required("Name is required"),
37
+ description: T.string()
38
+ }), me = (e, s) => {
39
+ const {
40
+ header: c,
41
+ confirmText: o,
42
+ onConfirm: m,
43
+ skillDetail: l,
44
+ onCancel: u,
45
+ edited: i,
46
+ setEdited: n,
47
+ setEditedTrue: r,
48
+ setEditedFalse: k,
49
+ isDisabled: b
50
+ } = e, { t: d } = R();
51
+ return /* @__PURE__ */ t(
52
+ le,
53
+ {
54
+ initialValues: l,
55
+ enableReinitialize: !0,
56
+ validationSchema: de,
57
+ onSubmit: (g, p) => {
58
+ m(g), p.resetForm();
59
+ },
60
+ children: (g) => {
61
+ const {
62
+ values: p,
63
+ touched: x,
64
+ errors: C,
65
+ handleChange: D,
66
+ handleBlur: w,
67
+ handleSubmit: $,
68
+ resetForm: F
69
+ } = g;
70
+ return /* @__PURE__ */ t(
71
+ H,
72
+ {
73
+ header: c,
74
+ confirmText: o,
75
+ onConfirm: $,
76
+ ref: s,
77
+ onCancel: () => {
78
+ u(), F();
79
+ },
80
+ edited: i,
81
+ setEdited: n,
82
+ setEditedFalse: k,
83
+ children: /* @__PURE__ */ h(B, { children: [
84
+ /* @__PURE__ */ h(y, { md: 12, className: "mb-2", children: [
85
+ /* @__PURE__ */ t(J, { text: d("name") }),
86
+ /* @__PURE__ */ t(
87
+ M,
88
+ {
89
+ name: "name",
90
+ placeholder: d("name"),
91
+ value: p.name,
92
+ onChange: (a) => {
93
+ D(a), r();
94
+ },
95
+ onBlur: w("name")
96
+ }
97
+ ),
98
+ x.name && C.name && /* @__PURE__ */ t(
99
+ K,
100
+ {
101
+ text: C.name
102
+ }
103
+ )
104
+ ] }),
105
+ /* @__PURE__ */ h(y, { md: 12, className: "mb-2", children: [
106
+ /* @__PURE__ */ t(P, { children: d("description") }),
107
+ /* @__PURE__ */ t(
108
+ M,
109
+ {
110
+ type: "textarea",
111
+ rows: 5,
112
+ name: "description",
113
+ placeholder: d("description"),
114
+ value: p.description,
115
+ onChange: (a) => {
116
+ D(a), r();
117
+ },
118
+ onBlur: w("description")
119
+ }
120
+ )
121
+ ] }),
122
+ /* @__PURE__ */ h(y, { md: 12, className: "mb-2", children: [
123
+ /* @__PURE__ */ t(P, { children: d("parent_category") }),
124
+ /* @__PURE__ */ t(
125
+ ce,
126
+ {
127
+ isDisabled: b,
128
+ onChange: (a) => {
129
+ g.setFieldValue(
130
+ "parentSkillId",
131
+ a.value
132
+ ), r();
133
+ },
134
+ id: p.parentSkillId
135
+ }
136
+ )
137
+ ] })
138
+ ] })
139
+ }
140
+ );
141
+ }
142
+ }
143
+ );
144
+ }, ue = V(me), he = "Skill list", pe = () => {
145
+ const e = j((n) => n.skills.skillList), s = j((n) => n.skills.totalItems), { t: c } = R(), { filters: o, changeFilters: m } = X(), l = A(), u = _(async () => {
146
+ l(f(!0));
147
+ try {
148
+ const n = await U(o), { items: r, totalItems: k } = n.data;
149
+ l(Y({ skillList: r, totalItems: k }));
150
+ } catch (n) {
151
+ l(
152
+ S({
153
+ type: "danger",
154
+ message: n.response?.data?.title || n.message
155
+ })
156
+ );
157
+ }
158
+ l(f(!1));
159
+ }, [l, o]), i = _(
160
+ (n) => {
161
+ l(f(!0));
162
+ try {
163
+ l(
164
+ G({
165
+ isOpen: !0,
166
+ type: "warning",
167
+ message: c("do_you_want_to_remove_this_skill"),
168
+ onConfirm: async () => {
169
+ try {
170
+ await oe(n), l(
171
+ S({
172
+ type: "success",
173
+ message: c("remove_skill_successfully")
174
+ })
175
+ ), m({ currentPage: 1 });
176
+ } catch (r) {
177
+ l(
178
+ S({
179
+ type: "danger",
180
+ message: r.response?.data?.title || r.message || "Error occured"
181
+ })
182
+ );
183
+ }
184
+ }
185
+ })
186
+ );
187
+ } catch (r) {
188
+ l(
189
+ S({
190
+ type: "danger",
191
+ message: r.response?.data?.title || r.message || "Error occured"
192
+ })
193
+ );
194
+ }
195
+ l(f(!1));
196
+ },
197
+ [o]
198
+ );
199
+ return I(() => {
200
+ document.title = he;
201
+ }, []), I(() => {
202
+ u();
203
+ }, [o]), {
204
+ skillList: e,
205
+ totalItems: s,
206
+ filters: o,
207
+ changeFilters: m,
208
+ getData: u,
209
+ removeData: i
210
+ };
211
+ }, v = {
212
+ name: "",
213
+ description: "",
214
+ path: "",
215
+ parentSkillId: null
216
+ }, ge = () => {
217
+ const e = A(), [s, c] = N(0), [o, m] = N(v), [l, u] = N(!1), i = async () => {
218
+ localStorage.setItem(window.location.href, "true"), u(!0);
219
+ }, n = async () => {
220
+ localStorage.getItem(window.location.href) && localStorage.removeItem(window.location.href), u(!1);
221
+ };
222
+ I(() => {
223
+ s ? k() : m(v);
224
+ }, [s]);
225
+ const r = () => {
226
+ c(0), m(v);
227
+ };
228
+ I(() => {
229
+ n();
230
+ }, []);
231
+ const k = _(async () => {
232
+ e(f(!0));
233
+ try {
234
+ const d = await ne(s);
235
+ m(d.data);
236
+ } catch (d) {
237
+ e(
238
+ S({
239
+ type: "danger",
240
+ message: d.response?.data?.title || d.message
241
+ })
242
+ );
243
+ }
244
+ e(f(!1));
245
+ }, [s]), b = _(
246
+ async (d, g) => {
247
+ e(f(!0));
248
+ try {
249
+ await (s ? re : ie)(d), e(
250
+ S({
251
+ type: "success",
252
+ message: `${s ? "Update" : "Create"} skill successfully`
253
+ })
254
+ ), g && g(), s && c(0);
255
+ } catch (p) {
256
+ e(
257
+ S({
258
+ type: "danger",
259
+ message: p.response?.data?.title || p.message
260
+ })
261
+ );
262
+ }
263
+ e(f(!1));
264
+ },
265
+ [s, o]
266
+ );
267
+ return {
268
+ id: s,
269
+ setId: c,
270
+ skillDetail: o,
271
+ confirmData: b,
272
+ initValue: v,
273
+ reset: r,
274
+ edited: l,
275
+ setEdited: u,
276
+ setEditedTrue: i,
277
+ setEditedFalse: n
278
+ };
279
+ }, Ie = () => {
280
+ const e = q(null), { t: s } = R(), {
281
+ skillList: c,
282
+ totalItems: o,
283
+ filters: m,
284
+ changeFilters: l,
285
+ getData: u,
286
+ removeData: i
287
+ } = pe(), {
288
+ id: n,
289
+ setId: r,
290
+ skillDetail: k,
291
+ confirmData: b,
292
+ reset: d,
293
+ edited: g,
294
+ setEdited: p,
295
+ setEditedTrue: x,
296
+ setEditedFalse: C
297
+ } = ge(), D = (a) => {
298
+ r(a || 0), e && e.current && e.current.toggle();
299
+ }, w = (a) => {
300
+ b(a, () => {
301
+ e && e.current && e.current.toggle(), u();
302
+ }), C();
303
+ }, $ = (a) => {
304
+ i(a);
305
+ }, F = () => d();
306
+ return /* @__PURE__ */ h("div", { className: "fadeIn animated", children: [
307
+ /* @__PURE__ */ t(
308
+ ue,
309
+ {
310
+ ref: e,
311
+ header: s(n ? "edit_skill" : "create_skill"),
312
+ confirmText: s(n ? "update" : "create"),
313
+ onCancel: F,
314
+ onConfirm: w,
315
+ skillDetail: k,
316
+ edited: g,
317
+ setEdited: p,
318
+ setEditedTrue: x,
319
+ setEditedFalse: C,
320
+ isDisabled: n
321
+ }
322
+ ),
323
+ /* @__PURE__ */ t(W, { when: g }),
324
+ /* @__PURE__ */ h(B, { className: "my-2", children: [
325
+ /* @__PURE__ */ t(y, { md: 4, children: /* @__PURE__ */ t(
326
+ Z,
327
+ {
328
+ text: s("create_skill"),
329
+ onClick: () => D()
330
+ }
331
+ ) }),
332
+ /* @__PURE__ */ h(
333
+ y,
334
+ {
335
+ md: 4,
336
+ className: "d-flex align-items-center justify-content-end",
337
+ children: [
338
+ s("total_of_skills"),
339
+ ": ",
340
+ o
341
+ ]
342
+ }
343
+ )
344
+ ] }),
345
+ /* @__PURE__ */ h(B, { className: "mb-2", children: [
346
+ /* @__PURE__ */ t(y, { md: 8, children: c && c.length > 0 ? /* @__PURE__ */ h(z, { bordered: !0, hover: !0, striped: !0, responsive: !0, size: "sm", children: [
347
+ /* @__PURE__ */ t("thead", { children: /* @__PURE__ */ h("tr", { children: [
348
+ /* @__PURE__ */ t("th", { className: "align-top", children: s("name") }),
349
+ /* @__PURE__ */ t("th", { className: "align-top", children: s("description") }),
350
+ /* @__PURE__ */ t("th", { className: "text-center", children: s("action") })
351
+ ] }) }),
352
+ /* @__PURE__ */ t("tbody", { children: c.map((a) => /* @__PURE__ */ h("tr", { children: [
353
+ /* @__PURE__ */ h("td", { className: "align-middle", children: [
354
+ /* @__PURE__ */ t(
355
+ ee,
356
+ {
357
+ label: a.name,
358
+ onClick: () => D(a.id)
359
+ }
360
+ ),
361
+ !!a.path && /* @__PURE__ */ t("p", { className: "mb-0 pl-3", children: /* @__PURE__ */ t("i", { children: a.path }) })
362
+ ] }),
363
+ /* @__PURE__ */ t("td", { className: "align-middle", children: a.description }),
364
+ /* @__PURE__ */ t("td", { className: "text-center align-middle", children: /* @__PURE__ */ t(
365
+ te,
366
+ {
367
+ onClick: () => $(a.id)
368
+ }
369
+ ) })
370
+ ] }, a.id)) })
371
+ ] }) : /* @__PURE__ */ t(se, { label: s("skill") }) }),
372
+ /* @__PURE__ */ t(y, { md: 8, className: "text-right", children: /* @__PURE__ */ t(
373
+ ae,
374
+ {
375
+ totalRecordCount: o,
376
+ filters: m,
377
+ changePageSize: (a) => l({ pageSize: a }),
378
+ changePage: (a) => l({ currentPage: a })
379
+ }
380
+ ) })
381
+ ] })
382
+ ] });
383
+ };
384
+ export {
385
+ Ie as default
386
+ };
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),m=require("react"),u=require("reactstrap"),v=require("react-i18next"),s=require("./index-KWXe_Hjz.js"),R=require("formik"),T=require("yup"),D=require("react-redux");function q(t){const a=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const i in t)if(i!=="default"){const o=Object.getOwnPropertyDescriptor(t,i);Object.defineProperty(a,i,o.get?o:{enumerable:!0,get:()=>t[i]})}}return a.default=t,Object.freeze(a)}const _=q(T),b=`${s.BASE_URL}/api/Skill`,N=t=>s.api.get(b,{params:t}),$=t=>s.api.get(`${b}/${t}`),A=t=>s.api.post(b,t),F=t=>s.api.put(`${b}/${t.id}`,t),B=t=>s.api.delete(`${b}/${t}`),M=t=>{const[a,i]=m.useState([]);m.useEffect(()=>{o()},[]);const o=async()=>{try{const c=await N();i(c.data.items)}catch(c){console.error(c.message)}},{id:g,isDisabled:l}=t,p=a.map(c=>({id:c.id,value:c.id,label:c.path?`${c.path}/${c.name}`:c.name}));return e.jsx(s.CustomSelector,{options:p,defaultValue:g,...t,isDisabled:l})},O=_.object({name:_.string().required("Name is required"),description:_.string()}),P=(t,a)=>{const{header:i,confirmText:o,onConfirm:g,skillDetail:l,onCancel:p,edited:c,setEdited:r,setEditedTrue:d,setEditedFalse:j,isDisabled:k}=t,{t:h}=v.useTranslation();return e.jsx(R.Formik,{initialValues:l,enableReinitialize:!0,validationSchema:O,onSubmit:(f,x)=>{g(f),x.resetForm()},children:f=>{const{values:x,touched:E,errors:y,handleChange:S,handleBlur:C,handleSubmit:I,resetForm:w}=f;return e.jsx(s.CommonModal,{header:i,confirmText:o,onConfirm:I,ref:a,onCancel:()=>{p(),w()},edited:c,setEdited:r,setEditedFalse:j,children:e.jsxs(u.Row,{children:[e.jsxs(u.Col,{md:12,className:"mb-2",children:[e.jsx(s.RequiredLabel,{text:h("name")}),e.jsx(u.Input,{name:"name",placeholder:h("name"),value:x.name,onChange:n=>{S(n),d()},onBlur:C("name")}),E.name&&y.name&&e.jsx(s.ErrorHandler,{text:y.name})]}),e.jsxs(u.Col,{md:12,className:"mb-2",children:[e.jsx(u.Label,{children:h("description")}),e.jsx(u.Input,{type:"textarea",rows:5,name:"description",placeholder:h("description"),value:x.description,onChange:n=>{S(n),d()},onBlur:C("description")})]}),e.jsxs(u.Col,{md:12,className:"mb-2",children:[e.jsx(u.Label,{children:h("parent_category")}),e.jsx(M,{isDisabled:k,onChange:n=>{f.setFieldValue("parentSkillId",n.value),d()},id:x.parentSkillId})]})]})})}})},z=m.forwardRef(P),V="Skill list",U=()=>{const t=D.useSelector(r=>r.skills.skillList),a=D.useSelector(r=>r.skills.totalItems),{t:i}=v.useTranslation(),{filters:o,changeFilters:g}=s.useFilters(),l=D.useDispatch(),p=m.useCallback(async()=>{l(s.setLoading(!0));try{const r=await N(o),{items:d,totalItems:j}=r.data;l(s.setSkillList({skillList:d,totalItems:j}))}catch(r){l(s.setAlert({type:"danger",message:r.response?.data?.title||r.message}))}l(s.setLoading(!1))},[l,o]),c=m.useCallback(r=>{l(s.setLoading(!0));try{l(s.setModal({isOpen:!0,type:"warning",message:i("do_you_want_to_remove_this_skill"),onConfirm:async()=>{try{await B(r),l(s.setAlert({type:"success",message:i("remove_skill_successfully")})),g({currentPage:1})}catch(d){l(s.setAlert({type:"danger",message:d.response?.data?.title||d.message||"Error occured"}))}}}))}catch(d){l(s.setAlert({type:"danger",message:d.response?.data?.title||d.message||"Error occured"}))}l(s.setLoading(!1))},[o]);return m.useEffect(()=>{document.title=V},[]),m.useEffect(()=>{p()},[o]),{skillList:t,totalItems:a,filters:o,changeFilters:g,getData:p,removeData:c}},L={name:"",description:"",path:"",parentSkillId:null},H=()=>{const t=D.useDispatch(),[a,i]=m.useState(0),[o,g]=m.useState(L),[l,p]=m.useState(!1),c=async()=>{localStorage.setItem(window.location.href,"true"),p(!0)},r=async()=>{localStorage.getItem(window.location.href)&&localStorage.removeItem(window.location.href),p(!1)};m.useEffect(()=>{a?j():g(L)},[a]);const d=()=>{i(0),g(L)};m.useEffect(()=>{r()},[]);const j=m.useCallback(async()=>{t(s.setLoading(!0));try{const h=await $(a);g(h.data)}catch(h){t(s.setAlert({type:"danger",message:h.response?.data?.title||h.message}))}t(s.setLoading(!1))},[a]),k=m.useCallback(async(h,f)=>{t(s.setLoading(!0));try{await(a?F:A)(h),t(s.setAlert({type:"success",message:`${a?"Update":"Create"} skill successfully`})),f&&f(),a&&i(0)}catch(x){t(s.setAlert({type:"danger",message:x.response?.data?.title||x.message}))}t(s.setLoading(!1))},[a,o]);return{id:a,setId:i,skillDetail:o,confirmData:k,initValue:L,reset:d,edited:l,setEdited:p,setEditedTrue:c,setEditedFalse:r}},K=()=>{const t=m.useRef(null),{t:a}=v.useTranslation(),{skillList:i,totalItems:o,filters:g,changeFilters:l,getData:p,removeData:c}=U(),{id:r,setId:d,skillDetail:j,confirmData:k,reset:h,edited:f,setEdited:x,setEditedTrue:E,setEditedFalse:y}=H(),S=n=>{d(n||0),t&&t.current&&t.current.toggle()},C=n=>{k(n,()=>{t&&t.current&&t.current.toggle(),p()}),y()},I=n=>{c(n)},w=()=>h();return e.jsxs("div",{className:"fadeIn animated",children:[e.jsx(z,{ref:t,header:a(r?"edit_skill":"create_skill"),confirmText:a(r?"update":"create"),onCancel:w,onConfirm:C,skillDetail:j,edited:f,setEdited:x,setEditedTrue:E,setEditedFalse:y,isDisabled:r}),e.jsx(s.QuitPrompt,{when:f}),e.jsxs(u.Row,{className:"my-2",children:[e.jsx(u.Col,{md:4,children:e.jsx(s.AddButton,{text:a("create_skill"),onClick:()=>S()})}),e.jsxs(u.Col,{md:4,className:"d-flex align-items-center justify-content-end",children:[a("total_of_skills"),": ",o]})]}),e.jsxs(u.Row,{className:"mb-2",children:[e.jsx(u.Col,{md:8,children:i&&i.length>0?e.jsxs(u.Table,{bordered:!0,hover:!0,striped:!0,responsive:!0,size:"sm",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{className:"align-top",children:a("name")}),e.jsx("th",{className:"align-top",children:a("description")}),e.jsx("th",{className:"text-center",children:a("action")})]})}),e.jsx("tbody",{children:i.map(n=>e.jsxs("tr",{children:[e.jsxs("td",{className:"align-middle",children:[e.jsx(s.LinkEditButton,{label:n.name,onClick:()=>S(n.id)}),!!n.path&&e.jsx("p",{className:"mb-0 pl-3",children:e.jsx("i",{children:n.path})})]}),e.jsx("td",{className:"align-middle",children:n.description}),e.jsx("td",{className:"text-center align-middle",children:e.jsx(s.DeleteButtonIcon,{onClick:()=>I(n.id)})})]},n.id))})]}):e.jsx(s.EmptyDataAlert,{label:a("skill")})}),e.jsx(u.Col,{md:8,className:"text-right",children:e.jsx(s.CustomPagination,{totalRecordCount:o,filters:g,changePageSize:n=>l({pageSize:n}),changePage:n=>l({currentPage:n})})})]})]})};exports.default=K;
@@ -0,0 +1 @@
1
+ "use strict";const e=require("react/jsx-runtime"),i=require("react"),l=require("./index-KWXe_Hjz.js"),u=({options:t,isDisabled:r,scrollBottom:c,onCreateOption:d,...a})=>{const[s,n]=i.useState(),o=()=>{n(void 0)};return e.jsxs("div",{className:"w-100",children:[e.jsx("div",{className:"w-100",children:e.jsx(l.CreatableSelect$1,{isDisabled:r,options:t,menuPlacement:c?"top":"auto",onFocus:o,...a})}),!!s&&e.jsx("p",{className:"text-danger mb-0 mt-1",children:s})]})};exports.TeacherSelector=u;
@@ -0,0 +1,30 @@
1
+ import { jsxs as n, jsx as e } from "react/jsx-runtime";
2
+ import { useState as m } from "react";
3
+ import { am as l } from "./index--POWjYN0.mjs";
4
+ const x = ({
5
+ options: s,
6
+ isDisabled: o,
7
+ scrollBottom: t,
8
+ onCreateOption: i,
9
+ ...a
10
+ }) => {
11
+ const [r, c] = m();
12
+ return /* @__PURE__ */ n("div", { className: "w-100", children: [
13
+ /* @__PURE__ */ e("div", { className: "w-100", children: /* @__PURE__ */ e(
14
+ l,
15
+ {
16
+ isDisabled: o,
17
+ options: s,
18
+ menuPlacement: t ? "top" : "auto",
19
+ onFocus: () => {
20
+ c(void 0);
21
+ },
22
+ ...a
23
+ }
24
+ ) }),
25
+ !!r && /* @__PURE__ */ e("p", { className: "text-danger mb-0 mt-1", children: r })
26
+ ] });
27
+ };
28
+ export {
29
+ x as T
30
+ };
@@ -0,0 +1,38 @@
1
+ import { jsx as a, jsxs as e } from "react/jsx-runtime";
2
+ import { memo as m, Suspense as r } from "react";
3
+ import { useLocation as p, Routes as h, Route as t } from "react-router-dom";
4
+ import { CContainer as g } from "@coreui/react";
5
+ import { H as u } from "./index--POWjYN0.mjs";
6
+ const N = /* @__PURE__ */ a("div", { className: "app-initial-loader", style: { position: "relative", height: "100%", minHeight: "400px", backgroundColor: "transparent", width: "100%" }, children: /* @__PURE__ */ e("div", { className: "loader-container", children: [
7
+ /* @__PURE__ */ a(
8
+ "img",
9
+ {
10
+ src: "/images/mario-logo.png",
11
+ alt: "Mario Education Logo",
12
+ className: "loader-logo",
13
+ style: { maxWidth: "220px" }
14
+ }
15
+ ),
16
+ /* @__PURE__ */ a("div", { className: "loading-text", children: "Loading your page..." }),
17
+ /* @__PURE__ */ e("div", { className: "loading-dots", children: [
18
+ /* @__PURE__ */ a("span", { className: "dot" }),
19
+ /* @__PURE__ */ a("span", { className: "dot" }),
20
+ /* @__PURE__ */ a("span", { className: "dot" })
21
+ ] })
22
+ ] }) }), f = ({ routes: i }) => {
23
+ const s = p(), { pathname: o } = s, l = o.includes("/admin") ? "" : "box-container", d = o.includes("/admin") ? "p-4" : "";
24
+ return /* @__PURE__ */ a("main", { className: `c-main ${l}`, style: { height: "100%" }, children: /* @__PURE__ */ a(g, { fluid: !0, className: `h-100 ${d}`, style: { flex: 1 }, children: /* @__PURE__ */ a(r, { fallback: N, children: /* @__PURE__ */ e(h, { children: [
25
+ i.map((n, c) => /* @__PURE__ */ a(
26
+ t,
27
+ {
28
+ path: n.path,
29
+ element: /* @__PURE__ */ a(n.component, {})
30
+ },
31
+ c
32
+ )),
33
+ /* @__PURE__ */ a(t, { path: "*", element: /* @__PURE__ */ a(u, {}) })
34
+ ] }) }) }) });
35
+ }, L = m(f);
36
+ export {
37
+ L as default
38
+ };
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),n=require("react"),s=require("react-router-dom"),r=require("@coreui/react"),m=require("./index-KWXe_Hjz.js"),u=e.jsx("div",{className:"app-initial-loader",style:{position:"relative",height:"100%",minHeight:"400px",backgroundColor:"transparent",width:"100%"},children:e.jsxs("div",{className:"loader-container",children:[e.jsx("img",{src:"/images/mario-logo.png",alt:"Mario Education Logo",className:"loader-logo",style:{maxWidth:"220px"}}),e.jsx("div",{className:"loading-text",children:"Loading your page..."}),e.jsxs("div",{className:"loading-dots",children:[e.jsx("span",{className:"dot"}),e.jsx("span",{className:"dot"}),e.jsx("span",{className:"dot"})]})]})}),x=({routes:o})=>{const i=s.useLocation(),{pathname:a}=i,l=a.includes("/admin")?"":"box-container",c=a.includes("/admin")?"p-4":"";return e.jsx("main",{className:`c-main ${l}`,style:{height:"100%"},children:e.jsx(r.CContainer,{fluid:!0,className:`h-100 ${c}`,style:{flex:1},children:e.jsx(n.Suspense,{fallback:u,children:e.jsxs(s.Routes,{children:[o.map((t,d)=>e.jsx(s.Route,{path:t.path,element:e.jsx(t.component,{})},d)),e.jsx(s.Route,{path:"*",element:e.jsx(m.NotFound,{})})]})})})})},h=n.memo(x);exports.default=h;
@@ -0,0 +1,5 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),s=require("./index-KWXe_Hjz.js"),je=require("./UserList-DUiZTiTR.js"),u=require("react"),i=require("reactstrap"),te=require("react-i18next"),j=require("./constants-DUelcmx7.js"),le=require("react-redux"),Q=require("./userService-DEwtByu1.js"),$e=require("./TeacherSelector-CV9c0Cn8.js"),We=require("react-select"),Ge=require("formik"),Ke=require("yup"),Qe=require("papaparse");function Xe(t){const l=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const c in t)if(c!=="default"){const r=Object.getOwnPropertyDescriptor(t,c);Object.defineProperty(l,c,r.get?r:{enumerable:!0,get:()=>t[c]})}}return l.default=t,Object.freeze(l)}const Ce=Xe(Ke),Pe="Cannot update two school levels at the same time.",ve=t=>t?.schoolLevel?.toLowerCase(),qe=t=>{const l=Object.entries(t).filter(([c])=>c!=="currentPage"&&c!=="cursor").sort(([c],[r])=>c.localeCompare(r));return JSON.stringify(l)},Ye=t=>{if(t===void 0)return;const l=j.UserOrder[t];return l?l.charAt(0).toLowerCase()+l.slice(1):void 0},Ze=()=>{const t=le.useDispatch(),[l,c]=u.useState([]),[r,d]=u.useState(j.DEFAULT_STUDENT_FILTER),[a,S]=u.useState(0),[f,o]=u.useState([]),[m,b]=u.useState([]),[h,E]=u.useState(j.initAssignStd),_="",U=u.useRef({}),N=u.useRef(""),I=u.useMemo(()=>{const A=m.find(y=>!!ve(y));return ve(A)},[m]),R=A=>{const y=Object.keys(A).every(C=>C==="currentPage"),p={...r,...A};y||(p.currentPage=1,U.current={},N.current=qe(p)),d(p)},J=u.useMemo(()=>{const A=l.filter(p=>f.includes(p.id)).flatMap(p=>p.teachers),y=new Map;return A.forEach(p=>{y.has(p.teacherUserId)||y.set(p.teacherUserId,p)}),Array.from(y.values()).map(p=>({value:p.teacherUserId,label:p.mainTeacherEmail}))},[m,f]),V=u.useMemo(()=>{const A=l.filter(p=>f.includes(p.id)).flatMap(p=>p.counselors),y=new Map;return A.forEach(p=>{y.has(p.counselorUserId)||y.set(p.counselorUserId,p)}),Array.from(y.values()).map(p=>({value:p.counselorUserId,label:p.counselorEmail}))},[m,f]),Y=u.useMemo(()=>{const A=l.filter(p=>f.includes(p.id)&&p.assistantUserId).map(p=>({value:p.assistantUserId,label:p.assistantEmail})),y=new Map;return A.forEach(p=>{y.has(p.value)||y.set(p.value,p)}),Array.from(y.values())},[l,f]),x=u.useMemo(()=>{const A=l.filter(p=>f.includes(p.id)&&p.secondaryTeacherUserId).map(p=>({value:p.secondaryTeacherUserId,label:p.secondaryTeacherEmail})),y=new Map;return A.forEach(p=>{y.has(p.value)||y.set(p.value,p)}),Array.from(y.values())},[l,f]),$=u.useCallback(A=>{A!==r.sortBy?R({sortBy:A,orderBy:"ASC",currentPage:1}):R({sortBy:A,orderBy:r.orderBy!=="DESC"?"DESC":"ASC",currentPage:1})},[JSON.stringify(r)]),P=async()=>{t(s.setLoading(!0));try{const A=r.currentPage||1,y=qe(r);N.current!==y&&(U.current={},N.current=y);const p=Object.entries(r).filter(([z,ee])=>ee!==void 0).reduce((z,[ee,se])=>(z[ee]=se,z),{}),C={};for(const z in p){if(z==="currentPage"){C.page=p[z];continue}if(z==="orderBy"||z==="cursor")continue;if(z==="sortBy"){const se=Ye(p[z]);se!==void 0&&(C.sortBy=se);continue}const ee=z.charAt(0).toLowerCase()+z.slice(1);C[ee]=p[z]}C.isDescending=r.isDescending??r.orderBy==="DESC";const O=Object.prototype.hasOwnProperty.call(U.current,A);A===1?C.cursor="":O&&(C.cursor=U.current[A]);const G=(await Q.getAssignStudentApi(C))?.data||{},X=G?.nextCursor||G?.pagination?.nextCursor;X?U.current[A+1]=X:delete U.current[A+1],c(G?.items||G?.pagination?.items||[]),S(G?.totalItems||G?.pagination?.totalItems||0)}catch(A){t(s.setAlert({type:"danger",message:A.response?.data?.title||A.message}))}t(s.setLoading(!1))},H=u.useMemo(()=>A=>{const y=ve(A);return!!I&&!!y&&y!==I},[I]),re=u.useMemo(()=>{const A=l.filter(y=>!H(y));return A.length>0&&A.every(y=>f.includes(y.id))},[l,f,H]),ne=()=>{if(re){const p=new Set(l.map(C=>C.id));o(C=>C.filter(O=>!p.has(O))),b(C=>C.filter(O=>!p.has(O.id)));return}const A=I??ve(l.find(p=>!!ve(p))),y=l.filter(p=>{const C=ve(p);return!C||!A||C===A});if(y.length===0&&l.length>0){Z();return}o(p=>{const C=y.map(O=>O.id).filter(O=>!p.includes(O));return[...p,...C]}),b(p=>{const C=new Set(p.map(F=>F.id)),O=y.filter(F=>!C.has(F.id));return[...p,...O]})},Z=()=>{t(s.setAlert({type:"warning",message:Pe}))},ce=A=>{const{id:y,checked:p}=A.target,C=l.find(O=>O.id===y);if(p&&C&&H(C)){Z();return}p?(o(O=>[...O,y]),C&&b(O=>[...O,C])):(o(O=>O.filter(F=>F!==y)),b(O=>O.filter(F=>F.id!==y)))},ae=u.useCallback(()=>{r.currentPage==1?P():R({currentPage:1}),o([]),b([])},[JSON.stringify(r)]);return u.useEffect(()=>{P()},[JSON.stringify(r)]),u.useEffect(()=>{document.title="User | Assign student"},[]),u.useEffect(()=>{R({...r,searchString:_})},[_]),{handelSort:$,handleRetrievedData:ae,totalItem:a,userList:l,filters:r,changeFilters:R,handleSelectAll:ne,handleClickCheck:ce,isCheckAll:re,isCheck:f,fullName:_,selectedUser:h,setSelectedUser:E,userSelected:m,getDataUserList:P,studentTeacherSelected:J,studentCounselorSelected:V,studentAssistantSelected:Y,studentSecondaryTeacherSelected:x,isStudentSelectionDisabled:H,handleBlockedSchoolLevelSelection:Z,schoolLevelConflictMessage:Pe}},es=()=>{const t=le.useDispatch(),[l,c]=u.useState([]),[r,d]=u.useState(),a=async()=>{try{const o=await Q.getCounselors();o.data&&c(o.data.map?.(m=>({label:m.email,value:m.id,schoolLevel:m.schoolLevel}))||[])}catch(o){t(s.setAlert({type:"danger",message:o.response?.data?.title||o.message}))}},S=u.useCallback((o,m)=>{let b=l.find(h=>h.value===o);d({...r,[m]:b})},[JSON.stringify(r),JSON.stringify(l)]),f=u.useCallback((o,m,b)=>{c([...l,o]),b&&d({...r,[m]:o})},[JSON.stringify(l),JSON.stringify(r)]);return u.useEffect(()=>{a()},[]),{selectedCounselors:r,counselorOptions:l,handleSelectCounselor:S,handleCreateCounselorOption:f,setSelectedCounselors:d}},ss=()=>{const t=le.useDispatch(),[l,c]=u.useState([]),[r,d]=u.useState(),a=async()=>{try{const o=await Q.getAssistants();o.data&&c(o.data.map?.(m=>({label:m.email,value:m.id,schoolLevel:m.schoolLevel}))||[])}catch(o){t(s.setAlert({type:"danger",message:o.response?.data?.title||o.message}))}},S=u.useCallback((o,m)=>{let b=l.find(h=>h.value===o);d({...r,[m]:b})},[JSON.stringify(r),JSON.stringify(l)]),f=u.useCallback((o,m,b)=>{c([...l,o]),b&&d({...r,[m]:o})},[JSON.stringify(l),JSON.stringify(r)]);return u.useEffect(()=>{a()},[]),{selectedAssistants:r,assistantOptions:l,handleSelectAssistant:S,handleCreateAssistantOption:f,setSelectedAssistants:d}},ts=()=>{const t=le.useDispatch(),[l,c]=u.useState([]),[r,d]=u.useState(),a=async()=>{try{const o=await Q.getSecondaryTeachers();o.data.items&&c(o.data.items.map?.(m=>({label:m.email,value:m.id,id:m.secondaryTeacherId,schoolLevel:m.schoolLevel}))||[])}catch(o){t(s.setAlert({type:"danger",message:o.response?.data?.title||o.message}))}},S=u.useCallback((o,m)=>{let b=l.find(h=>h.value===o);d({...r,[m]:b})},[JSON.stringify(r),JSON.stringify(l)]),f=u.useCallback((o,m,b)=>{c([...l,o]),b&&d({...r,[m]:o})},[JSON.stringify(l),JSON.stringify(r)]);return u.useEffect(()=>{a()},[]),{selectedSecondaryTeachers:r,secondaryTeacherOptions:l,handleSelectSecondaryTeacher:S,handleCreateSecondaryTeacherOption:f,setSelectedSecondaryTeachers:d}},as=()=>{const t=le.useDispatch(),[l,c]=u.useState([]),[r,d]=u.useState(),a=async()=>{try{const o=await Q.getTeachers({sortBy:"Email"});o.data&&c(o.data.map?.(m=>({label:m.email,value:m.id,schoolLevel:m.schoolLevel}))||[])}catch(o){t(s.setAlert({type:"danger",message:o.response?.data?.title||o.message}))}},S=u.useCallback((o,m)=>{let b=l.filter(h=>o.includes(h.value));d({...r,[m]:b})},[JSON.stringify(r),JSON.stringify(l)]),f=u.useCallback((o,m,b)=>{c([...l,o]),b&&d({...r,[m]:o})},[JSON.stringify(l),JSON.stringify(r)]);return u.useEffect(()=>{a()},[]),{selectedTeachers:r,teacherOptions:l,handleSelectTeacher:S,handleCreateTeacherOption:f,setSelectedTeachers:d}},ns=(t,l)=>{const c=[];if(l===j.TeacherType.Teacher)for(const d of t)for(const a of d.teachers||[])c.push({label:a.mainTeacherEmail,value:a.teacherUserId,name:a.mainTeacherName});else if(l===j.TeacherType.Assistant)for(const d of t)d.assistantEmail&&d.assistantUserId&&c.push({label:d.assistantEmail,value:d.assistantUserId,name:d.assistantName||""});else if(l===j.TeacherType.Counselor)for(const d of t)for(const a of d.counselors||[])c.push({label:a.counselorEmail,value:a.counselorUserId,name:a.counselorName});const r=new Map;for(const d of c)r.has(d.value)||r.set(d.value,d);return Array.from(r.values()).sort((d,a)=>d.label.localeCompare(a.label))},de=(t,l,c)=>{const r=l?.[0],a=c?.find(S=>S.id===r)?.schoolLevel?.toLowerCase();return t.filter(S=>!a||S.schoolLevel?.toLowerCase()===a)},ls=(t,l,c,r,d,a,S,f)=>{const o=le.useDispatch(),[m,b]=u.useState(!1),[h,E]=u.useState(j.initialStaffBulk),[_,U]=u.useState(!1),[N,I]=u.useState(!1),[R,J]=u.useState(j.TeacherType.Teacher),[V,Y]=u.useState([]),[x,$]=u.useState([]),[P,H]=u.useState([]),[re,ne]=u.useState({header:"",titleSelect:"",selectPlaceholder:"",changeTitle:"",changePlaceholder:""}),[Z,ce]=u.useState(""),[ae,A]=u.useState(""),[y,p]=u.useState(!1),[C,O]=u.useState(0),[F,G]=u.useState([]),[X,z]=u.useState(""),[ee,se]=u.useState(!1),[ue,me]=u.useState(!1),[W,oe]=u.useState(j.initStaffDeleteBulk),he=g=>{oe({...W,...g})},ie=g=>{if(g&&g.length===0){o(s.setAlert({type:"danger",message:"Please select students!"}));return}me(!ue),E({...j.initialStaffBulk}),oe({...j.initStaffDeleteBulk})},K=()=>{se(!ee),z("")},pe=g=>{F.includes(g)?G(F.filter(v=>v!==g)):G([...F,g])},ge=g=>{O(v=>v===g?-1:g)},fe=g=>{if(g&&g.length===0){o(s.setAlert({type:"danger",message:"Please select students!"}));return}b(!m),E({...j.initialStaffBulk})},xe=(g,v,T)=>{if(g&&g.length===0){o(s.setAlert({type:"danger",message:"Please select students!"}));return}switch(H(g),$(ns(g,v)),J(v),v){case j.TeacherType.Teacher:ne({header:"switch_teacher",titleSelect:"current_teacher_name",selectPlaceholder:"select_teacher",changeTitle:"select_teacher_change",changePlaceholder:"select_teacher_change"});break;case j.TeacherType.Assistant:ne({header:"switch_assistant",titleSelect:"current_assistant_name",selectPlaceholder:"",changeTitle:"",changePlaceholder:"select_assistant_change"});break;case j.TeacherType.Counselor:ne({header:"switch_counselor",titleSelect:"current_counselor_name",selectPlaceholder:"select_counselor",changeTitle:"select_counselor_change",changePlaceholder:"select_counselor_change"});break;case j.TeacherType.SecondaryTeacher:ne({header:"switch_support_teacher",titleSelect:"current_assistant_name",selectPlaceholder:"",changeTitle:"",changePlaceholder:"select_support_teacher_change"});break}I(!N),Y(T)},ye=()=>{Y([]),I(!1),p(!1),J(j.TeacherType.Teacher),$([]),ce(""),A(""),ne({header:"",titleSelect:"",selectPlaceholder:"",changeTitle:"",changePlaceholder:""}),G([])},be=()=>{p(!1),O(0),G([])},Ne=async(g,v)=>{o(s.setModal({isOpen:!0,type:"warning",message:`Do you want to change ${v===j.TeacherType.Teacher?"teacher":v===j.TeacherType.Assistant?"assistant":v===j.TeacherType.SecondaryTeacher?"support teacher":"counselor"} for ${g.length} student(s)?`,onConfirm:async()=>{o(s.setLoading(!0));try{const T=v===j.TeacherType.Teacher?await Q.changeMultiTeacherOfStudent(g):v===j.TeacherType.Assistant?await Q.changeAssistantOfStudents(g):v===j.TeacherType.Counselor?await Q.changeMultiCounselorsOfStudent(g):await Q.changeSecondaryTeacherOfStudents(g);T&&T?.data&&(ye(),d?.(),await S(),o(s.setAlert({type:"success",message:`Change ${v===j.TeacherType.Teacher?"teacher":v===j.TeacherType.Assistant?"assistant":v===j.TeacherType.SecondaryTeacher?"support teacher":"counselor"} successfully`})))}catch(T){o(s.setAlert({type:"danger",message:T.response?.data?.title||T.message}))}o(s.setLoading(!1))}}))},we=()=>{let g=[];switch(R){case j.TeacherType.Teacher:g=P.filter(v=>{const T=v.teachers.map(D=>D.teacherUserId);return T.includes(ae)&&!T.includes(Z)}).map(v=>({studentId:v.studentId,teacher:ae,teacherChange:Z}));break;case j.TeacherType.Counselor:g=P.filter(v=>{const T=v.counselors.map(D=>D.counselorUserId);return T.includes(ae)&&!T.includes(Z)}).map(v=>({studentId:v.studentId,counselor:ae,counselorChange:Z}));break;case j.TeacherType.Assistant:g=P.filter(v=>v?.assistantUserId&&v?.teachers?.length>0).map(v=>({studentId:v.studentId,assistantUserId:Z}));break;case j.TeacherType.SecondaryTeacher:g=P.filter(v=>v?.secondaryTeacherUserId&&v?.teachers?.length>0).map(v=>({studentId:v.studentId,secondaryTeacherId:Z}));break}if(g.length===0){o(s.setAlert({type:"danger",message:"No change to update!"}));return}Ne(g||[],R)},Le=g=>{if(g&&g.length===0){o(s.setAlert({type:"danger",message:"Please select student(s)!"}));return}U(!_)},Ae=(g,v)=>{switch(g){case"assistant":E({...h,assistantId:v.value,assistantEmail:v.label});break;case"secondary":E({...h,secondaryTeacherId:v.value,secondaryTeacherEmail:v.label});break;case"grade":E({...h,gradeLevel:v.value});break}},Ee=g=>{E({...h,teacher:g})},ke=g=>{E({...h,counselors:g})},Se=async g=>{o(s.setLoading(!0));try{await Q.assignStudentsApi(g),o(s.setAlert({type:"success",message:"Student assigned successfully"})),d?.(),ye()}catch(v){o(s.setAlert({type:"danger",message:v.response?.data?.title||v.message}))}o(s.setLoading(!1))},Me=u.useCallback(g=>{if(g.length===0){o(s.setAlert({type:"danger",message:"Not found selected student."}));return}if(g.some(D=>{const B=t?.[D],w=l?.[D],q=c?.[D],k=r?.[D];return!B&&!w&&!q&&!k})){o(s.setAlert({type:"danger",message:"Please select/add teacher for all selected student first."}));return}const T=g.map(D=>{const B=t?.[D],w=l?.[D],q=c?.[D],k=r?.[D],n=f?.find(M=>M.id===D),L={id:D,schoolLevel:n?.schoolLevel};return B&&(L.mainTeacherUserId=B?B.map(M=>M.value):void 0,L.mainTeacherEmail=B?B.map(M=>M.label):void 0),w&&(L.assistantUserId=w?.value&&typeof w?.value=="string"?w?.value:void 0,L.assistantEmail=w?.value&&typeof w?.value=="number"?w?.label:void 0),q&&(L.counselorUserIds=q?q.map(M=>M.value):void 0,L.counselorEmails=q?q.map(M=>M.label):void 0),k&&(L.secondaryTeacherUserId=k?.value&&typeof k?.value=="string"?k?.value:void 0,L.secondaryTeacherEmail=k?.value&&typeof k?.value=="number"?k?.label:void 0),L});Se([...T])},[JSON.stringify(t),JSON.stringify(l),JSON.stringify(c),JSON.stringify(r)]),Ue=u.useCallback(g=>{const v=t?.[g],T=l?.[g],D=c?.[g],B=r?.[g];if(!v&&!T&&!D&&!B){o(s.setAlert({type:"danger",message:"Please select/add teacher for selected student first."}));return}const w=f?.find(k=>k.id===g),q={id:g,schoolLevel:w?.schoolLevel};v&&(q.mainTeacherUserId=v?v.map(k=>k.value):void 0,q.mainTeacherEmail=v?v.map(k=>k.label):void 0),T&&(q.assistantUserId=T?.value&&typeof T?.value=="string"?T?.value:void 0,q.assistantEmail=T?.value&&typeof T?.value=="number"?T?.label:void 0),D&&(q.counselorUserIds=D?D.map(k=>k.value):void 0,q.counselorEmails=D?D.map(k=>k.label):void 0),B&&(q.secondaryTeacherUserId=B?.value&&typeof B?.value=="string"?B?.value:void 0,q.secondaryTeacherEmail=B?.value&&typeof B?.value=="number"?B?.label:void 0),Se([q])},[JSON.stringify(t),JSON.stringify(l),JSON.stringify(c),JSON.stringify(r)]),Oe=async g=>{if(g.length===0){o(s.setAlert({type:"danger",message:"Not found selected student."}));return}if(h.teacher.length===0&&h.counselors.length===0&&!h.assistantId&&!h.secondaryTeacherId){o(s.setAlert({type:"danger",message:"No change to assign!"}));return}const v=f?.filter(T=>g?.includes(T.id))?.every(T=>Array.isArray(T.teachers)&&T.teachers.length>0)??!1;if(h.teacher.length===0&&!v){o(s.setAlert({type:"danger",message:"Please assign a teacher to each student before giving other educators access to them"}));return}o(s.setLoading(!0));try{if(h.teacher.length>0&&f&&f.length>0){const B=f.filter(w=>g.includes(w.id)).map(w=>{const q=w.teachers?.map(n=>n.teacherUserId)||[],k=h.teacher.filter(n=>!q.includes(n.id));return{id:w.id,schoolLevel:w.schoolLevel,mainTeacherUserId:k.map(n=>n.id),mainTeacherEmail:k.map(n=>n.email)}}).filter(w=>w.mainTeacherUserId.length>0||w.mainTeacherEmail.length>0);B.length>0&&await Q.assignStudentsApi(B)}if(h.counselors.length>0&&f&&f.length>0){const B=f.filter(w=>g.includes(w.id)).map(w=>{const q=w.counselors?.map(n=>n.counselorUserId)||[],k=h.counselors.filter(n=>!q.includes(n.id));return{id:w.id,schoolLevel:w.schoolLevel,counselorUserIds:k.map(n=>n.id),counselorEmails:k.map(n=>n.email)}}).filter(w=>w.counselorUserIds.length>0||w.counselorEmails.length>0);B.length>0&&await Q.assignStudentsApi(B)}const T=f?.filter(B=>!B.assistantUserId);if(T&&T?.length>0&&h.assistantId){const B=T.map(w=>({id:w.id,schoolLevel:w.schoolLevel,assistantUserId:h.assistantId,assistantEmail:h.assistantEmail}));await Q.assignStudentsApi(B.filter(w=>w!==void 0))}const D=f?.filter(B=>!B.secondaryTeacherUserId);if(D&&D?.length>0&&h.secondaryTeacherId){const B=D.map(w=>({id:w.id,schoolLevel:w.schoolLevel,secondaryTeacherUserId:h.secondaryTeacherId,secondaryTeacherEmail:h.secondaryTeacherEmail}));await Q.assignStudentsApi(B.filter(w=>w!==void 0))}o(s.setAlert({type:"success",message:"Student assigned successfully"})),d?.(),ye(),fe()}catch(T){o(s.setAlert({type:"danger",message:T.response?.data?.title||T.message}))}o(s.setLoading(!1))},De=async g=>{if(h.teacher.length===0){o(s.setAlert({type:"danger",message:"Please select teacher before assign!"}));return}if(F.length>0&&!g){se(!0);return}const v={id:a?.id||"",schoolLevel:a?.schoolLevel,mainTeacherUserId:h.teacher.filter(T=>!a?.teachers?.some(D=>D.teacherUserId===T.id)).map(T=>T.id)||[],mainTeacherEmail:h.teacher.filter(T=>!a?.teachers?.some(D=>D.teacherUserId===T.id)).map(T=>T.email)||[],assistantUserId:h?.assistantId?h?.assistantId:void 0,assistantEmail:h?.assistantEmail?h?.assistantEmail:void 0,counselorUserIds:h.counselors.map(T=>T.id)||[],counselorEmails:h.counselors.map(T=>T.email)||[],secondaryTeacherUserId:h?.secondaryTeacherId?h?.secondaryTeacherId:void 0,secondaryTeacherEmail:h?.secondaryTeacherEmail?h?.secondaryTeacherEmail:void 0,removeTeacherUserIds:F,teacherSwitchUserId:g||""};h?.gradeLevel&&h.gradeLevel!==a?.gradeLevel&&await Q.addGradeToStudent(a?.id||"",h?.gradeLevel),Se([v])},Be=async(g,v)=>{o(s.setLoading(!0));try{(await Q.updateStatusAll(g)).status==200&&(o(s.setAlert({type:"success",message:`Inactive ${g.length} Students successfully`})),v())}catch(T){o(s.setAlert({type:"danger",message:T.response?.data?.title||T.message}))}U(!_),o(s.setLoading(!1))},_e=u.useCallback(async g=>{if(W.assistantRemoveUserId.length&&!W.assistantSwitchDataUserId){o(s.setAlert({type:"danger",message:"Please select an assistant to transfer data!"}));return}if(W.teacherRemoveUserIds.length&&!W.teacherSwitchDataUserId){o(s.setAlert({type:"danger",message:"Please select a teacher to transfer data!"}));return}if(W.counselorRemoveUserIds.length&&!W.counselorSwitchDataUserId){o(s.setAlert({type:"danger",message:"Please select a counselor to transfer data!"}));return}if(W.supportTeacherRemoveUserIds.length&&!W.supportTeacherSwitchDataUserId){o(s.setAlert({type:"danger",message:"Please select a support teacher to transfer data!"}));return}o(s.setLoading(!0));try{const v=g?.[0],D=f?.find(B=>B.id===v)?.schoolLevel;await Q.removeBulkStaff({...W,studentUserIds:g||[],schoolLevel:D}),d?.(),await S()}catch(v){o(s.setAlert({type:"danger",message:v.response?.data?.title||v.message}))}ie(),o(s.setLoading(!1))},[W]);return u.useEffect(()=>(a?.id&&E({teacher:a?.teachers?.map(g=>({id:g.teacherUserId,email:g.mainTeacherEmail})),assistantId:a?.assistantUserId,assistantEmail:a?.assistantEmail,counselors:a?.counselors?.map(g=>({id:g.counselorUserId,email:g.counselorEmail})),secondaryTeacherEmail:a?.secondaryTeacherEmail,secondaryTeacherId:a?.secondaryTeacherUserId,gradeLevel:a?.gradeLevel}),()=>{E(j.initialStaffBulk)}),[a]),{handleAssignSingleStudent:Ue,handleAssignMultiStudent:Me,openModelBulk:m,handleToggleModel:fe,handleChangeStaffBulk:Ae,staffBulkAssign:h,onAssignStaffToStudents:Oe,handleToggleInactiveModal:Le,openInactiveModal:_,handleInactiveStudents:Be,handleChangeTeacherBulk:Ee,handleEditAssignForStudents:De,handleToggleSwitchModel:xe,openSwitchModal:N,optionsSwitch:V,modalType:R,textModal:re,teacherSwitchList:x,onCloseSwitchModal:ye,handleUpdateSwitch:we,setTeacherChangeUserId:ce,setTeacherSelectForChangeUserId:A,teacherSelectForChangeUserId:ae,openDetailModal:y,setOpenDetailModal:p,toggleCollapse:ge,activeIndex:C,handleChangeCounselorBulk:ke,onClose:be,removeTeacherUserIds:F,onSelectRemoveTeacher:pe,openModelSwitchDataTeacher:ee,onToggleModelSwitchDataTeacher:K,teacherSwitchUserId:X,setTeacherSwitchUserId:z,onToggleModelDeleteBulk:ie,openModelDeleteBulk:ue,handelChangeStaffRemove:he,switchStaffUsers:W,handleRemoveBulkStaff:_e}};function rs(t){return s.GenIcon({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M228.9 79.9L51.8 403.1C40.6 423.3 55.5 448 78.9 448h354.3c23.3 0 38.2-24.7 27.1-44.9L283.1 79.9c-11.7-21.2-42.5-21.2-54.2 0zM273.6 214L270 336h-28l-3.6-122h35.2zM256 402.4c-10.7 0-19.1-8.1-19.1-18.4s8.4-18.4 19.1-18.4 19.1 8.1 19.1 18.4-8.4 18.4-19.1 18.4z"}}]})(t)}const os=t=>{const{textModal:l,isOpen:c,teachers:r,options:d,onClose:a,onSave:S,modalType:f,setTeacherChangeUserId:o,setTeacherSelectForChangeUserId:m,teacherSelectForChangeUserId:b}=t,{t:h}=te.useTranslation();return e.jsxs(i.Modal,{centered:!0,isOpen:c,toggle:a,zIndex:1201,children:[e.jsx(i.ModalHeader,{className:s.styles["header-assign-for-student"],children:h(l.header)}),e.jsxs(i.ModalBody,{children:[f!==j.TeacherType.Assistant||f!==j.TeacherType.SecondaryTeacher&&e.jsxs(u.Fragment,{children:[e.jsx("div",{children:h(l.titleSelect)}),e.jsx("ul",{style:{maxHeight:200,overflow:"auto"},children:r.map(E=>e.jsxs("li",{children:[E.name,"-",E.label]},E.label))})]}),(f===j.TeacherType.Teacher||f===j.TeacherType.Counselor)&&e.jsxs(u.Fragment,{children:[e.jsx("div",{children:h(l.selectPlaceholder)}),e.jsx(s.CustomSelector,{options:r,value:r.filter(E=>E.value===b),placeholder:h(l.selectPlaceholder),className:`flex-grow-1 mb-3 ${s.styles["custom-chip-teacher-select"]}`,onChange:E=>{m(E.value)},isClearable:!0,style:{maxWidth:120}})]}),e.jsx("div",{children:h(l.changeTitle)}),e.jsx($e.TeacherSelector,{options:d,onChange:E=>{f!==j.TeacherType.SecondaryTeacher?o(E.value):o(E.id)},placeholder:h(l.changePlaceholder),className:"flex-grow-1 mb-3"})]}),e.jsxs(i.ModalFooter,{className:"textModal-right",children:[e.jsx(i.Button,{onClick:()=>a(!1),children:h("cancel")}),e.jsx(i.Button,{color:"primary",onClick:()=>{S()},children:h("save")})]})]})},cs=u.forwardRef(os),is=({openDetailModal:t,onClose:l,selectedUser:c,staffBulkAssign:r,teacherOptions:d,handleChangeTeacherBulk:a,handleChangeCounselorBulk:S,assistantOptions:f,counselorOptions:o,secondaryTeacherOptions:m,handleChangeStaffBulk:b,handleEditAssignForStudents:h,toggleCollapse:E,activeIndex:_})=>{const{t:U}=te.useTranslation(),N=[c?.teachers||[],c?.counselors||[]],I=c?.schoolLevel?.toLowerCase(),R=d.filter(x=>!c.teachers?.some($=>$.teacherUserId===x.value)).filter(x=>!I||x.schoolLevel?.toLowerCase()===I),J=f.filter(x=>!I||x.schoolLevel?.toLowerCase()===I),V=o.filter(x=>!c.counselors?.some($=>$.counselorUserId===x.value)).filter(x=>!I||x.schoolLevel?.toLowerCase()===I),Y=m.filter(x=>!I||x.schoolLevel?.toLowerCase()===I);return e.jsxs(i.Modal,{centered:!0,isOpen:t,toggle:()=>l(),zIndex:1201,children:[e.jsxs(i.ModalHeader,{className:s.styles["header-assign-for-student"],children:[e.jsxs("div",{children:["Assign student ",c?.fullName]}),e.jsxs("div",{children:["Grade ",c?.gradeLevel]})]}),e.jsxs(i.ModalBody,{children:[N.map((x,$)=>e.jsxs("div",{children:[e.jsxs("button",{type:"button",className:`btn ${s.styles["btn-collapse"]} ${_===$?"btn-link ":""}`,onClick:()=>E($),children:[U($===0?"current_teacher_name":"current_counselor_name")," ",`(${x.length})`," ",e.jsx("i",{className:`fa fa-angle-${_===$?"up":"down"}`})]}),e.jsx(i.Collapse,{isOpen:_===$,children:e.jsx(i.Card,{children:e.jsx(i.CardBody,{children:x.length>0?x.map(P=>$===0?e.jsxs("li",{children:[P.mainTeacherName," - ",P.mainTeacherEmail]},P.mainTeacherEmail):e.jsxs("li",{children:[P.counselorName," - ",P.counselorEmail]},P.counselorUserId)):e.jsx("div",{children:U("no_data")})})})})]},$)),e.jsx("div",{children:U("teacher_email")}),e.jsx(s.CustomSelector,{isMulti:!0,value:r.teacher.filter(x=>!c.teachers?.some($=>$.teacherUserId===x.id)).map(x=>({label:x.email,value:x.id})),options:R,placeholder:U("select_teacher"),className:`flex-grow-1 mb-3 ${s.styles["custom-chip-teacher-select"]}`,onChange:x=>{const $=x.map(P=>({id:P.value,email:P.label}));a($)},isClearable:!0,style:{maxWidth:120}}),e.jsx("div",{children:U("assistant_email")}),e.jsx($e.TeacherSelector,{value:f.find(x=>x.value==r.assistantId||x.label==r.assistantEmail)||null,options:J,onChange:x=>{b("assistant",x)},placeholder:U("select_assistant"),className:"flex-grow-1 mb-3"}),e.jsx("div",{children:U("counselor_email")}),e.jsx(s.CustomSelector,{isMulti:!0,value:r.counselors.filter(x=>!c.counselors?.some($=>$.counselorUserId===x.id)).map(x=>({label:x.email,value:x.id})),options:V,placeholder:U("select_counselor"),className:`flex-grow-1 mb-3 ${s.styles["custom-chip-teacher-select"]}`,onChange:x=>{const $=x.map(P=>({id:P.value,email:P.label}));S($)},isClearable:!0,style:{maxWidth:120}}),e.jsx("div",{children:U("support_teacher_email")}),e.jsx($e.TeacherSelector,{value:m.find(x=>x.value==r.secondaryTeacherId||x.label==r.secondaryTeacherEmail)||null,options:Y,onChange:x=>{b("secondary",x)},placeholder:U("select_support_teacher"),className:"flex-grow-1"}),e.jsx("div",{children:U("grade")}),e.jsx(We,{value:j.GRADE_DEFAULT.find(x=>x.value===r.gradeLevel),options:j.GRADE_DEFAULT.filter(x=>x.schoolLevel===I),placeholder:U("select_grade"),className:"flex-grow-1 mb-3",onChange:x=>{b("grade",x)},styles:{container:x=>({...x,maxWidth:120})}})]}),e.jsxs(i.ModalFooter,{className:"text-right",children:[e.jsx(i.Button,{onClick:()=>l(),children:U("cancel")}),e.jsx(i.Button,{color:"primary",onClick:()=>{h()},children:U("save")})]})]})},ds=({open:t,onClose:l,teachers:c,onConfirm:r,teacherSwitchUserId:d,setTeacherSwitchUserId:a})=>{const{t:S}=te.useTranslation();return e.jsxs(i.Modal,{centered:!0,isOpen:t,toggle:()=>l(),zIndex:1201,children:[e.jsx(i.ModalHeader,{className:s.styles["header-assign-for-student"],children:e.jsx("div",{children:"Select teacher switch data"})}),e.jsx(i.ModalBody,{className:"p-0",children:e.jsx("div",{className:s.styles["switch-data-teachers"],children:c.map(f=>e.jsx("p",{onClick:()=>a(f.teacherUserId),className:`${s.styles["switch-data-teacher-item"]} ${f.teacherUserId==d?s.styles["item-checked"]:""}`,children:f.mainTeacherName}))})}),e.jsxs(i.ModalFooter,{className:"text-right",children:[e.jsx(i.Button,{onClick:()=>l(),children:S("cancel")}),e.jsx(i.Button,{disabled:!d,color:"primary",onClick:async()=>{await r(d),l()},children:S("save")})]})]})},us=({teachers:t,onChangeStaffRemove:l,switchStaffUsers:c,teacherOptions:r})=>{const{t:d}=te.useTranslation();return e.jsxs("div",{children:[e.jsx("h6",{children:"Select teacher to remove"}),e.jsx(s.CustomSelector,{isMulti:!0,value:t.filter(a=>c.teacherRemoveUserIds.includes(a.value))||[],options:t.filter(a=>!c.teacherRemoveUserIds.includes(a.value)&&a.value!==c.teacherSwitchDataUserId)||[],placeholder:d("select_teacher"),className:`flex-grow-1 mb-3 ${s.styles["custom-chip-teacher-select"]}`,onChange:a=>{l({teacherRemoveUserIds:a.map(S=>S.value)})},isClearable:!0}),e.jsx("h6",{className:"mt-3",children:"Select the teacher to transfer data to"}),e.jsx(s.CustomSelector,{value:r.find(a=>c.teacherSwitchDataUserId==a.value)||null,options:r.filter(a=>!c.teacherRemoveUserIds.includes(a.value)&&a.value!==c.teacherSwitchDataUserId)||[],placeholder:d("select_teacher"),className:`flex-grow-1 mb-3 ${s.styles["custom-chip-teacher-select"]}`,onChange:a=>{console.log("value",a),l({teacherSwitchDataUserId:a?.value})},isClearable:!0})]})},hs=({counselors:t,onChangeStaffRemove:l,switchStaffUsers:c,counselorOptions:r})=>{const{t:d}=te.useTranslation();return e.jsxs("div",{children:[e.jsx("h6",{children:"Select counselor to remove"}),e.jsx(s.CustomSelector,{isMulti:!0,value:t.filter(a=>c.counselorRemoveUserIds.includes(a.value))||[],options:t.filter(a=>!c.counselorRemoveUserIds.includes(a.value)&&a.value!==c.counselorSwitchDataUserId)||[],placeholder:d("select_counselor"),className:`flex-grow-1 mb-3 ${s.styles["custom-chip-teacher-select"]}`,onChange:a=>{l({counselorRemoveUserIds:a.map(S=>S.value)})},isClearable:!0}),e.jsx("h6",{className:"mt-3",children:"Select the counselor to transfer data to"}),e.jsx(s.CustomSelector,{value:r.find(a=>c.counselorSwitchDataUserId==a.value)||null,options:r.filter(a=>!c.counselorRemoveUserIds.includes(a.value)&&a.value!==c.counselorSwitchDataUserId)||[],placeholder:d("select_counselor"),className:`flex-grow-1 mb-3 ${s.styles["custom-chip-counselor-select"]}`,onChange:a=>{l({counselorSwitchDataUserId:a?.value})},isClearable:!0})]})},ms=({tabs:t})=>{const{t:l}=te.useTranslation(),[c,r]=u.useState(0),d=S=>{r(S)},a=()=>e.jsx(i.Row,{children:e.jsxs(i.Col,{xl:12,children:[e.jsx(i.Nav,{tabs:!0,children:t.map((S,f)=>{const o=f===c;return e.jsx(i.NavItem,{children:e.jsx(i.NavLink,{className:`${o?"active":""} cursor-pointer`,onClick:()=>d(f),style:{color:o?"#316CD9":"#242424"},children:l(S.title)})},f)})}),e.jsx(i.TabContent,{activeTab:c,className:"border-bottom-0 border-left-0 border-right-0 p-3",children:t.map((S,f)=>e.jsx(i.TabPane,{tabId:f,children:e.jsx(S.component,{})},f))})]})});return e.jsx("div",{className:"animated fadeIn",children:a()})},ps=({assistants:t,onChangeStaffRemove:l,switchStaffUsers:c,assistantOptions:r})=>{const{t:d}=te.useTranslation();return e.jsxs("div",{children:[e.jsx("h6",{children:"Select assistant to remove"}),e.jsx(s.CustomSelector,{isMulti:!0,value:t.filter(a=>c.assistantRemoveUserId.includes(a.value))||[],options:t.filter(a=>!c.assistantRemoveUserId.includes(a.value)&&a.value!==c.assistantSwitchDataUserId)||[],placeholder:d("select_assistant"),className:`flex-grow-1 mb-3 ${s.styles["custom-chip-teacher-select"]}`,onChange:a=>{l({assistantRemoveUserId:a.map(S=>S.value)})},isClearable:!0}),e.jsx("h6",{className:"mt-3",children:"Select the assistant to transfer data to"}),e.jsx(s.CustomSelector,{value:r.find(a=>c.assistantSwitchDataUserId==a.value)||null,options:r.filter(a=>!c.assistantRemoveUserId.includes(a.value)&&a.value!==c.assistantSwitchDataUserId)||[],placeholder:d("select_assistant"),className:`flex-grow-1 mb-3 ${s.styles["custom-chip-assistant-select"]}`,onChange:a=>{console.log("value",a),l({assistantSwitchDataUserId:a?.value})},isClearable:!0})]})},gs=({secondaryTeachers:t,onChangeStaffRemove:l,switchStaffUsers:c,secondaryTeacherOptions:r})=>{const{t:d}=te.useTranslation();return e.jsxs("div",{children:[e.jsx("h6",{children:"Select support teacher to remove"}),e.jsx(s.CustomSelector,{isMulti:!0,value:t.filter(a=>c.supportTeacherRemoveUserIds.includes(a.value))||[],options:t.filter(a=>!c.supportTeacherRemoveUserIds.includes(a.value)&&a.value!==c.supportTeacherSwitchDataUserId)||[],placeholder:d("select_support_teacher"),className:`flex-grow-1 mb-3 ${s.styles["custom-chip-teacher-select"]}`,onChange:a=>{l({supportTeacherRemoveUserIds:a.map(S=>S.value)})},isClearable:!0}),e.jsx("h6",{className:"mt-3",children:"Select the support teacher to transfer data to"}),e.jsx(s.CustomSelector,{value:r.find(a=>c.supportTeacherSwitchDataUserId==a.value)||null,options:r.filter(a=>!c.supportTeacherRemoveUserIds.includes(a.value)&&a.value!==c.supportTeacherSwitchDataUserId)||[],placeholder:d("select_support_teacher"),className:`flex-grow-1 mb-3 ${s.styles["custom-chip-teacher-select"]}`,onChange:a=>{l({supportTeacherSwitchDataUserId:a?.value})},isClearable:!0})]})},fs=({open:t,onClose:l,teachers:c,onChangeStaffRemove:r,switchStaffUsers:d,assistants:a,onRemoveBulkStaff:S,counselors:f,studentUserIds:o,secondaryTeachers:m,teacherOptions:b,assistantOptions:h,counselorOptions:E,secondaryTeacherOptions:_})=>{const{t:U}=te.useTranslation(),N=[{title:"Remove Teacher",component:()=>e.jsx(us,{teachers:c,onChangeStaffRemove:r,switchStaffUsers:d,teacherOptions:b})},{title:"Remove Assistant",component:()=>e.jsx(ps,{assistants:a,onChangeStaffRemove:r,switchStaffUsers:d,assistantOptions:h})},{title:"Remove Counselor",component:()=>e.jsx(hs,{counselors:f,onChangeStaffRemove:r,switchStaffUsers:d,counselorOptions:E})},{title:"Remove Support Teacher",component:()=>e.jsx(gs,{secondaryTeachers:m,onChangeStaffRemove:r,switchStaffUsers:d,secondaryTeacherOptions:_})}];return e.jsxs(i.Modal,{size:"lg",centered:!0,isOpen:t,toggle:()=>l(),zIndex:1201,children:[e.jsx(i.ModalHeader,{className:`${s.styles["header-assign-for-student"]} border-0`,children:e.jsx("div",{children:"Remove Bulk"})}),e.jsx(i.ModalBody,{className:"p-0",children:e.jsx(ms,{tabs:N})}),e.jsxs(i.ModalFooter,{className:"text-right",children:[e.jsx(i.Button,{onClick:()=>l(),children:U("cancel")}),e.jsx(i.Button,{disabled:!d.teacherRemoveUserIds.length&&!d.assistantRemoveUserId&&!d.counselorRemoveUserIds.length,color:"primary",onClick:async()=>{await S(o)},children:"Remove"})]})]})},ys=()=>{const{t}=te.useTranslation(),{selectedTeachers:l,teacherOptions:c,setSelectedTeachers:r}=as(),{selectedAssistants:d,assistantOptions:a,setSelectedAssistants:S}=ss(),{selectedCounselors:f,counselorOptions:o,setSelectedCounselors:m}=es(),{selectedSecondaryTeachers:b,secondaryTeacherOptions:h,setSelectedSecondaryTeachers:E}=ts(),{isCheck:_,userList:U,filters:N,totalItem:I,handleClickCheck:R,changeFilters:J,fullName:V,handleRetrievedData:Y,selectedUser:x,setSelectedUser:$,getDataUserList:P,userSelected:H,studentTeacherSelected:re,studentCounselorSelected:ne,studentAssistantSelected:Z,studentSecondaryTeacherSelected:ce,isStudentSelectionDisabled:ae,handleBlockedSchoolLevelSelection:A,schoolLevelConflictMessage:y,handleSelectAll:p,isCheckAll:C}=Ze(),O=()=>{Y(),r(void 0),S(void 0),m(void 0),E(void 0)},{openModelBulk:F,handleToggleModel:G,staffBulkAssign:X,handleChangeStaffBulk:z,onAssignStaffToStudents:ee,handleToggleInactiveModal:se,openInactiveModal:ue,handleInactiveStudents:me,handleChangeTeacherBulk:W,handleChangeCounselorBulk:oe,handleEditAssignForStudents:he,modalType:ie,openSwitchModal:K,optionsSwitch:pe,textModal:ge,teacherSwitchList:fe,onCloseSwitchModal:xe,handleUpdateSwitch:ye,setTeacherChangeUserId:be,setTeacherSelectForChangeUserId:Ne,teacherSelectForChangeUserId:we,openDetailModal:Le,setOpenDetailModal:Ae,toggleCollapse:Ee,activeIndex:ke,onClose:Se,removeTeacherUserIds:Me,openModelSwitchDataTeacher:Ue,onToggleModelSwitchDataTeacher:Oe,teacherSwitchUserId:De,setTeacherSwitchUserId:Be,onToggleModelDeleteBulk:_e,openModelDeleteBulk:g,handelChangeStaffRemove:v,switchStaffUsers:T,handleRemoveBulkStaff:D}=ls(l,d,f,b,O,x,P,H),B=[{name:"",isCenter:!0,onSelectAll:p,isCheckAll:C,className:`align-top ${s.styles["fixed-width-40"]}`},{name:"student_name",isCenter:!0,sortBy:j.UserOrder.Name,searchBy:j.SearchBy.Name,className:`align-top ${s.styles["fixed-width"]}`,getOption:n=>({label:n||"empty",value:n})},{name:"grade",isCenter:!0,sortBy:j.UserOrder.Grade,searchBy:j.SearchBy.Grade,className:`align-center justify-center ${s.styles["fixed-width-80"]}`,getOption:n=>({label:n||"empty",value:n})},{name:"teacher_emails",isCenter:!0,className:"align-center justify-center",sortBy:j.UserOrder.Teacher,searchBy:j.SearchBy.Teacher,getOption:n=>({label:n||"empty",value:n})},{name:"assistant_email",isCenter:!0,className:"align-center justify-center",sortBy:j.UserOrder.Assistant,searchBy:j.SearchBy.Assistant,getOption:n=>({label:n||"empty",value:n})},{name:"counselor_emails",isCenter:!0,className:"align-center justify-center",sortBy:j.UserOrder.Counselor,searchBy:j.SearchBy.Counselor,getOption:n=>({label:n||"empty",value:n})},{name:"support_teacher_email",isCenter:!0,className:"align-center justify-center",sortBy:j.UserOrder.SecondaryTeacher,searchBy:j.SearchBy.SecondaryTeacher,getOption:n=>({label:n||"empty",value:n})}],[w,q]=u.useState(null),k=n=>{q(L=>L===n?null:n)};return e.jsxs("div",{className:"fadeIn animated",children:[e.jsx("h5",{className:"mt-4 mb-2",children:t("assign_student")}),e.jsxs(i.Row,{className:"my-2",children:[e.jsx(i.Col,{md:3,children:e.jsx(s.SearchBox,{initValue:N?.searchString||"",onSearch:n=>J({searchString:n}),placeholder:t("type_something_to_search_students")})}),e.jsx(i.Col,{md:8,className:"d-flex justify-content-end align-items-center",children:e.jsx(i.Row,{className:"mb-2",children:e.jsxs(i.Col,{style:{display:"flex",alignItems:"center",flexWrap:"wrap",gap:4},children:[e.jsx(i.Button,{onClick:()=>G(_),color:"primary",style:{background:"#316cd9"},children:t("assign_bulk")}),e.jsx(i.Button,{onClick:()=>_e(_),color:"primary",style:{background:"#316cd9"},children:t("delete_bulk")}),e.jsx(i.Button,{onClick:()=>se(_),color:"primary",style:{background:"#316cd9"},children:t("inactive_students")})]})})}),e.jsxs(i.Col,{md:1,className:"d-flex justify-content-end align-items-center",style:{whiteSpace:"nowrap",flexWrap:"nowrap"},children:[t("total_of_users"),": ",I]})]}),e.jsxs(i.Modal,{centered:!0,isOpen:F,toggle:()=>G(),zIndex:1201,children:[e.jsx(i.ModalHeader,{children:t("assign_bulk_student")}),e.jsxs(i.ModalBody,{children:[e.jsx(s.CustomSelector,{isMulti:!0,value:X.teacher.map(n=>({label:n.email,value:n.id})),options:de(c,_,H),placeholder:t("select_teacher"),className:`flex-grow-1 mb-3 ${s.styles["custom-chip-teacher-select"]}`,onChange:n=>{const L=n.map(M=>({id:M.value,email:M.label}));W(L)},isClearable:!0,style:{maxWidth:120}}),e.jsx(s.CustomSelector,{value:a.find(n=>n.value==X.assistantId||n.label==X.assistantEmail)||null,options:de(a,_,H),onChange:n=>z("assistant",n),placeholder:t("select_assistant"),className:"flex-grow-1 mb-3"}),e.jsx(s.CustomSelector,{isMulti:!0,value:X.counselors.map(n=>({label:n.email,value:n.id})),options:de(o,_,H),placeholder:t("select_counselor"),className:`flex-grow-1 mb-3 ${s.styles["custom-chip-teacher-select"]}`,onChange:n=>{const L=n.map(M=>({id:M.value,email:M.label,schoolLevel:M.schoolLevel}));oe(L)},isClearable:!0,style:{maxWidth:120}}),e.jsx(s.CustomSelector,{value:h.find(n=>n.value==X.secondaryTeacherId||n.label==X.secondaryTeacherEmail)||null,options:de(h,_,H),onChange:n=>z("secondary",n),placeholder:t("select_support_teacher"),className:"flex-grow-1"})]}),e.jsxs(i.ModalFooter,{className:"text-right",children:[e.jsx(i.Button,{onClick:()=>G(),children:t("cancel")}),e.jsx(i.Button,{color:"primary",onClick:()=>ee(_),children:t("assign")})]})]}),e.jsxs(i.Modal,{centered:!0,isOpen:ue,toggle:()=>se(),zIndex:1201,children:[e.jsx(i.ModalHeader,{children:t("inactive_students")}),e.jsxs(i.ModalBody,{style:{display:"flex",gap:12},children:[e.jsx(rs,{color:"red",size:30}),e.jsx(i.CardText,{style:{fontSize:20,margin:0,display:"flex",alignItems:"center"},children:t("are_you_sure_you_want_to_inactive_students",{number:_.length})})]}),e.jsxs(i.ModalFooter,{className:"text-right",children:[e.jsx(i.Button,{onClick:()=>se(),children:t("cancel")}),e.jsx(i.Button,{color:"primary",onClick:()=>me(_,O),children:t("confirm")})]})]}),e.jsxs(i.Row,{className:"my-2",children:[e.jsx(i.Col,{md:12,children:e.jsx("div",{children:e.jsxs(i.Table,{bordered:!0,hover:!0,striped:!0,size:"sm",className:`${s.styles["table-fixed"]}`,children:[e.jsx("thead",{children:e.jsx(je.TableHeader,{headers:B,filters:N,fullName:V,onChangeFilters:J,teacherOptions:c,assistantOptions:a,counselorOptions:o,secondaryTeacherOptions:h})}),U&&U.length>0?e.jsx("tbody",{children:U.map((n,L)=>e.jsxs("tr",{children:[e.jsx("td",{className:`align-middle text-center ${s.styles["fixed-width-40"]}`,children:(()=>{const M=ae(n),Te=`student_checkbox_${n.id}_${L}`;return e.jsxs("span",{id:Te,onClick:()=>{M&&A()},onMouseEnter:()=>{M&&k(Te)},onMouseLeave:()=>{M&&k(Te)},style:{display:"inline-block"},children:[e.jsx("input",{id:n.id,type:"checkbox",onChange:R,checked:_.includes(n.id),disabled:M,style:{pointerEvents:M?"none":void 0}}),M&&e.jsx(i.Tooltip,{placement:"right",isOpen:w===Te,target:Te,children:y})]})})()}),e.jsxs("td",{className:`align-middle ${s.styles["fixed-width"]}`,id:`student_name_${n.id}_${L}`,onMouseEnter:()=>k(`student_name_${n.id}_${L}`),onMouseLeave:()=>k(`student_name_${n.id}_${L}`),children:[e.jsx("button",{type:"button",className:`${s.styles["button-user-name"]} btn-link`,onClick:()=>{$(n),Ae(!0)},children:n.fullName}),e.jsx(i.Tooltip,{placement:"top",isOpen:w===`student_name_${n.id}_${L}`,target:`student_name_${n.id}_${L}`,children:n.fullName})]}),e.jsx("td",{className:`align-middle ${s.styles["fixed-width"]}`,id:`student_email_${n.id}_${L}`,onMouseEnter:()=>k(`student_email_${n.id}_${L}`),onMouseLeave:()=>k(`student_email_${n.id}_${L}`),children:e.jsx("p",{children:n.gradeLevel})}),e.jsxs("td",{className:`align-middle ${s.styles["equal-width"]}`,id:`student_teacher_${n.id}_${L}`,onMouseEnter:()=>k(`student_teacher_${n.id}_${L}`),onMouseLeave:()=>k(`student_teacher_${n.id}_${L}`),children:[!!n.teachers&&n.teachers.length>0&&e.jsx(u.Fragment,{children:n.teachers.map(M=>e.jsxs("p",{className:"mb-0",children:[M.mainTeacherName," - ",M.mainTeacherEmail]},M.mainTeacherEmail))}),!!n.teachers&&n.teachers.length>0&&e.jsx(i.Tooltip,{placement:"top",isOpen:w===`student_teacher_${n.id}_${L}`,target:`student_teacher_${n.id}_${L}`,children:n.teachers.map(M=>e.jsxs("p",{className:"mb-0",children:[M.mainTeacherName," - ",M.mainTeacherEmail]},M.mainTeacherEmail))})]}),e.jsxs("td",{className:`align-middle ${s.styles["equal-width"]}`,id:`student_assistant_${n.id}_${L}`,onMouseEnter:()=>k(`student_assistant_${n.id}_${L}`),onMouseLeave:()=>k(`student_assistant_${n.id}_${L}`),children:[!!n.assistantEmail&&e.jsxs("p",{className:"mb-0",children:[n.assistantName," - ",n.assistantEmail]}),!!n.assistantEmail&&e.jsxs(i.Tooltip,{placement:"top",isOpen:w===`student_assistant_${n.id}_${L}`,target:`student_assistant_${n.id}_${L}`,children:[n.assistantName,"-",n.assistantEmail]})]}),e.jsxs("td",{className:`align-middle ${s.styles["equal-width"]}`,id:`student_counselor_${n.id}_${L}`,onMouseEnter:()=>k(`student_counselor_${n.id}_${L}`),onMouseLeave:()=>k(`student_counselor_${n.id}_${L}`),children:[!!n.counselors&&n.counselors.length>0&&e.jsx(u.Fragment,{children:n.counselors.map(M=>e.jsxs("p",{className:"mb-0",children:[M.counselorName," - ",M.counselorEmail]},M.counselorUserId))}),!!n.counselors&&n.counselors.length>0&&e.jsx(i.Tooltip,{placement:"top",isOpen:w===`student_counselor_${n.id}_${L}`,target:`student_counselor_${n.id}_${L}`,children:n.counselors.map(M=>e.jsxs("p",{className:"mb-0",children:[M.counselorName," - ",M.counselorEmail]},M.counselorUserId))})]}),e.jsxs("td",{className:`align-middle ${s.styles["equal-width"]}`,id:`student_secondary_teacher_${n.id}_${L}`,onMouseEnter:()=>k(`student_secondary_teacher_${n.id}_${L}`),onMouseLeave:()=>k(`student_secondary_teacher_${n.id}_${L}`),children:[!!n.secondaryTeacherEmail&&e.jsxs("p",{className:"mb-0",children:[n.secondaryTeacherName," - ",n.secondaryTeacherEmail]}),!!n.secondaryTeacherEmail&&e.jsxs(i.Tooltip,{placement:"top",isOpen:w===`student_secondary_teacher_${n.id}_${L}`,target:`student_secondary_teacher_${n.id}_${L}`,children:[n.secondaryTeacherName," - ",n.secondaryTeacherEmail]})]})]},`${n.id}_${L}`))}):e.jsx("div",{style:{width:"max-content",padding:20},children:t("no_data")})]})})}),e.jsx(i.Col,{md:12,children:e.jsx(s.CustomPagination,{filters:N,totalRecordCount:I,changePageSize:n=>J({pageSize:n}),changePage:n=>J({currentPage:n})})})]}),e.jsx(is,{openDetailModal:Le,onClose:Se,selectedUser:x,staffBulkAssign:X,teacherOptions:c,handleChangeTeacherBulk:W,handleChangeCounselorBulk:oe,assistantOptions:a,counselorOptions:o,secondaryTeacherOptions:h,handleChangeStaffBulk:z,handleEditAssignForStudents:he,toggleCollapse:Ee,activeIndex:ke}),e.jsx(cs,{textModal:ge,isOpen:K,teachers:fe,options:pe,onClose:xe,onSave:ye,modalType:ie,setTeacherChangeUserId:be,setTeacherSelectForChangeUserId:Ne,teacherSelectForChangeUserId:we}),e.jsx(ds,{open:Ue,onClose:Oe,teachers:x?.teachers?.filter(n=>!Me.includes(n.teacherUserId))||[],onConfirm:he,teacherSwitchUserId:De,setTeacherSwitchUserId:Be}),e.jsx(fs,{open:g,onClose:_e,teachers:re,onChangeStaffRemove:v,switchStaffUsers:T,counselors:ne,assistants:Z,onRemoveBulkStaff:D,studentUserIds:_,secondaryTeachers:ce,teacherOptions:de(c,_,H),assistantOptions:de(a,_,H),counselorOptions:de(o,_,H),secondaryTeacherOptions:de(h,_,H)})]})},vs=()=>{const t=le.useDispatch(),[l,c]=u.useState(j.initialUserChoice),[r,d]=u.useState([]),[a,S]=u.useState(""),f=async()=>{try{const m=await s.getTeacher();d(m.data)}catch(m){t(s.setAlert({type:"danger",message:m.response?.data?.title||m.message}))}},o=r.map(m=>({label:`${m.name} - ${m.email}`,value:m.id}));return u.useEffect(()=>{l.roles?.includes("Teacher")&&f()},[l]),{userChoiced:l,setUserChoiced:c,teacherList:r,options:o,setTeacherChangeId:S,teacherChangeId:a}},xs="User deleted list",Ss=()=>{const{userChoiced:t,setUserChoiced:l,options:c,teacherChangeId:r,setTeacherChangeId:d}=vs(),[a,S]=u.useState([]),[f,o]=u.useState(0),{filters:m,changeFilters:b}=s.useFilters(),h=le.useDispatch(),E=u.useRef(null),_=()=>{E&&E.current&&E.current.toggle()},U=()=>{d(""),l(j.initialUserChoice)},N=u.useCallback(async()=>{h(s.setLoading(!0));try{const R=await s.get(m),{items:J,totalItems:V}=R.data;S(J),o(V)}catch(R){h(s.setAlert({type:"danger",message:R.response?.data?.title||R.message}))}h(s.setLoading(!1))},[h,m]);u.useEffect(()=>{document.title=xs},[]),u.useEffect(()=>{N()},[m]);const I=u.useCallback(R=>{h(s.setModal({isOpen:!0,type:"warning",message:"Do you want to remove this user?",onConfirm:async()=>{h(s.setLoading(!0));try{t.roles.includes("Teacher")?await s.remove(R,r):await s.remove(R),h(s.setAlert({type:"success",message:"Remove user successfully"})),_(),U(),b({currentPage:1})}catch(J){h(s.setAlert({type:"danger",message:J.response?.data?.title||J.message}))}h(s.setLoading(!1))}}))},[m,r,t]);return{userList:a,totalItems:f,filters:m,getData:N,removeData:I,changeFilters:b,modal:E,openModal:_,userChoiced:t,setUserChoiced:l,options:c,teacherChangeId:r,setTeacherChangeId:d,resetData:U}},Ts=(t,l)=>{const{header:c,removeData:r,resetData:d,userChoiced:a,options:S,teacherChangeId:f,setTeacherChangeId:o}=t,{t:m}=te.useTranslation(),b=()=>{var h=window.location.origin+"/api/ExportDataUser/"+a.id;window.open(h)};return e.jsx(s.CommonModal,{header:c,ref:l,onCancel:()=>{d()},children:e.jsx(i.Row,{children:e.jsxs(i.Col,{md:12,className:"mb-2",children:[e.jsx("p",{children:m("export_user_data")}),e.jsx("div",{className:"pb-3",children:e.jsx(i.Button,{color:"success",onClick:()=>{b()},style:{color:"#fff"},children:m("download_users_data")})}),e.jsx("p",{children:"Delete user"}),!!a&&e.jsxs("div",{children:[a.roles.includes("Student")&&e.jsxs("div",{children:[e.jsx(i.Alert,{color:"danger",children:m("alert_delete_user")}),e.jsx(i.Button,{color:"danger",onClick:()=>r(a.id),style:{color:"#fff"},children:m("delete_user")})]}),a.roles.includes("Admin")&&e.jsxs("div",{children:[e.jsx(i.Alert,{color:"danger",children:m("alert_delete_user")}),e.jsx(i.Button,{color:"danger",onClick:()=>r(a.id),children:m("delete_user")})]}),a.roles.includes("Teacher")&&e.jsxs("div",{children:[e.jsx(i.Alert,{color:"warning",children:m("alert_delete_user")}),e.jsx(s.CustomSelector,{options:S,defaultValue:f,placeholder:"select_teacher_change",onChange:h=>o(h.value)}),!!f&&e.jsxs("div",{className:"mt-2",children:[e.jsx(i.Alert,{color:"danger",children:m("alert_delete_user")}),e.jsx(i.Button,{color:"danger",onClick:()=>r(a.id),children:m("delete_user")})]})]}),(a.roles.includes("Parent")||a.roles.includes("Counselor")||a.roles.includes("SecondaryTeacher"))&&e.jsxs("div",{children:[e.jsx(i.Alert,{color:"danger",children:m("alert_delete_user")}),e.jsx(i.Button,{color:"danger",onClick:()=>r(a.id),children:m("delete_user")})]})]})]})})})},Cs=u.forwardRef(Ts),js="user_deleted",_s=()=>{const{userList:t,totalItems:l,filters:c,changeFilters:r,removeData:d,openModal:a,modal:S,userChoiced:f,setUserChoiced:o,options:m,teacherChangeId:b,setTeacherChangeId:h,resetData:E}=Ss(),{t:_}=te.useTranslation(),U=N=>{N&&o(N),a()};return e.jsxs("div",{className:"fadeIn animated",children:[e.jsx("h5",{className:"mt-4 mb-2",children:_(js)}),e.jsxs(i.Row,{className:"my-2",children:[e.jsx(i.Col,{md:8,children:e.jsx(s.SearchBox,{initValue:c.searchString,onSearch:N=>r({searchString:N}),placeholder:_("type_something_to_search_reflection_result")})}),e.jsxs(i.Col,{md:4,className:"d-flex justify-content-end align-items-center",children:[_("total_of_users"),": ",l]})]}),e.jsxs(i.Row,{className:"mb-2",children:[e.jsx(i.Col,{md:12,children:t&&t.length>0?e.jsx("div",{children:e.jsxs(i.Table,{bordered:!0,hover:!0,striped:!0,responsive:!0,size:"sm",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{className:"align-top",children:_("name")}),e.jsx("th",{className:"align-top",children:_("email")}),e.jsx("th",{className:"align-top",children:_("role")})]})}),e.jsx("tbody",{children:t.map(N=>e.jsxs("tr",{children:[e.jsx("td",{className:"align-middle",children:e.jsx(s.LinkEditButton,{label:`${N.fullName}`,onClick:()=>U(N)})}),e.jsx("td",{className:"align-middle",children:N.email}),e.jsx("td",{className:"align-middle",children:!!N.roles&&N.roles.map(I=>I==="SecondaryTeacher"?"SupportTeacher":I).join(", ")})]},N.id))})]})}):e.jsx(s.EmptyDataAlert,{label:_("user")})}),e.jsx(i.Col,{md:12,children:e.jsx(s.CustomPagination,{filters:c,totalRecordCount:l,changePageSize:N=>r({pageSize:N}),changePage:N=>r({currentPage:N})})})]}),e.jsx(Cs,{ref:S,header:f.fullName,onCancel:()=>{},userChoiced:f,removeData:d,options:m,teacherChangeId:b,setTeacherChangeId:h,resetData:E})]})},Is={padding:"4px 8px",marginBottom:0,borderRadius:"4px",color:"#fff",fontWeight:500,fontSize:"14px",height:"56px",justifyContent:"center"},Ie=({htmlFor:t,isDisabled:l,text:c,backgroundColor:r,onClick:d,isClassReflection:a})=>e.jsxs(i.Label,{htmlFor:t,role:"button",tabIndex:0,className:`d-flex align-items-center justfy-content-center mr-2
2
+ ${a?"w-25":""}
3
+ ${l?"":"cursor-pointer hover-opacity"}`,style:{...Is,backgroundColor:r,opacity:l?.5:1,gap:"8px"},onClick:S=>d(),children:[e.jsx("i",{className:"fa fa-paperclip mr-1","aria-hidden":"true"}),c]}),Ve=`${s.BASE_URL}/api/ImportCsv/csv`,Fe=`${s.BASE_URL}/api/Teacher`,bs=(t,l)=>s.apiUpload.post(`${Ve}/${l}`,t),Je=t=>s.apiUpload.post(`${Ve}/importClassReflection`,t),Ns=(t,l)=>s.apiUpload.post(`${Fe}/adminImportStudentByTeacherId/${t}`,l),ws=t=>s.api.post(`${Fe}/adminImportChunkUser`,t),Ls=(t=!0)=>s.api.get(`${Fe}/download-template-file-user?hasEsSchool=${t}`);var He=(t=>(t.Students="students",t.Subjects="subjects",t.Grades="grades",t.Attendances="attendances",t.ClassReflection="classReflection",t.Others="others",t.AllUser="allUser",t))(He||{});const As=[{text:"import_users",backgroundColor:"#0abde3",type:"allUser"}],Es=[{text:"import_class_reflection",backgroundColor:"#e74c3c",type:"classReflection"}],ks="CSV Import",Re="csvupload",ze={teacherName:"",teacherEmail:"",studentIds:[],file:""},Ms=()=>{const t=le.useDispatch(),l=le.useSelector(y=>y.common.isLoading),[c,r]=u.useState(null),[d,a]=u.useState(),[S,f]=u.useState([]),[o,m]=u.useState(ze),[b,h]=u.useState(),[E,_]=u.useState([]),N=window.location.hostname.includes("isb"),[I,R]=u.useState(0),[J,V]=u.useState(""),x=le.useSelector(y=>y.common.user)?.hasEsSchool!==!1;u.useEffect(()=>{document.title=ks},[]);const $=N?As:Es,P=async()=>{t(s.setLoading(!0));try{const C=await Ls(x);var y=new Blob([C.data.content],{type:"text/csv"});const O=window.URL.createObjectURL(y);var p=document.createElement("a");p.href=O,p.setAttribute("download",C.data.nameFile),p.click(),t(s.setAlert({type:"success",message:"Download successfully"}))}catch(C){t(s.setAlert({type:"danger",message:C.message}))}t(s.setLoading(!1))},H=u.useCallback(async y=>{if(!c||!y)return;t(s.setLoading(!0));try{const F=new FormData;F.append("file",y,y.name);const G=c==="allUser"?s.CsvImportType.Admin:s.CsvImportType.Teacher,X=await je.validateCsvApi(F,G,x);if(X.data&&X.data.length>0){_(X.data),t(s.setLoading(!1)),t(s.setAlert({type:"danger",message:"Please use the file as per the template."}));return}if(c=="allUser"){let ee=(await y.text()).trim();const se=ee.split(`
4
+ `).map(K=>K.trim()),ue=se.findIndex(K=>K.split(",").includes("First Name"));if(ue===0)throw new Error("Invalid CSV: Missing header row.");ee=se.slice(ue).join(`
5
+ `);const me=Qe.parse(ee,{header:!0,skipEmptyLines:!0}),W=me.meta.fields,oe=me.data;if(!oe.length){t(s.setLoading(!1)),t(s.setAlert({type:"danger",message:"The file has no data or some column names are misformed."}));return}const he=10,ie=[];for(let K=0;K<oe.length;K+=he){const ge=oe.slice(K,K+he).map(fe=>Object.values(fe).map(xe=>(xe??"").toString().trim()));W&&ge.unshift(W),ie.push(ge)}for(let K=0;K<ie.length;K++)await ws({index:K,chunks:ie[K]}),await new Promise(pe=>setTimeout(pe,500))}else N?c=="classReflection"&&await Je(F):await bs(F,c.toString());t(s.setAlert({type:"success",message:"Import CSV successfully"}))}catch(F){console.error("❌ Upload failed",F),t(s.setAlert({type:"danger",message:F.response?.data?.title||F.message}))}t(s.setLoading(!1));const p=document.getElementById(Re),C=document.getElementById("import-student"),O=document.getElementById("import-classReflection");p&&(p.value=""),C&&(C.value=""),O&&(O.value="")},[c]),re=async y=>{if(!I){t(s.setAlert({type:"danger",message:"Select teacher before import csv"}));return}if(!c||!y)return;t(s.setLoading(!0));try{const C=new FormData;C.append("file",y,y.name),await Ns(I,C),t(s.setAlert({type:"success",message:"Import CSV successfully"}))}catch(C){t(s.setAlert({type:"danger",message:C.response?.data?.title||C.message}))}t(s.setLoading(!1));const p=document.getElementById("teacherSelector");p&&(p.value="")},ne=async y=>{if(!d||!d)return;t(s.setLoading(!0));try{const C=new FormData;C.append("file",d,d.name),C.append("teacherName",y.teacherName),C.append("teacherEmail",y.teacherEmail),y.studentIds.forEach(O=>{C.append("studentIds",O)}),await Je(C),t(s.setAlert({type:"success",message:"Import CSV successfully"})),m(ze)}catch(C){t(s.setAlert({type:"danger",message:C.response?.data?.title||C.message}))}t(s.setLoading(!1));const p=document.getElementById(Re);p&&(p.value="")},Z=y=>{R(y.value)},ce=y=>{h(y),V(y?.name||"")},ae=()=>{if(!b){t(s.setAlert({type:"danger",message:"Select CSV to import"}));return}re(b)};return{isLoading:l,buttons:$,id:Re,setType:r,upload:H,initImportReflection:o,setInitImportReflection:m,onConfirm:ne,CSVType:He,dataFile:d,setDataFile:a,setArrStudent:f,arrStudent:S,isCheckDomainIBS:N,onChangeTeacher:Z,uploadByTeacherId:re,setDataFileImportStudent:ce,onUpLoadStudentFile:ae,defaultTeacher:I,fileName:J,onStudentSubmit:()=>{t(s.setModal({isOpen:!0,type:"warning",message:"Are you sure upload this file?",onConfirm:()=>{ae()}}))},downloadTemplateUser:P,errorsValidate:E,setErrorsValidate:_}},Us=Ce.object({teacherName:Ce.string()?.trim().required(),teacherEmail:Ce.string()?.trim().email("Invalid email").required(),studentIds:Ce.array().required().test("test students","Please choose student",function(){return!!this.parent.studentIds&&!!this.parent.studentIds.length}),file:Ce.string()?.trim().required()}),Os=()=>{const{initImportReflection:t,onConfirm:l,isLoading:c,setType:r,id:d,CSVType:a,dataFile:S,setDataFile:f,setArrStudent:o,buttons:m,upload:b,isCheckDomainIBS:h,downloadTemplateUser:E,errorsValidate:_,setErrorsValidate:U}=Ms(),{t:N}=te.useTranslation();return e.jsx("div",{className:"animated fadeIn pt-3",children:h?e.jsxs(e.Fragment,{children:[e.jsx(i.Input,{className:"d-none",type:"file",id:"import-user",onChange:I=>b(I.target.files[0]),accept:"text/csv"}),e.jsx(i.Input,{className:"d-none",type:"file",id:"import-classReflection",onChange:I=>b(I.target.files[0]),accept:"text/csv"}),e.jsx("div",{className:"class-reflection",children:e.jsx(Ge.Formik,{initialValues:t,enableReinitialize:!0,validationSchema:Us,onSubmit:(I,R)=>{l(I),f(""),o([]),R.resetForm()},children:I=>{const{touched:R,errors:J}=I;return e.jsxs(i.Row,{className:"mb-2",children:[e.jsx(i.Input,{className:"d-none",type:"file",id:d,onChange:V=>{f(V.target.files[0]),I.setFieldValue("file","imported");const Y=document.getElementById(d);Y&&(Y.value="")},accept:"text/csv"}),e.jsx(i.Col,{md:6,className:"mb-2 d-flex mt-5",children:e.jsxs(i.Row,{className:"w-100 flex-column",children:[e.jsxs(i.Col,{md:12,className:"",children:[e.jsx(s.RequiredLabel,{text:N("import_class_reflection")}),e.jsx(Ie,{htmlFor:"import-classReflection",text:N("import_class_reflection"),isDisabled:c,backgroundColor:"#e74c3c",onClick:()=>{r(a.ClassReflection)}},"Import class reflections"),!!S&&e.jsx("p",{style:{color:"#007bff",fontStyle:"italic",marginTop:"5px"},children:S.name})]}),!S&&e.jsx(i.Col,{md:12,className:"mb-2",children:R.file&&J.file&&e.jsx(s.ErrorHandler,{text:J.file})})]})}),e.jsx(i.Col,{md:6,className:"mb-2",children:e.jsxs(i.Row,{className:"flex-column",children:[e.jsx(i.Col,{md:12,className:"mb-2 text-right",style:{textAlign:"right"},children:e.jsx(i.Button,{role:"button",color:"primary",onClick:()=>E(),children:e.jsxs("p",{className:"d-flex align-items-center mb-0",children:[N("download_template")," ",e.jsx(je.AiOutlineDownload,{size:20,className:"ml-2"})]})})}),e.jsxs(i.Col,{md:12,className:"mb-2",children:[e.jsx(s.RequiredLabel,{text:N("import_users")}),m.map(V=>e.jsx(Ie,{htmlFor:"import-user",text:V.text,isDisabled:c,backgroundColor:V.backgroundColor,onClick:()=>r(V.type)},V.text))]}),_?.length>0&&_.map((V,Y)=>e.jsx(s.ErrorHandler,{text:V},Y))]})})]})}})})]}):e.jsx(e.Fragment,{children:e.jsxs(i.Row,{children:[e.jsx(i.Col,{md:12,className:"mt-2 mb-2 text-left",children:e.jsx(i.Button,{role:"button",color:"primary",onClick:()=>E(),children:e.jsxs("p",{className:"d-flex align-items-center mb-0",children:[N("download_template")," ",e.jsx(je.AiOutlineDownload,{size:20,className:"ml-2"})]})})}),e.jsxs(i.Col,{md:6,className:"mb-3",children:[e.jsx(i.Input,{id:"import-user",className:"d-none",type:"file",onChange:I=>b(I.target.files[0]),accept:"text/csv"}),e.jsx(s.RequiredLabel,{text:N("import_users")}),e.jsx(Ie,{htmlFor:"import-user",text:N("import_users"),isDisabled:c,backgroundColor:"#0abde3",onClick:()=>{r(a.AllUser),_.length>0&&U([])}},"import-users")]}),_.length>0&&_.map((I,R)=>e.jsx(s.ErrorHandler,{text:I},R)),e.jsxs(i.Col,{md:6,className:"mb-3",children:[e.jsx(i.Input,{className:"d-none",type:"file",id:d,onChange:I=>b(I.target.files[0]),accept:"text/csv"}),m.map(I=>e.jsxs(e.Fragment,{children:[e.jsx(s.RequiredLabel,{text:N(I.text)}),e.jsx(Ie,{htmlFor:d,text:N(I.text),isDisabled:c,backgroundColor:I.backgroundColor,onClick:()=>r(I.type)},I.text)]}))]})]})})})},Ds=[{path:"/admin/users/user-list",title:"user_list",component:je.UserList},{path:"/admin/users/assign-student",title:"assign_student",component:ys},{path:"/admin/users/user-deleted",title:"user_deleted",component:_s},{path:"/admin/users/import-csv",title:"csv_import",component:Os}],Bs=()=>e.jsx(s.CustomTabs,{tabs:Ds});exports.default=Bs;