mario-core 2.0.127-release → 2.0.128-release
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Dashboard-Dn1Xl7SC.js +1 -0
- package/dist/Dashboard-DxrE_UdE.mjs +206 -0
- package/dist/EmailTemplateDetail-BxDmv_IB.mjs +443 -0
- package/dist/EmailTemplateDetail-c2h1KwyT.js +1 -0
- package/dist/EmailTemplateList-C6KbuCHO.mjs +170 -0
- package/dist/EmailTemplateList-Dk7gCfdy.js +1 -0
- package/dist/GalleryList-CG-GA7Go.mjs +329 -0
- package/dist/GalleryList-p6WP3Krc.js +1 -0
- package/dist/Login-BMRuV2H4.js +1 -0
- package/dist/Login-Ch1dKH9m.mjs +1700 -0
- package/dist/NotificationList-51yt2V-v.js +1 -0
- package/dist/NotificationList-bZsuTSkC.mjs +419 -0
- package/dist/SkillList-BQM2FIla.mjs +386 -0
- package/dist/SkillList-BxqOHumi.js +1 -0
- package/dist/TeacherSelector-CrH5Ji_R.mjs +30 -0
- package/dist/TeacherSelector-DYwwL8rL.js +1 -0
- package/dist/TheContent-B_P8fq4J.mjs +38 -0
- package/dist/TheContent-C5I2GeSi.js +1 -0
- package/dist/UserContainer-JB0zF0Be.js +5 -0
- package/dist/UserContainer-QmPiHlko.mjs +2698 -0
- package/dist/UserDetail-BuhWeZrj.mjs +913 -0
- package/dist/UserDetail-ClL8qEKG.js +1 -0
- package/dist/UserList-Crz4aLRP.mjs +1514 -0
- package/dist/UserList-DoZZeZzW.js +7 -0
- package/dist/constants-DF79sw6a.mjs +241 -0
- package/dist/constants-DSNqVx4Y.js +1 -0
- package/dist/index-CD8bO3wO.js +15 -0
- package/dist/index-CfBp3NrB.mjs +22670 -0
- package/dist/mailCategoryService-C9FSK6lv.js +1 -0
- package/dist/mailCategoryService-CRdM3FRx.mjs +11 -0
- package/dist/shared/gradeYear/ukYearCsv.d.ts +4 -0
- package/dist/userService-CDfW2VnH.js +1 -0
- package/dist/userService-CjQDQKT0.mjs +47 -0
- package/package.json +113 -113
|
@@ -0,0 +1,386 @@
|
|
|
1
|
+
import { jsx as t, jsxs as h } from "react/jsx-runtime";
|
|
2
|
+
import { useState as v, useEffect as I, forwardRef as q, useCallback as N, useRef as z } from "react";
|
|
3
|
+
import { Row as T, Col as y, Input as M, Label as V, Table as U } from "reactstrap";
|
|
4
|
+
import { useTranslation as B } from "react-i18next";
|
|
5
|
+
import { i as E, B as O, a2 as H, a3 as K, $ as Q, E as W, O as X, b as f, a4 as G, c as S, R as J, _ as Y, S as Z, T as ee, V as te, W as se, X as ae } from "./index-CfBp3NrB.mjs";
|
|
6
|
+
import { Formik as le } from "formik";
|
|
7
|
+
import * as R from "yup";
|
|
8
|
+
import { useSelector as j, useDispatch as A } from "react-redux";
|
|
9
|
+
const L = `${O}/api/Skill`, P = (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] = v([]);
|
|
11
|
+
I(() => {
|
|
12
|
+
o();
|
|
13
|
+
}, []);
|
|
14
|
+
const o = async () => {
|
|
15
|
+
try {
|
|
16
|
+
const i = await P();
|
|
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
|
+
H,
|
|
28
|
+
{
|
|
29
|
+
options: u,
|
|
30
|
+
defaultValue: m,
|
|
31
|
+
...e,
|
|
32
|
+
isDisabled: l
|
|
33
|
+
}
|
|
34
|
+
);
|
|
35
|
+
}, de = R.object({
|
|
36
|
+
name: R.string().required("Name is required"),
|
|
37
|
+
description: R.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 } = B();
|
|
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
|
+
K,
|
|
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(T, { children: [
|
|
84
|
+
/* @__PURE__ */ h(y, { md: 12, className: "mb-2", children: [
|
|
85
|
+
/* @__PURE__ */ t(Q, { 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
|
+
W,
|
|
100
|
+
{
|
|
101
|
+
text: C.name
|
|
102
|
+
}
|
|
103
|
+
)
|
|
104
|
+
] }),
|
|
105
|
+
/* @__PURE__ */ h(y, { md: 12, className: "mb-2", children: [
|
|
106
|
+
/* @__PURE__ */ t(V, { 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(V, { 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 = q(me), he = "Skill list", pe = () => {
|
|
145
|
+
const e = j((n) => n.skills.skillList), s = j((n) => n.skills.totalItems), { t: c } = B(), { filters: o, changeFilters: m } = X(), l = A(), u = N(async () => {
|
|
146
|
+
l(f(!0));
|
|
147
|
+
try {
|
|
148
|
+
const n = await P(o), { items: r, totalItems: k } = n.data;
|
|
149
|
+
l(G({ 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 = N(
|
|
160
|
+
(n) => {
|
|
161
|
+
l(f(!0));
|
|
162
|
+
try {
|
|
163
|
+
l(
|
|
164
|
+
J({
|
|
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
|
+
}, _ = {
|
|
212
|
+
name: "",
|
|
213
|
+
description: "",
|
|
214
|
+
path: "",
|
|
215
|
+
parentSkillId: null
|
|
216
|
+
}, ge = () => {
|
|
217
|
+
const e = A(), [s, c] = v(0), [o, m] = v(_), [l, u] = v(!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(_);
|
|
224
|
+
}, [s]);
|
|
225
|
+
const r = () => {
|
|
226
|
+
c(0), m(_);
|
|
227
|
+
};
|
|
228
|
+
I(() => {
|
|
229
|
+
n();
|
|
230
|
+
}, []);
|
|
231
|
+
const k = N(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 = N(
|
|
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: _,
|
|
273
|
+
reset: r,
|
|
274
|
+
edited: l,
|
|
275
|
+
setEdited: u,
|
|
276
|
+
setEditedTrue: i,
|
|
277
|
+
setEditedFalse: n
|
|
278
|
+
};
|
|
279
|
+
}, Ie = () => {
|
|
280
|
+
const e = z(null), { t: s } = B(), {
|
|
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(Y, { when: g }),
|
|
324
|
+
/* @__PURE__ */ h(T, { 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(T, { className: "mb-2", children: [
|
|
346
|
+
/* @__PURE__ */ t(y, { md: 8, children: c && c.length > 0 ? /* @__PURE__ */ h(U, { 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-CD8bO3wO.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,30 @@
|
|
|
1
|
+
import { jsxs as n, jsx as e } from "react/jsx-runtime";
|
|
2
|
+
import { useState as m } from "react";
|
|
3
|
+
import { ax as l } from "./index-CfBp3NrB.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 @@
|
|
|
1
|
+
"use strict";const e=require("react/jsx-runtime"),i=require("react"),l=require("./index-CD8bO3wO.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,38 @@
|
|
|
1
|
+
import { jsx as a, jsxs as n } 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 { L as u } from "./index-CfBp3NrB.mjs";
|
|
6
|
+
const N = /* @__PURE__ */ a("div", { className: "app-initial-loader", style: { position: "relative", height: "100%", minHeight: "400px", backgroundColor: "transparent", width: "100%" }, children: /* @__PURE__ */ n("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__ */ n("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 = ["/journey-insights/"], x = ({ routes: s }) => {
|
|
23
|
+
const i = p(), { pathname: o } = i, l = o.includes("/admin") ? "" : "box-container", d = o.includes("/admin") ? f.some((e) => o.includes(e)) ? "p-0" : "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__ */ n(h, { children: [
|
|
25
|
+
s.map((e, c) => /* @__PURE__ */ a(
|
|
26
|
+
t,
|
|
27
|
+
{
|
|
28
|
+
path: e.path,
|
|
29
|
+
element: /* @__PURE__ */ a(e.component, {})
|
|
30
|
+
},
|
|
31
|
+
c
|
|
32
|
+
)),
|
|
33
|
+
/* @__PURE__ */ a(t, { path: "*", element: /* @__PURE__ */ a(u, {}) })
|
|
34
|
+
] }) }) }) });
|
|
35
|
+
}, j = m(x);
|
|
36
|
+
export {
|
|
37
|
+
j as default
|
|
38
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),t=require("react"),n=require("react-router-dom"),r=require("@coreui/react"),m=require("./index-CD8bO3wO.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"})]})]})}),h=["/journey-insights/"],x=({routes:o})=>{const i=n.useLocation(),{pathname:a}=i,c=a.includes("/admin")?"":"box-container",l=a.includes("/admin")?h.some(s=>a.includes(s))?"p-0":"p-4":"";return e.jsx("main",{className:`c-main ${c}`,style:{height:"100%"},children:e.jsx(r.CContainer,{fluid:!0,className:`h-100 ${l}`,style:{flex:1},children:e.jsx(t.Suspense,{fallback:u,children:e.jsxs(n.Routes,{children:[o.map((s,d)=>e.jsx(n.Route,{path:s.path,element:e.jsx(s.component,{})},d)),e.jsx(n.Route,{path:"*",element:e.jsx(m.NotFound,{})})]})})})})},p=t.memo(x);exports.default=p;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),t=require("./index-CD8bO3wO.js"),W=require("./UserList-DoZZeZzW.js"),i=require("react"),l=require("reactstrap"),le=require("react-i18next"),C=require("./constants-DSNqVx4Y.js"),Se=require("react-redux"),se=require("./userService-CDfW2VnH.js"),ze=require("./TeacherSelector-DYwwL8rL.js"),Xe=require("react-select"),Ze=require("papaparse"),et=require("formik"),tt=require("yup");function st(s){const o=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(s){for(const r in s)if(r!=="default"){const c=Object.getOwnPropertyDescriptor(s,r);Object.defineProperty(o,r,c.get?c:{enumerable:!0,get:()=>s[r]})}}return o.default=s,Object.freeze(o)}const be=st(tt),He="Cannot update two school levels at the same time.",Te=s=>W.resolveStudentTier(s),Ge=s=>{const o=Object.entries(s).filter(([r])=>r!=="currentPage"&&r!=="cursor").sort(([r],[c])=>r.localeCompare(c));return JSON.stringify(o)},at=s=>{if(s===void 0)return;const o=C.UserOrder[s];return o?o.charAt(0).toLowerCase()+o.slice(1):void 0},nt=()=>{const s=Se.useDispatch(),[o,r]=i.useState([]),[c,x]=i.useState(C.DEFAULT_STUDENT_FILTER),[n,_]=i.useState(0),[f,m]=i.useState([]),[S,D]=i.useState([]),[u,w]=i.useState(C.initAssignStd),L="",E=i.useRef({}),j=i.useRef(""),I=i.useMemo(()=>{const v=S.find(p=>!!Te(p));return Te(v)},[S]),O=v=>{const p=Object.keys(v).every(N=>N==="currentPage"),d={...c,...v};p||(d.currentPage=1,E.current={},j.current=Ge(d)),x(d)},K=i.useMemo(()=>{const v=o.filter(d=>f.includes(d.id)).flatMap(d=>d.teachers),p=new Map;return v.forEach(d=>{p.has(d.teacherUserId)||p.set(d.teacherUserId,d)}),Array.from(p.values()).map(d=>({value:d.teacherUserId,label:d.mainTeacherEmail}))},[S,f]),A=i.useMemo(()=>{const v=o.filter(d=>f.includes(d.id)).flatMap(d=>d.counselors),p=new Map;return v.forEach(d=>{p.has(d.counselorUserId)||p.set(d.counselorUserId,d)}),Array.from(p.values()).map(d=>({value:d.counselorUserId,label:d.counselorEmail}))},[S,f]),Q=i.useMemo(()=>{const v=o.filter(d=>f.includes(d.id)&&d.assistantUserId).map(d=>({value:d.assistantUserId,label:d.assistantEmail})),p=new Map;return v.forEach(d=>{p.has(d.value)||p.set(d.value,d)}),Array.from(p.values())},[o,f]),re=i.useMemo(()=>{const v=o.filter(d=>f.includes(d.id)&&d.secondaryTeacherUserId).map(d=>({value:d.secondaryTeacherUserId,label:d.secondaryTeacherEmail})),p=new Map;return v.forEach(d=>{p.has(d.value)||p.set(d.value,d)}),Array.from(p.values())},[o,f]),oe=i.useCallback(v=>{v!==c.sortBy?O({sortBy:v,orderBy:"ASC",currentPage:1}):O({sortBy:v,orderBy:c.orderBy!=="DESC"?"DESC":"ASC",currentPage:1})},[JSON.stringify(c)]),Z=async()=>{s(t.setLoading(!0));try{const v=c.currentPage||1,p=Ge(c);j.current!==p&&(E.current={},j.current=p);const d=Object.entries(c).filter(([J,ae])=>ae!==void 0).reduce((J,[ae,ne])=>(J[ae]=ne,J),{}),N={};for(const J in d){if(J==="currentPage"){N.page=d[J];continue}if(J==="orderBy"||J==="cursor")continue;if(J==="sortBy"){const ne=at(d[J]);ne!==void 0&&(N.sortBy=ne);continue}const ae=J.charAt(0).toLowerCase()+J.slice(1);N[ae]=d[J]}N.isDescending=c.isDescending??c.orderBy==="DESC";const F=Object.prototype.hasOwnProperty.call(E.current,v);v===1?N.cursor="":F&&(N.cursor=E.current[v]);const ee=(await se.getAssignStudentApi(N))?.data||{},de=ee?.nextCursor||ee?.pagination?.nextCursor;de?E.current[v+1]=de:delete E.current[v+1],r(ee?.items||ee?.pagination?.items||[]),_(ee?.totalItems||ee?.pagination?.totalItems||0)}catch(v){s(t.setAlert({type:"danger",message:v.response?.data?.title||v.message}))}s(t.setLoading(!1))},y=i.useMemo(()=>v=>{const p=Te(v);return!!I&&!!p&&p!==I},[I]),$=i.useMemo(()=>{const v=o.filter(p=>!y(p));return v.length>0&&v.every(p=>f.includes(p.id))},[o,f,y]),V=()=>{if($){const d=new Set(o.map(N=>N.id));m(N=>N.filter(F=>!d.has(F))),D(N=>N.filter(F=>!d.has(F.id)));return}const v=I??Te(o.find(d=>!!Te(d))),p=o.filter(d=>{const N=Te(d);return!N||!v||N===v});if(p.length===0&&o.length>0){q();return}m(d=>{const N=p.map(F=>F.id).filter(F=>!d.includes(F));return[...d,...N]}),D(d=>{const N=new Set(d.map(G=>G.id)),F=p.filter(G=>!N.has(G.id));return[...d,...F]})},q=()=>{s(t.setAlert({type:"warning",message:He}))},pe=v=>{const{id:p,checked:d}=v.target,N=o.find(F=>F.id===p);if(d&&N&&y(N)){q();return}d?(m(F=>[...F,p]),N&&D(F=>[...F,N])):(m(F=>F.filter(G=>G!==p)),D(F=>F.filter(G=>G.id!==p)))},k=i.useCallback(()=>{c.currentPage==1?Z():O({currentPage:1}),m([]),D([])},[JSON.stringify(c)]);return i.useEffect(()=>{Z()},[JSON.stringify(c)]),i.useEffect(()=>{document.title="User | Assign student"},[]),i.useEffect(()=>{O({...c,searchString:L})},[L]),{handelSort:oe,handleRetrievedData:k,totalItem:n,userList:o,filters:c,changeFilters:O,handleSelectAll:V,handleClickCheck:pe,isCheckAll:$,isCheck:f,fullName:L,selectedUser:u,setSelectedUser:w,userSelected:S,getDataUserList:Z,studentTeacherSelected:K,studentCounselorSelected:A,studentAssistantSelected:Q,studentSecondaryTeacherSelected:re,isStudentSelectionDisabled:y,handleBlockedSchoolLevelSelection:q,schoolLevelConflictMessage:He}},lt=(s,o,r,c,x,n,_,f)=>{const m=Se.useDispatch(),[S,D]=i.useState(!1),[u,w]=i.useState(C.initialStaffBulk),[L,E]=i.useState(!1),[j,I]=i.useState(!1),[O,K]=i.useState(C.TeacherType.Teacher),[A,Q]=i.useState([]),[re,oe]=i.useState([]),[Z,y]=i.useState([]),[$,V]=i.useState({header:"",titleSelect:"",selectPlaceholder:"",changeTitle:"",changePlaceholder:""}),[q,pe]=i.useState(""),[k,v]=i.useState(""),[p,d]=i.useState(!1),[N,F]=i.useState(0),[G,ee]=i.useState([]),[de,J]=i.useState(""),[ae,ne]=i.useState(!1),[ge,he]=i.useState(!1),[H,ue]=i.useState(C.initStaffDeleteBulk),X=h=>{ue({...H,...h})},me=h=>{if(h&&h.length===0){m(t.setAlert({type:"danger",message:"Please select students!"}));return}he(!ge),w({...C.initialStaffBulk}),ue({...C.initStaffDeleteBulk})},ye=()=>{ne(!ae),J("")},je=h=>{G.includes(h)?ee(G.filter(g=>g!==h)):ee([...G,h])},ve=h=>{F(g=>g===h?-1:h)},Ce=h=>{if(h&&h.length===0){m(t.setAlert({type:"danger",message:"Please select students!"}));return}D(!S),w({...C.initialStaffBulk})},we=(h,g,T)=>{if(h&&h.length===0){m(t.setAlert({type:"danger",message:"Please select students!"}));return}switch(y(h),oe(W.extractStaffList(h,g)),K(g),g){case C.TeacherType.Teacher:V({header:"switch_teacher",titleSelect:"current_teacher_name",selectPlaceholder:"select_teacher",changeTitle:"select_teacher_change",changePlaceholder:"select_teacher_change"});break;case C.TeacherType.Assistant:V({header:"switch_assistant",titleSelect:"current_assistant_name",selectPlaceholder:"",changeTitle:"",changePlaceholder:"select_assistant_change"});break;case C.TeacherType.Counselor:V({header:"switch_counselor",titleSelect:"current_counselor_name",selectPlaceholder:"select_counselor",changeTitle:"select_counselor_change",changePlaceholder:"select_counselor_change"});break;case C.TeacherType.SecondaryTeacher:V({header:"switch_support_teacher",titleSelect:"current_assistant_name",selectPlaceholder:"",changeTitle:"",changePlaceholder:"select_support_teacher_change"});break}I(!j),Q(T)},xe=()=>{Q([]),I(!1),d(!1),K(C.TeacherType.Teacher),oe([]),pe(""),v(""),V({header:"",titleSelect:"",selectPlaceholder:"",changeTitle:"",changePlaceholder:""}),ee([])},Le=()=>{d(!1),F(0),ee([])},Ae=async(h,g)=>{m(t.setModal({isOpen:!0,type:"warning",message:`Do you want to change ${g===C.TeacherType.Teacher?"teacher":g===C.TeacherType.Assistant?"assistant":g===C.TeacherType.SecondaryTeacher?"support teacher":"counselor"} for ${h.length} student(s)?`,onConfirm:async()=>{m(t.setLoading(!0));try{const T=g===C.TeacherType.Teacher?await se.changeMultiTeacherOfStudent(h):g===C.TeacherType.Assistant?await se.changeAssistantOfStudents(h):g===C.TeacherType.Counselor?await se.changeMultiCounselorsOfStudent(h):await se.changeSecondaryTeacherOfStudents(h);T&&T?.data&&(xe(),x?.(),await _(),m(t.setAlert({type:"success",message:`Change ${g===C.TeacherType.Teacher?"teacher":g===C.TeacherType.Assistant?"assistant":g===C.TeacherType.SecondaryTeacher?"support teacher":"counselor"} successfully`})))}catch(T){m(t.setAlert({type:"danger",message:T.response?.data?.title||T.message}))}m(t.setLoading(!1))}}))},Me=()=>{let h=[];switch(O){case C.TeacherType.Teacher:h=Z.filter(g=>{const T=g.teachers.map(U=>U.teacherUserId);return T.includes(k)&&!T.includes(q)}).map(g=>({studentId:g.studentId,teacher:k,teacherChange:q}));break;case C.TeacherType.Counselor:h=Z.filter(g=>{const T=g.counselors.map(U=>U.counselorUserId);return T.includes(k)&&!T.includes(q)}).map(g=>({studentId:g.studentId,counselor:k,counselorChange:q}));break;case C.TeacherType.Assistant:h=Z.filter(g=>g?.assistantUserId&&g?.teachers?.length>0).map(g=>({studentId:g.studentId,assistantUserId:q}));break;case C.TeacherType.SecondaryTeacher:h=Z.filter(g=>g?.secondaryTeacherUserId&&g?.teachers?.length>0).map(g=>({studentId:g.studentId,secondaryTeacherId:q}));break}if(h.length===0){m(t.setAlert({type:"danger",message:"No change to update!"}));return}Ae(h||[],O)},Ee=h=>{if(h&&h.length===0){m(t.setAlert({type:"danger",message:"Please select student(s)!"}));return}E(!L)},ke=(h,g)=>{switch(h){case"assistant":w({...u,assistantId:g.value,assistantEmail:g.label});break;case"secondary":w({...u,secondaryTeacherId:g.value,secondaryTeacherEmail:g.label});break;case"grade":w({...u,gradeLevel:g.value});break}},Ue=h=>{w({...u,teacher:h})},Be=h=>{w({...u,counselors:h})},_e=async h=>{m(t.setLoading(!0));try{await se.assignStudentsApi(h),m(t.setAlert({type:"success",message:"Student assigned successfully"})),x?.(),xe()}catch(g){m(t.setAlert({type:"danger",message:g.response?.data?.title||g.message}))}m(t.setLoading(!1))},Oe=i.useCallback(h=>{if(h.length===0){m(t.setAlert({type:"danger",message:"Not found selected student."}));return}if(h.some(U=>{const B=s?.[U],b=o?.[U],z=r?.[U],P=c?.[U];return!B&&!b&&!z&&!P})){m(t.setAlert({type:"danger",message:"Please select/add teacher for all selected student first."}));return}const T=h.map(U=>{const B=s?.[U],b=o?.[U],z=r?.[U],P=c?.[U],Y=f?.find(ie=>ie.id===U),ce={id:U,schoolLevel:Y?.schoolLevel};return B&&(ce.mainTeacherUserId=B?B.map(ie=>ie.value):void 0,ce.mainTeacherEmail=B?B.map(ie=>ie.label):void 0),b&&(ce.assistantUserId=b?.value&&typeof b?.value=="string"?b?.value:void 0,ce.assistantEmail=b?.value&&typeof b?.value=="number"?b?.label:void 0),z&&(ce.counselorUserIds=z?z.map(ie=>ie.value):void 0,ce.counselorEmails=z?z.map(ie=>ie.label):void 0),P&&(ce.secondaryTeacherUserId=P?.value&&typeof P?.value=="string"?P?.value:void 0,ce.secondaryTeacherEmail=P?.value&&typeof P?.value=="number"?P?.label:void 0),ce});_e([...T])},[JSON.stringify(s),JSON.stringify(o),JSON.stringify(r),JSON.stringify(c)]),De=i.useCallback(h=>{const g=s?.[h],T=o?.[h],U=r?.[h],B=c?.[h];if(!g&&!T&&!U&&!B){m(t.setAlert({type:"danger",message:"Please select/add teacher for selected student first."}));return}const b=f?.find(P=>P.id===h),z={id:h,schoolLevel:b?.schoolLevel};g&&(z.mainTeacherUserId=g?g.map(P=>P.value):void 0,z.mainTeacherEmail=g?g.map(P=>P.label):void 0),T&&(z.assistantUserId=T?.value&&typeof T?.value=="string"?T?.value:void 0,z.assistantEmail=T?.value&&typeof T?.value=="number"?T?.label:void 0),U&&(z.counselorUserIds=U?U.map(P=>P.value):void 0,z.counselorEmails=U?U.map(P=>P.label):void 0),B&&(z.secondaryTeacherUserId=B?.value&&typeof B?.value=="string"?B?.value:void 0,z.secondaryTeacherEmail=B?.value&&typeof B?.value=="number"?B?.label:void 0),_e([z])},[JSON.stringify(s),JSON.stringify(o),JSON.stringify(r),JSON.stringify(c)]),Re=async h=>{if(h.length===0){m(t.setAlert({type:"danger",message:"Not found selected student."}));return}if(u.teacher.length===0&&u.counselors.length===0&&!u.assistantId&&!u.secondaryTeacherId){m(t.setAlert({type:"danger",message:"No change to assign!"}));return}const g=f?.filter(T=>h?.includes(T.id))?.every(T=>Array.isArray(T.teachers)&&T.teachers.length>0)??!1;if(u.teacher.length===0&&!g){m(t.setAlert({type:"danger",message:"Please assign a teacher to each student before giving other educators access to them"}));return}m(t.setLoading(!0));try{if(u.teacher.length>0&&f&&f.length>0){const B=f.filter(b=>h.includes(b.id)).map(b=>{const z=b.teachers?.map(Y=>Y.teacherUserId)||[],P=u.teacher.filter(Y=>!z.includes(Y.id));return{id:b.id,schoolLevel:b.schoolLevel,mainTeacherUserId:P.map(Y=>Y.id),mainTeacherEmail:P.map(Y=>Y.email)}}).filter(b=>b.mainTeacherUserId.length>0||b.mainTeacherEmail.length>0);B.length>0&&await se.assignStudentsApi(B)}if(u.counselors.length>0&&f&&f.length>0){const B=f.filter(b=>h.includes(b.id)).map(b=>{const z=b.counselors?.map(Y=>Y.counselorUserId)||[],P=u.counselors.filter(Y=>!z.includes(Y.id));return{id:b.id,schoolLevel:b.schoolLevel,counselorUserIds:P.map(Y=>Y.id),counselorEmails:P.map(Y=>Y.email)}}).filter(b=>b.counselorUserIds.length>0||b.counselorEmails.length>0);B.length>0&&await se.assignStudentsApi(B)}const T=f?.filter(B=>!B.assistantUserId);if(T&&T?.length>0&&u.assistantId){const B=T.map(b=>({id:b.id,schoolLevel:b.schoolLevel,assistantUserId:u.assistantId,assistantEmail:u.assistantEmail}));await se.assignStudentsApi(B.filter(b=>b!==void 0))}const U=f?.filter(B=>!B.secondaryTeacherUserId);if(U&&U?.length>0&&u.secondaryTeacherId){const B=U.map(b=>({id:b.id,schoolLevel:b.schoolLevel,secondaryTeacherUserId:u.secondaryTeacherId,secondaryTeacherEmail:u.secondaryTeacherEmail}));await se.assignStudentsApi(B.filter(b=>b!==void 0))}m(t.setAlert({type:"success",message:"Student assigned successfully"})),x?.(),xe(),Ce()}catch(T){m(t.setAlert({type:"danger",message:T.response?.data?.title||T.message}))}m(t.setLoading(!1))},$e=async h=>{if(u.teacher.length===0){m(t.setAlert({type:"danger",message:"Please select teacher before assign!"}));return}if(G.length>0&&!h){ne(!0);return}const g={id:n?.id||"",schoolLevel:n?.schoolLevel,mainTeacherUserId:u.teacher.filter(T=>!n?.teachers?.some(U=>U.teacherUserId===T.id)).map(T=>T.id)||[],mainTeacherEmail:u.teacher.filter(T=>!n?.teachers?.some(U=>U.teacherUserId===T.id)).map(T=>T.email)||[],assistantUserId:u?.assistantId?u?.assistantId:void 0,assistantEmail:u?.assistantEmail?u?.assistantEmail:void 0,counselorUserIds:u.counselors.map(T=>T.id)||[],counselorEmails:u.counselors.map(T=>T.email)||[],secondaryTeacherUserId:u?.secondaryTeacherId?u?.secondaryTeacherId:void 0,secondaryTeacherEmail:u?.secondaryTeacherEmail?u?.secondaryTeacherEmail:void 0,removeTeacherUserIds:G,teacherSwitchUserId:h||""};u?.gradeLevel&&u.gradeLevel!==n?.gradeLevel&&await se.addGradeToStudent(n?.id||"",u?.gradeLevel,n?.schoolLevel),_e([g])},Fe=async(h,g)=>{m(t.setLoading(!0));try{(await se.updateStatusAll(h)).status==200&&(m(t.setAlert({type:"success",message:`Inactive ${h.length} Students successfully`})),g())}catch(T){m(t.setAlert({type:"danger",message:T.response?.data?.title||T.message}))}E(!L),m(t.setLoading(!1))},Pe=i.useCallback(async h=>{if(H.assistantRemoveUserId.length&&!H.assistantSwitchDataUserId){m(t.setAlert({type:"danger",message:"Please select an assistant to transfer data!"}));return}if(H.teacherRemoveUserIds.length&&!H.teacherSwitchDataUserId){m(t.setAlert({type:"danger",message:"Please select a teacher to transfer data!"}));return}if(H.counselorRemoveUserIds.length&&!H.counselorSwitchDataUserId){m(t.setAlert({type:"danger",message:"Please select a counselor to transfer data!"}));return}if(H.supportTeacherRemoveUserIds.length&&!H.supportTeacherSwitchDataUserId){m(t.setAlert({type:"danger",message:"Please select a support teacher to transfer data!"}));return}m(t.setLoading(!0));try{const g=h?.[0],U=f?.find(B=>B.id===g)?.schoolLevel;await se.removeBulkStaff({...H,studentUserIds:h||[],schoolLevel:U}),x?.(),await _()}catch(g){m(t.setAlert({type:"danger",message:g.response?.data?.title||g.message}))}me(),m(t.setLoading(!1))},[H]);return i.useEffect(()=>(n?.id&&w({teacher:n?.teachers?.map(h=>({id:h.teacherUserId,email:h.mainTeacherEmail})),assistantId:n?.assistantUserId,assistantEmail:n?.assistantEmail,counselors:n?.counselors?.map(h=>({id:h.counselorUserId,email:h.counselorEmail})),secondaryTeacherEmail:n?.secondaryTeacherEmail,secondaryTeacherId:n?.secondaryTeacherUserId,gradeLevel:n?.gradeLevel}),()=>{w(C.initialStaffBulk)}),[n]),{handleAssignSingleStudent:De,handleAssignMultiStudent:Oe,openModelBulk:S,handleToggleModel:Ce,handleChangeStaffBulk:ke,staffBulkAssign:u,onAssignStaffToStudents:Re,handleToggleInactiveModal:Ee,openInactiveModal:L,handleInactiveStudents:Fe,handleChangeTeacherBulk:Ue,handleEditAssignForStudents:$e,handleToggleSwitchModel:we,openSwitchModal:j,optionsSwitch:A,modalType:O,textModal:$,teacherSwitchList:re,onCloseSwitchModal:xe,handleUpdateSwitch:Me,setTeacherChangeUserId:pe,setTeacherSelectForChangeUserId:v,teacherSelectForChangeUserId:k,openDetailModal:p,setOpenDetailModal:d,toggleCollapse:ve,activeIndex:N,handleChangeCounselorBulk:Be,onClose:Le,removeTeacherUserIds:G,onSelectRemoveTeacher:je,openModelSwitchDataTeacher:ae,onToggleModelSwitchDataTeacher:ye,teacherSwitchUserId:de,setTeacherSwitchUserId:J,onToggleModelDeleteBulk:me,openModelDeleteBulk:ge,handelChangeStaffRemove:X,switchStaffUsers:H,handleRemoveBulkStaff:Pe}};function rt(s){return t.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"}}]})(s)}const ot=s=>{const{textModal:o,isOpen:r,teachers:c,options:x,onClose:n,onSave:_,modalType:f,setTeacherChangeUserId:m,setTeacherSelectForChangeUserId:S,teacherSelectForChangeUserId:D}=s,{t:u}=le.useTranslation();return e.jsxs(l.Modal,{centered:!0,isOpen:r,toggle:n,zIndex:1201,children:[e.jsx(l.ModalHeader,{className:t.styles["header-assign-for-student"],children:u(o.header)}),e.jsxs(l.ModalBody,{children:[f!==C.TeacherType.Assistant||f!==C.TeacherType.SecondaryTeacher&&e.jsxs(i.Fragment,{children:[e.jsx("div",{children:u(o.titleSelect)}),e.jsx("ul",{style:{maxHeight:200,overflow:"auto"},children:c.map(w=>e.jsxs("li",{children:[w.name,"-",w.label]},w.label))})]}),(f===C.TeacherType.Teacher||f===C.TeacherType.Counselor)&&e.jsxs(i.Fragment,{children:[e.jsx("div",{children:u(o.selectPlaceholder)}),e.jsx(t.CustomSelector,{options:c,value:c.filter(w=>w.value===D),placeholder:u(o.selectPlaceholder),className:`flex-grow-1 mb-3 ${t.styles["custom-chip-teacher-select"]}`,onChange:w=>{S(w.value)},isClearable:!0,style:{maxWidth:120}})]}),e.jsx("div",{children:u(o.changeTitle)}),e.jsx(ze.TeacherSelector,{options:x,onChange:w=>{f!==C.TeacherType.SecondaryTeacher?m(w.value):m(w.id)},placeholder:u(o.changePlaceholder),className:"flex-grow-1 mb-3"})]}),e.jsxs(l.ModalFooter,{className:"textModal-right",children:[e.jsx(l.Button,{onClick:()=>n(!1),children:u("cancel")}),e.jsx(l.Button,{color:"primary",onClick:()=>{_()},children:u("save")})]})]})},ct=i.forwardRef(ot),it=({openDetailModal:s,onClose:o,selectedUser:r,staffBulkAssign:c,teacherOptions:x,handleChangeTeacherBulk:n,handleChangeCounselorBulk:_,assistantOptions:f,counselorOptions:m,secondaryTeacherOptions:S,handleChangeStaffBulk:D,handleEditAssignForStudents:u,toggleCollapse:w,activeIndex:L})=>{const{t:E}=le.useTranslation(),{getLabel:j,system:I}=t.useGradeLabel(),O=[r?.teachers||[],r?.counselors||[]],K=W.resolveStudentTier(r),A=y=>W.matchesStudentTier(y,K),Q=x.filter(y=>!r.teachers?.some($=>$.teacherUserId===y.value)).filter(A),re=f.filter(A),oe=m.filter(y=>!r.counselors?.some($=>$.counselorUserId===y.value)).filter(A),Z=S.filter(A);return e.jsxs(l.Modal,{centered:!0,isOpen:s,toggle:()=>o(),zIndex:1201,children:[e.jsxs(l.ModalHeader,{className:t.styles["header-assign-for-student"],children:[e.jsxs("div",{children:["Assign student ",r?.fullName]}),e.jsx("div",{children:j(r?.gradeLevel)})]}),e.jsxs(l.ModalBody,{children:[O.map((y,$)=>e.jsxs("div",{children:[e.jsxs("button",{type:"button",className:`btn ${t.styles["btn-collapse"]} ${L===$?"btn-link ":""}`,onClick:()=>w($),children:[E($===0?"current_teacher_name":"current_counselor_name")," ",`(${y.length})`," ",e.jsx("i",{className:`fa fa-angle-${L===$?"up":"down"}`})]}),e.jsx(l.Collapse,{isOpen:L===$,children:e.jsx(l.Card,{children:e.jsx(l.CardBody,{children:y.length>0?y.map(V=>$===0?e.jsxs("li",{children:[V.mainTeacherName," - ",V.mainTeacherEmail]},V.mainTeacherEmail):e.jsxs("li",{children:[V.counselorName," - ",V.counselorEmail]},V.counselorUserId)):e.jsx("div",{children:E("no_data")})})})})]},$)),e.jsx("div",{children:E("teacher_email")}),e.jsx(t.CustomSelector,{isMulti:!0,value:c.teacher.filter(y=>!r.teachers?.some($=>$.teacherUserId===y.id)).map(y=>({label:y.email,value:y.id})),options:Q,placeholder:E("select_teacher"),className:`flex-grow-1 mb-3 ${t.styles["custom-chip-teacher-select"]}`,onChange:y=>{const $=y.map(V=>({id:V.value,email:V.label}));n($)},isClearable:!0,style:{maxWidth:120}}),e.jsx("div",{children:E("assistant_email")}),e.jsx(ze.TeacherSelector,{value:f.find(y=>y.value==c.assistantId||y.label==c.assistantEmail)||null,options:re,onChange:y=>{D("assistant",y)},placeholder:E("select_assistant"),className:"flex-grow-1 mb-3"}),e.jsx("div",{children:E("counselor_email")}),e.jsx(t.CustomSelector,{isMulti:!0,value:c.counselors.filter(y=>!r.counselors?.some($=>$.counselorUserId===y.id)).map(y=>({label:y.email,value:y.id})),options:oe,placeholder:E("select_counselor"),className:`flex-grow-1 mb-3 ${t.styles["custom-chip-teacher-select"]}`,onChange:y=>{const $=y.map(V=>({id:V.value,email:V.label}));_($)},isClearable:!0,style:{maxWidth:120}}),e.jsx("div",{children:E("support_teacher_email")}),e.jsx(ze.TeacherSelector,{value:S.find(y=>y.value==c.secondaryTeacherId||y.label==c.secondaryTeacherEmail)||null,options:Z,onChange:y=>{D("secondary",y)},placeholder:E("select_support_teacher"),className:"flex-grow-1"}),e.jsx("div",{children:I==="UK"?"Year":E("grade")}),e.jsx(Xe,{value:C.GRADE_DEFAULT.filter(y=>y.schoolLevel===K).map(y=>({...y,label:j(y.value)})).find(y=>y.value===c.gradeLevel)||null,options:C.GRADE_DEFAULT.filter(y=>y.schoolLevel===K).map(y=>({...y,label:j(y.value)})),placeholder:I==="UK"?"Select year":E("select_grade"),className:"flex-grow-1 mb-3",onChange:y=>{D("grade",y)},styles:{container:y=>({...y,maxWidth:120})}})]}),e.jsxs(l.ModalFooter,{className:"text-right",children:[e.jsx(l.Button,{onClick:()=>o(),children:E("cancel")}),e.jsx(l.Button,{color:"primary",onClick:()=>{u()},children:E("save")})]})]})},dt=({open:s,onClose:o,teachers:r,onConfirm:c,teacherSwitchUserId:x,setTeacherSwitchUserId:n})=>{const{t:_}=le.useTranslation();return e.jsxs(l.Modal,{centered:!0,isOpen:s,toggle:()=>o(),zIndex:1201,children:[e.jsx(l.ModalHeader,{className:t.styles["header-assign-for-student"],children:e.jsx("div",{children:"Select teacher switch data"})}),e.jsx(l.ModalBody,{className:"p-0",children:e.jsx("div",{className:t.styles["switch-data-teachers"],children:r.map(f=>e.jsx("p",{onClick:()=>n(f.teacherUserId),className:`${t.styles["switch-data-teacher-item"]} ${f.teacherUserId==x?t.styles["item-checked"]:""}`,children:f.mainTeacherName}))})}),e.jsxs(l.ModalFooter,{className:"text-right",children:[e.jsx(l.Button,{onClick:()=>o(),children:_("cancel")}),e.jsx(l.Button,{disabled:!x,color:"primary",onClick:async()=>{await c(x),o()},children:_("save")})]})]})},ut=({teachers:s,onChangeStaffRemove:o,switchStaffUsers:r,teacherOptions:c})=>{const{t:x}=le.useTranslation();return e.jsxs("div",{children:[e.jsx("h6",{children:"Select teacher to remove"}),e.jsx(t.CustomSelector,{isMulti:!0,value:s.filter(n=>r.teacherRemoveUserIds.includes(n.value))||[],options:s.filter(n=>!r.teacherRemoveUserIds.includes(n.value)&&n.value!==r.teacherSwitchDataUserId)||[],placeholder:x("select_teacher"),className:`flex-grow-1 mb-3 ${t.styles["custom-chip-teacher-select"]}`,onChange:n=>{o({teacherRemoveUserIds:n.map(_=>_.value)})},isClearable:!0}),e.jsx("h6",{className:"mt-3",children:"Select the teacher to transfer data to"}),e.jsx(t.CustomSelector,{value:c.find(n=>r.teacherSwitchDataUserId==n.value)||null,options:c.filter(n=>!r.teacherRemoveUserIds.includes(n.value)&&n.value!==r.teacherSwitchDataUserId)||[],placeholder:x("select_teacher"),className:`flex-grow-1 mb-3 ${t.styles["custom-chip-teacher-select"]}`,onChange:n=>{console.log("value",n),o({teacherSwitchDataUserId:n?.value})},isClearable:!0})]})},ht=({counselors:s,onChangeStaffRemove:o,switchStaffUsers:r,counselorOptions:c})=>{const{t:x}=le.useTranslation();return e.jsxs("div",{children:[e.jsx("h6",{children:"Select counselor to remove"}),e.jsx(t.CustomSelector,{isMulti:!0,value:s.filter(n=>r.counselorRemoveUserIds.includes(n.value))||[],options:s.filter(n=>!r.counselorRemoveUserIds.includes(n.value)&&n.value!==r.counselorSwitchDataUserId)||[],placeholder:x("select_counselor"),className:`flex-grow-1 mb-3 ${t.styles["custom-chip-teacher-select"]}`,onChange:n=>{o({counselorRemoveUserIds:n.map(_=>_.value)})},isClearable:!0}),e.jsx("h6",{className:"mt-3",children:"Select the counselor to transfer data to"}),e.jsx(t.CustomSelector,{value:c.find(n=>r.counselorSwitchDataUserId==n.value)||null,options:c.filter(n=>!r.counselorRemoveUserIds.includes(n.value)&&n.value!==r.counselorSwitchDataUserId)||[],placeholder:x("select_counselor"),className:`flex-grow-1 mb-3 ${t.styles["custom-chip-counselor-select"]}`,onChange:n=>{o({counselorSwitchDataUserId:n?.value})},isClearable:!0})]})},mt=({tabs:s})=>{const{t:o}=le.useTranslation(),[r,c]=i.useState(0),x=_=>{c(_)},n=()=>e.jsx(l.Row,{children:e.jsxs(l.Col,{xl:12,children:[e.jsx(l.Nav,{tabs:!0,children:s.map((_,f)=>{const m=f===r;return e.jsx(l.NavItem,{children:e.jsx(l.NavLink,{className:`${m?"active":""} cursor-pointer`,onClick:()=>x(f),style:{color:m?"#316CD9":"#242424"},children:o(_.title)})},f)})}),e.jsx(l.TabContent,{activeTab:r,className:"border-bottom-0 border-left-0 border-right-0 p-3",children:s.map((_,f)=>e.jsx(l.TabPane,{tabId:f,children:e.jsx(_.component,{})},f))})]})});return e.jsx("div",{className:"animated fadeIn",children:n()})},pt=({assistants:s,onChangeStaffRemove:o,switchStaffUsers:r,assistantOptions:c})=>{const{t:x}=le.useTranslation();return e.jsxs("div",{children:[e.jsx("h6",{children:"Select assistant to remove"}),e.jsx(t.CustomSelector,{isMulti:!0,value:s.filter(n=>r.assistantRemoveUserId.includes(n.value))||[],options:s.filter(n=>!r.assistantRemoveUserId.includes(n.value)&&n.value!==r.assistantSwitchDataUserId)||[],placeholder:x("select_assistant"),className:`flex-grow-1 mb-3 ${t.styles["custom-chip-teacher-select"]}`,onChange:n=>{o({assistantRemoveUserId:n.map(_=>_.value)})},isClearable:!0}),e.jsx("h6",{className:"mt-3",children:"Select the assistant to transfer data to"}),e.jsx(t.CustomSelector,{value:c.find(n=>r.assistantSwitchDataUserId==n.value)||null,options:c.filter(n=>!r.assistantRemoveUserId.includes(n.value)&&n.value!==r.assistantSwitchDataUserId)||[],placeholder:x("select_assistant"),className:`flex-grow-1 mb-3 ${t.styles["custom-chip-assistant-select"]}`,onChange:n=>{console.log("value",n),o({assistantSwitchDataUserId:n?.value})},isClearable:!0})]})},gt=({secondaryTeachers:s,onChangeStaffRemove:o,switchStaffUsers:r,secondaryTeacherOptions:c})=>{const{t:x}=le.useTranslation();return e.jsxs("div",{children:[e.jsx("h6",{children:"Select support teacher to remove"}),e.jsx(t.CustomSelector,{isMulti:!0,value:s.filter(n=>r.supportTeacherRemoveUserIds.includes(n.value))||[],options:s.filter(n=>!r.supportTeacherRemoveUserIds.includes(n.value)&&n.value!==r.supportTeacherSwitchDataUserId)||[],placeholder:x("select_support_teacher"),className:`flex-grow-1 mb-3 ${t.styles["custom-chip-teacher-select"]}`,onChange:n=>{o({supportTeacherRemoveUserIds:n.map(_=>_.value)})},isClearable:!0}),e.jsx("h6",{className:"mt-3",children:"Select the support teacher to transfer data to"}),e.jsx(t.CustomSelector,{value:c.find(n=>r.supportTeacherSwitchDataUserId==n.value)||null,options:c.filter(n=>!r.supportTeacherRemoveUserIds.includes(n.value)&&n.value!==r.supportTeacherSwitchDataUserId)||[],placeholder:x("select_support_teacher"),className:`flex-grow-1 mb-3 ${t.styles["custom-chip-teacher-select"]}`,onChange:n=>{o({supportTeacherSwitchDataUserId:n?.value})},isClearable:!0})]})},ft=({open:s,onClose:o,teachers:r,onChangeStaffRemove:c,switchStaffUsers:x,assistants:n,onRemoveBulkStaff:_,counselors:f,studentUserIds:m,secondaryTeachers:S,teacherOptions:D,assistantOptions:u,counselorOptions:w,secondaryTeacherOptions:L})=>{const{t:E}=le.useTranslation(),j=[{title:"Remove Teacher",component:()=>e.jsx(ut,{teachers:r,onChangeStaffRemove:c,switchStaffUsers:x,teacherOptions:D})},{title:"Remove Assistant",component:()=>e.jsx(pt,{assistants:n,onChangeStaffRemove:c,switchStaffUsers:x,assistantOptions:u})},{title:"Remove Counselor",component:()=>e.jsx(ht,{counselors:f,onChangeStaffRemove:c,switchStaffUsers:x,counselorOptions:w})},{title:"Remove Support Teacher",component:()=>e.jsx(gt,{secondaryTeachers:S,onChangeStaffRemove:c,switchStaffUsers:x,secondaryTeacherOptions:L})}];return e.jsxs(l.Modal,{size:"lg",centered:!0,isOpen:s,toggle:()=>o(),zIndex:1201,children:[e.jsx(l.ModalHeader,{className:`${t.styles["header-assign-for-student"]} border-0`,children:e.jsx("div",{children:"Remove Bulk"})}),e.jsx(l.ModalBody,{className:"p-0",children:e.jsx(mt,{tabs:j})}),e.jsxs(l.ModalFooter,{className:"text-right",children:[e.jsx(l.Button,{onClick:()=>o(),children:E("cancel")}),e.jsx(l.Button,{disabled:!x.teacherRemoveUserIds.length&&!x.assistantRemoveUserId&&!x.counselorRemoveUserIds.length,color:"primary",onClick:async()=>{await _(m)},children:"Remove"})]})]})},yt=()=>{const{t:s}=le.useTranslation(),{getLabel:o,system:r}=t.useGradeLabel(),[c,x]=i.useState(),[n,_]=i.useState(),[f,m]=i.useState(),[S,D]=i.useState(),[u,w]=i.useState([]),[L,E]=i.useState([]),[j,I]=i.useState([]),[O,K]=i.useState([]);i.useEffect(()=>{se.getEducatorsOptionsApi().then(a=>{a.data&&(w(a.data.teachers||[]),E(a.data.assistants||[]),I(a.data.counselors||[]),K(a.data.secondaryTeachers||[]))}).catch(a=>{console.error("Failed to load educators options",a)})},[]);const{isCheck:A,userList:Q,filters:re,totalItem:oe,handleClickCheck:Z,changeFilters:y,fullName:$,handleRetrievedData:V,selectedUser:q,setSelectedUser:pe,getDataUserList:k,userSelected:v,studentTeacherSelected:p,studentCounselorSelected:d,studentAssistantSelected:N,studentSecondaryTeacherSelected:F,isStudentSelectionDisabled:G,handleBlockedSchoolLevelSelection:ee,schoolLevelConflictMessage:de,handleSelectAll:J,isCheckAll:ae}=nt(),ne=()=>{V(),x(void 0),_(void 0),m(void 0),D(void 0)},{openModelBulk:ge,handleToggleModel:he,staffBulkAssign:H,handleChangeStaffBulk:ue,onAssignStaffToStudents:X,handleToggleInactiveModal:me,openInactiveModal:ye,handleInactiveStudents:je,handleChangeTeacherBulk:ve,handleChangeCounselorBulk:Ce,handleEditAssignForStudents:we,modalType:xe,openSwitchModal:Le,optionsSwitch:Ae,textModal:Me,teacherSwitchList:Ee,onCloseSwitchModal:ke,handleUpdateSwitch:Ue,setTeacherChangeUserId:Be,setTeacherSelectForChangeUserId:_e,teacherSelectForChangeUserId:Oe,openDetailModal:De,setOpenDetailModal:Re,toggleCollapse:$e,activeIndex:Fe,onClose:Pe,removeTeacherUserIds:h,openModelSwitchDataTeacher:g,onToggleModelSwitchDataTeacher:T,teacherSwitchUserId:U,setTeacherSwitchUserId:B,onToggleModelDeleteBulk:b,openModelDeleteBulk:z,handelChangeStaffRemove:P,switchStaffUsers:Y,handleRemoveBulkStaff:ce}=lt(c,n,f,S,ne,q,k,v),ie=[{name:"",isCenter:!0,onSelectAll:J,isCheckAll:ae,className:`align-top ${t.styles["fixed-width-40"]}`},{name:"student_name",isCenter:!0,sortBy:C.UserOrder.Name,className:`align-top ${t.styles["fixed-width"]}`},{name:r==="UK"?"Year":"grade",isCenter:!0,sortBy:C.UserOrder.Grade,searchBy:C.SearchBy.Grade,className:`align-center justify-center ${t.styles["fixed-width-120"]}`,getOption:a=>({label:a?o(a):"empty",value:a})},{name:"teacher_emails",isCenter:!0,className:"align-center justify-center",sortBy:C.UserOrder.Teacher,searchBy:C.SearchBy.Teacher,getOption:a=>({label:a||"empty",value:a})},{name:"assistant_email",isCenter:!0,className:"align-center justify-center",sortBy:C.UserOrder.Assistant,searchBy:C.SearchBy.Assistant,getOption:a=>({label:a||"empty",value:a})},{name:"counselor_emails",isCenter:!0,className:"align-center justify-center",sortBy:C.UserOrder.Counselor,searchBy:C.SearchBy.Counselor,getOption:a=>({label:a||"empty",value:a})},{name:"support_teacher_email",isCenter:!0,className:"align-center justify-center",sortBy:C.UserOrder.SecondaryTeacher,searchBy:C.SearchBy.SecondaryTeacher,getOption:a=>({label:a||"empty",value:a})}],[fe,Qe]=i.useState(null),te=a=>{Qe(M=>M===a?null:a)};return e.jsxs("div",{className:"fadeIn animated",children:[e.jsx("h5",{className:"mt-4 mb-2",children:s("assign_student")}),e.jsxs(l.Row,{className:"my-2",children:[e.jsx(l.Col,{md:3,children:e.jsx(t.SearchBox,{initValue:re?.searchString||"",onSearch:a=>y({searchString:a}),placeholder:s("type_something_to_search_students")})}),e.jsx(l.Col,{md:8,className:"d-flex justify-content-end align-items-center",children:e.jsx(l.Row,{className:"mb-2",children:e.jsxs(l.Col,{style:{display:"flex",alignItems:"center",flexWrap:"wrap",gap:4},children:[e.jsx(l.Button,{onClick:()=>he(A),color:"primary",style:{background:"#316cd9"},children:s("assign_bulk")}),e.jsx(l.Button,{onClick:()=>b(A),color:"primary",style:{background:"#316cd9"},children:s("delete_bulk")}),e.jsx(l.Button,{onClick:()=>me(A),color:"primary",style:{background:"#316cd9"},children:s("inactive_students")})]})})}),e.jsxs(l.Col,{md:1,className:"d-flex justify-content-end align-items-center",style:{whiteSpace:"nowrap",flexWrap:"nowrap"},children:[s("total_of_users"),": ",oe]})]}),e.jsxs(l.Modal,{centered:!0,isOpen:ge,toggle:()=>he(),zIndex:1201,children:[e.jsx(l.ModalHeader,{children:s("assign_bulk_student")}),e.jsxs(l.ModalBody,{children:[e.jsx(t.CustomSelector,{isMulti:!0,value:H.teacher.map(a=>({label:a.email,value:a.id})),options:W.filterOptionsBySchoolLevel(u,A,v),placeholder:s("select_teacher"),className:`flex-grow-1 mb-3 ${t.styles["custom-chip-teacher-select"]}`,onChange:a=>{const M=a.map(R=>({id:R.value,email:R.label}));ve(M)},isClearable:!0,style:{maxWidth:120}}),e.jsx(t.CustomSelector,{value:L.find(a=>a.value==H.assistantId||a.label==H.assistantEmail)||null,options:W.filterOptionsBySchoolLevel(L,A,v),onChange:a=>ue("assistant",a),placeholder:s("select_assistant"),className:"flex-grow-1 mb-3"}),e.jsx(t.CustomSelector,{isMulti:!0,value:H.counselors.map(a=>({label:a.email,value:a.id})),options:W.filterOptionsBySchoolLevel(j,A,v),placeholder:s("select_counselor"),className:`flex-grow-1 mb-3 ${t.styles["custom-chip-teacher-select"]}`,onChange:a=>{const M=a.map(R=>({id:R.value,email:R.label,schoolLevel:R.schoolLevel}));Ce(M)},isClearable:!0,style:{maxWidth:120}}),e.jsx(t.CustomSelector,{value:O.find(a=>a.value==H.secondaryTeacherId||a.label==H.secondaryTeacherEmail)||null,options:W.filterOptionsBySchoolLevel(O,A,v),onChange:a=>ue("secondary",a),placeholder:s("select_support_teacher"),className:"flex-grow-1"})]}),e.jsxs(l.ModalFooter,{className:"text-right",children:[e.jsx(l.Button,{onClick:()=>he(),children:s("cancel")}),e.jsx(l.Button,{color:"primary",onClick:()=>X(A),children:s("assign")})]})]}),e.jsxs(l.Modal,{centered:!0,isOpen:ye,toggle:()=>me(),zIndex:1201,children:[e.jsx(l.ModalHeader,{children:s("inactive_students")}),e.jsxs(l.ModalBody,{style:{display:"flex",gap:12},children:[e.jsx(rt,{color:"red",size:30}),e.jsx(l.CardText,{style:{fontSize:20,margin:0,display:"flex",alignItems:"center"},children:s("are_you_sure_you_want_to_inactive_students",{number:A.length})})]}),e.jsxs(l.ModalFooter,{className:"text-right",children:[e.jsx(l.Button,{onClick:()=>me(),children:s("cancel")}),e.jsx(l.Button,{color:"primary",onClick:()=>je(A,ne),children:s("confirm")})]})]}),e.jsxs(l.Row,{className:"my-2",children:[e.jsx(l.Col,{md:12,children:e.jsx("div",{children:e.jsxs(l.Table,{bordered:!0,hover:!0,striped:!0,size:"sm",className:`${t.styles["table-fixed"]}`,children:[e.jsx("thead",{children:e.jsx(W.TableHeader,{headers:ie,filters:re,fullName:$,onChangeFilters:y,teacherOptions:u,assistantOptions:L,counselorOptions:j,secondaryTeacherOptions:O})}),Q&&Q.length>0?e.jsx("tbody",{children:Q.map((a,M)=>e.jsxs("tr",{children:[e.jsx("td",{className:`align-middle text-center ${t.styles["fixed-width-40"]}`,children:(()=>{const R=G(a),Ie=`student_checkbox_${a.id}_${M}`;return e.jsxs("span",{id:Ie,onClick:()=>{R&&ee()},onMouseEnter:()=>{R&&te(Ie)},onMouseLeave:()=>{R&&te(Ie)},style:{display:"inline-block"},children:[e.jsx("input",{id:a.id,type:"checkbox",onChange:Z,checked:A.includes(a.id),disabled:R,style:{pointerEvents:R?"none":void 0}}),R&&e.jsx(l.Tooltip,{placement:"right",isOpen:fe===Ie,target:Ie,children:de})]})})()}),e.jsxs("td",{className:`align-middle ${t.styles["fixed-width"]}`,id:`student_name_${a.id}_${M}`,onMouseEnter:()=>te(`student_name_${a.id}_${M}`),onMouseLeave:()=>te(`student_name_${a.id}_${M}`),children:[e.jsx("button",{type:"button",className:`${t.styles["button-user-name"]} btn-link`,onClick:()=>{pe(a),Re(!0)},children:a.fullName}),e.jsx(l.Tooltip,{placement:"top",isOpen:fe===`student_name_${a.id}_${M}`,target:`student_name_${a.id}_${M}`,children:a.fullName})]}),e.jsxs("td",{className:`align-middle text-center ${t.styles["fixed-width-120"]}`,id:`student_grade_${a.id}_${M}`,onMouseEnter:()=>te(`student_grade_${a.id}_${M}`),onMouseLeave:()=>te(`student_grade_${a.id}_${M}`),children:[e.jsx("p",{className:"mb-0",children:o(a.gradeLevel)}),!!o(a.gradeLevel)&&e.jsx(l.Tooltip,{placement:"top",isOpen:fe===`student_grade_${a.id}_${M}`,target:`student_grade_${a.id}_${M}`,children:o(a.gradeLevel)})]}),e.jsxs("td",{className:`align-middle ${t.styles["equal-width"]}`,id:`student_teacher_${a.id}_${M}`,onMouseEnter:()=>te(`student_teacher_${a.id}_${M}`),onMouseLeave:()=>te(`student_teacher_${a.id}_${M}`),children:[!!a.teachers&&a.teachers.length>0&&e.jsx(i.Fragment,{children:a.teachers.map(R=>e.jsxs("p",{className:"mb-0",children:[R.mainTeacherName," - ",R.mainTeacherEmail]},R.mainTeacherEmail))}),!!a.teachers&&a.teachers.length>0&&e.jsx(l.Tooltip,{placement:"top",isOpen:fe===`student_teacher_${a.id}_${M}`,target:`student_teacher_${a.id}_${M}`,children:a.teachers.map(R=>e.jsxs("p",{className:"mb-0",children:[R.mainTeacherName," - ",R.mainTeacherEmail]},R.mainTeacherEmail))})]}),e.jsxs("td",{className:`align-middle ${t.styles["equal-width"]}`,id:`student_assistant_${a.id}_${M}`,onMouseEnter:()=>te(`student_assistant_${a.id}_${M}`),onMouseLeave:()=>te(`student_assistant_${a.id}_${M}`),children:[!!a.assistantEmail&&e.jsxs("p",{className:"mb-0",children:[a.assistantName," - ",a.assistantEmail]}),!!a.assistantEmail&&e.jsxs(l.Tooltip,{placement:"top",isOpen:fe===`student_assistant_${a.id}_${M}`,target:`student_assistant_${a.id}_${M}`,children:[a.assistantName,"-",a.assistantEmail]})]}),e.jsxs("td",{className:`align-middle ${t.styles["equal-width"]}`,id:`student_counselor_${a.id}_${M}`,onMouseEnter:()=>te(`student_counselor_${a.id}_${M}`),onMouseLeave:()=>te(`student_counselor_${a.id}_${M}`),children:[!!a.counselors&&a.counselors.length>0&&e.jsx(i.Fragment,{children:a.counselors.map(R=>e.jsxs("p",{className:"mb-0",children:[R.counselorName," - ",R.counselorEmail]},R.counselorUserId))}),!!a.counselors&&a.counselors.length>0&&e.jsx(l.Tooltip,{placement:"top",isOpen:fe===`student_counselor_${a.id}_${M}`,target:`student_counselor_${a.id}_${M}`,children:a.counselors.map(R=>e.jsxs("p",{className:"mb-0",children:[R.counselorName," - ",R.counselorEmail]},R.counselorUserId))})]}),e.jsxs("td",{className:`align-middle ${t.styles["equal-width"]}`,id:`student_secondary_teacher_${a.id}_${M}`,onMouseEnter:()=>te(`student_secondary_teacher_${a.id}_${M}`),onMouseLeave:()=>te(`student_secondary_teacher_${a.id}_${M}`),children:[!!a.secondaryTeacherEmail&&e.jsxs("p",{className:"mb-0",children:[a.secondaryTeacherName," - ",a.secondaryTeacherEmail]}),!!a.secondaryTeacherEmail&&e.jsxs(l.Tooltip,{placement:"top",isOpen:fe===`student_secondary_teacher_${a.id}_${M}`,target:`student_secondary_teacher_${a.id}_${M}`,children:[a.secondaryTeacherName," - ",a.secondaryTeacherEmail]})]})]},`${a.id}_${M}`))}):e.jsx("div",{style:{width:"max-content",padding:20},children:s("no_data")})]})})}),e.jsx(l.Col,{md:12,children:e.jsx(t.CustomPagination,{filters:re,totalRecordCount:oe,changePageSize:a=>y({pageSize:a}),changePage:a=>y({currentPage:a})})})]}),e.jsx(it,{openDetailModal:De,onClose:Pe,selectedUser:q,staffBulkAssign:H,teacherOptions:W.filterOptionsBySchoolLevel(u,[q?.id],[q]),handleChangeTeacherBulk:ve,handleChangeCounselorBulk:Ce,assistantOptions:W.filterOptionsBySchoolLevel(L,[q?.id],[q]),counselorOptions:W.filterOptionsBySchoolLevel(j,[q?.id],[q]),secondaryTeacherOptions:W.filterOptionsBySchoolLevel(O,[q?.id],[q]),handleChangeStaffBulk:ue,handleEditAssignForStudents:we,toggleCollapse:$e,activeIndex:Fe}),e.jsx(ct,{textModal:Me,isOpen:Le,teachers:Ee,options:Ae,onClose:ke,onSave:Ue,modalType:xe,setTeacherChangeUserId:Be,setTeacherSelectForChangeUserId:_e,teacherSelectForChangeUserId:Oe}),e.jsx(dt,{open:g,onClose:T,teachers:q?.teachers?.filter(a=>!h.includes(a.teacherUserId))||[],onConfirm:we,teacherSwitchUserId:U,setTeacherSwitchUserId:B}),e.jsx(ft,{open:z,onClose:b,teachers:p,onChangeStaffRemove:P,switchStaffUsers:Y,counselors:d,assistants:N,onRemoveBulkStaff:ce,studentUserIds:A,secondaryTeachers:F,teacherOptions:W.filterOptionsBySchoolLevel(u,A,v),assistantOptions:W.filterOptionsBySchoolLevel(L,A,v),counselorOptions:W.filterOptionsBySchoolLevel(j,A,v),secondaryTeacherOptions:W.filterOptionsBySchoolLevel(O,A,v)})]})},vt=()=>{const s=Se.useDispatch(),[o,r]=i.useState(C.initialUserChoice),[c,x]=i.useState([]),[n,_]=i.useState(""),f=async()=>{try{const S=await t.getTeacher();x(S.data)}catch(S){s(t.setAlert({type:"danger",message:S.response?.data?.title||S.message}))}},m=c.map(S=>({label:`${S.name} - ${S.email}`,value:S.id}));return i.useEffect(()=>{o.roles?.includes("Teacher")&&f()},[o]),{userChoiced:o,setUserChoiced:r,teacherList:c,options:m,setTeacherChangeId:_,teacherChangeId:n}},xt="User deleted list",Tt=()=>{const{userChoiced:s,setUserChoiced:o,options:r,teacherChangeId:c,setTeacherChangeId:x}=vt(),[n,_]=i.useState([]),[f,m]=i.useState(0),{filters:S,changeFilters:D}=t.useFilters(),u=Se.useDispatch(),w=i.useRef(null),L=()=>{w&&w.current&&w.current.toggle()},E=()=>{x(""),o(C.initialUserChoice)},j=i.useCallback(async()=>{u(t.setLoading(!0));try{const O=await t.get(S),{items:K,totalItems:A}=O.data;_(K),m(A)}catch(O){u(t.setAlert({type:"danger",message:O.response?.data?.title||O.message}))}u(t.setLoading(!1))},[u,S]);i.useEffect(()=>{document.title=xt},[]),i.useEffect(()=>{j()},[S]);const I=i.useCallback(O=>{u(t.setModal({isOpen:!0,type:"warning",message:"Do you want to remove this user?",onConfirm:async()=>{u(t.setLoading(!0));try{s.roles.includes("Teacher")?await t.remove(O,c):await t.remove(O),u(t.setAlert({type:"success",message:"Remove user successfully"})),L(),E(),D({currentPage:1})}catch(K){u(t.setAlert({type:"danger",message:K.response?.data?.title||K.message}))}u(t.setLoading(!1))}}))},[S,c,s]);return{userList:n,totalItems:f,filters:S,getData:j,removeData:I,changeFilters:D,modal:w,openModal:L,userChoiced:s,setUserChoiced:o,options:r,teacherChangeId:c,setTeacherChangeId:x,resetData:E}},St=(s,o)=>{const{header:r,removeData:c,resetData:x,userChoiced:n,options:_,teacherChangeId:f,setTeacherChangeId:m}=s,{t:S}=le.useTranslation(),D=()=>{var u=window.location.origin+"/api/ExportDataUser/"+n.id;window.open(u)};return e.jsx(t.CommonModal,{header:r,ref:o,onCancel:()=>{x()},children:e.jsx(l.Row,{children:e.jsxs(l.Col,{md:12,className:"mb-2",children:[e.jsx("p",{children:S("export_user_data")}),e.jsx("div",{className:"pb-3",children:e.jsx(l.Button,{color:"success",onClick:()=>{D()},style:{color:"#fff"},children:S("download_users_data")})}),e.jsx("p",{children:"Delete user"}),!!n&&e.jsxs("div",{children:[n.roles.includes("Student")&&e.jsxs("div",{children:[e.jsx(l.Alert,{color:"danger",children:S("alert_delete_user")}),e.jsx(l.Button,{color:"danger",onClick:()=>c(n.id),style:{color:"#fff"},children:S("delete_user")})]}),n.roles.includes("Admin")&&e.jsxs("div",{children:[e.jsx(l.Alert,{color:"danger",children:S("alert_delete_user")}),e.jsx(l.Button,{color:"danger",onClick:()=>c(n.id),children:S("delete_user")})]}),n.roles.includes("Teacher")&&e.jsxs("div",{children:[e.jsx(l.Alert,{color:"warning",children:S("alert_delete_user")}),e.jsx(t.CustomSelector,{options:_,defaultValue:f,placeholder:"select_teacher_change",onChange:u=>m(u.value)}),!!f&&e.jsxs("div",{className:"mt-2",children:[e.jsx(l.Alert,{color:"danger",children:S("alert_delete_user")}),e.jsx(l.Button,{color:"danger",onClick:()=>c(n.id),children:S("delete_user")})]})]}),(n.roles.includes("Parent")||n.roles.includes("Counselor")||n.roles.includes("SecondaryTeacher"))&&e.jsxs("div",{children:[e.jsx(l.Alert,{color:"danger",children:S("alert_delete_user")}),e.jsx(l.Button,{color:"danger",onClick:()=>c(n.id),children:S("delete_user")})]})]})]})})})},jt=i.forwardRef(St),Ct="user_deleted",_t=()=>{const{userList:s,totalItems:o,filters:r,changeFilters:c,removeData:x,openModal:n,modal:_,userChoiced:f,setUserChoiced:m,options:S,teacherChangeId:D,setTeacherChangeId:u,resetData:w}=Tt(),{t:L}=le.useTranslation(),E=j=>{j&&m(j),n()};return e.jsxs("div",{className:"fadeIn animated",children:[e.jsx("h5",{className:"mt-4 mb-2",children:L(Ct)}),e.jsxs(l.Row,{className:"my-2",children:[e.jsx(l.Col,{md:8,children:e.jsx(t.SearchBox,{initValue:r.searchString,onSearch:j=>c({searchString:j}),placeholder:L("type_something_to_search_reflection_result")})}),e.jsxs(l.Col,{md:4,className:"d-flex justify-content-end align-items-center",children:[L("total_of_users"),": ",o]})]}),e.jsxs(l.Row,{className:"mb-2",children:[e.jsx(l.Col,{md:12,children:s&&s.length>0?e.jsx("div",{children:e.jsxs(l.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:L("name")}),e.jsx("th",{className:"align-top",children:L("email")}),e.jsx("th",{className:"align-top",children:L("role")})]})}),e.jsx("tbody",{children:s.map(j=>e.jsxs("tr",{children:[e.jsx("td",{className:"align-middle",children:e.jsx(t.LinkEditButton,{label:`${j.fullName}`,onClick:()=>E(j)})}),e.jsx("td",{className:"align-middle",children:j.email}),e.jsx("td",{className:"align-middle",children:!!j.roles&&j.roles.map(I=>I==="SecondaryTeacher"?"SupportTeacher":I).join(", ")})]},j.id))})]})}):e.jsx(t.EmptyDataAlert,{label:L("user")})}),e.jsx(l.Col,{md:12,children:e.jsx(t.CustomPagination,{filters:r,totalRecordCount:o,changePageSize:j=>c({pageSize:j}),changePage:j=>c({currentPage:j})})})]}),e.jsx(jt,{ref:_,header:f.fullName,onCancel:()=>{},userChoiced:f,removeData:x,options:S,teacherChangeId:D,setTeacherChangeId:u,resetData:w})]})},It={padding:"4px 8px",marginBottom:0,borderRadius:"4px",color:"#fff",fontWeight:500,fontSize:"14px",height:"56px",justifyContent:"center"},Ne=({htmlFor:s,isDisabled:o,text:r,backgroundColor:c,onClick:x,isClassReflection:n})=>e.jsxs(l.Label,{htmlFor:s,role:"button",tabIndex:0,className:`d-flex align-items-center justfy-content-center mr-2
|
|
2
|
+
${n?"w-25":""}
|
|
3
|
+
${o?"":"cursor-pointer hover-opacity"}`,style:{...It,backgroundColor:c,opacity:o?.5:1,gap:"8px"},onClick:_=>x(),children:[e.jsx("i",{className:"fa fa-paperclip mr-1","aria-hidden":"true"}),r]}),Ke=`${t.BASE_URL}/api/ImportCsv/csv`,Ve=`${t.BASE_URL}/api/Teacher`,bt=(s,o)=>t.apiUpload.post(`${Ke}/${o}`,s),Je=s=>t.apiUpload.post(`${Ke}/importClassReflection`,s),wt=(s,o)=>t.apiUpload.post(`${Ve}/adminImportStudentByTeacherId/${s}`,o),Nt=s=>t.api.post(`${Ve}/adminImportChunkUser`,s),Lt=(s=!0)=>t.api.get(`${Ve}/download-template-file-user?hasEsSchool=${s}`);var Ye=(s=>(s.Students="students",s.Subjects="subjects",s.Grades="grades",s.Attendances="attendances",s.ClassReflection="classReflection",s.Others="others",s.AllUser="allUser",s))(Ye||{});const At=[{text:"import_users",backgroundColor:"#0abde3",type:"allUser"}],Mt=[{text:"import_class_reflection",backgroundColor:"#e74c3c",type:"classReflection"}],Et="CSV Import",qe="csvupload",We={teacherName:"",teacherEmail:"",studentIds:[],file:""},kt=()=>{const s=Se.useDispatch(),o=Se.useSelector(k=>k.common.isLoading),[r,c]=i.useState(null),[x,n]=i.useState(),[_,f]=i.useState([]),[m,S]=i.useState(We),[D,u]=i.useState(),[w,L]=i.useState([]),j=window.location.hostname.includes("isb"),[I,O]=i.useState(0),[K,A]=i.useState("");i.useEffect(()=>{document.title=Et},[]);const Q=j?At:Mt,re=async()=>{s(t.setLoading(!0));try{const p=await Lt(!0);var k=new Blob([t.toUkTemplate(p.data.content)],{type:"text/csv"});const d=window.URL.createObjectURL(k);var v=document.createElement("a");v.href=d,v.setAttribute("download",p.data.nameFile),v.click(),s(t.setAlert({type:"success",message:"Download successfully"}))}catch(p){s(t.setAlert({type:"danger",message:p.message}))}s(t.setLoading(!1))},oe=i.useCallback(async k=>{if(!r||!k)return;s(t.setLoading(!0));try{k=await t.ukYearCsvToGradeCsv(k);const N=new FormData;N.append("file",k,k.name);const F=r==="allUser"?t.CsvImportType.Admin:t.CsvImportType.Teacher,G=await W.validateCsvApi(N,F,!0);if(G.data&&G.data.length>0){L(G.data),s(t.setLoading(!1)),s(t.setAlert({type:"danger",message:"Please use the file as per the template."}));return}if(r=="allUser"){let de=(await k.text()).trim();const J=de.split(`
|
|
4
|
+
`).map(X=>X.trim()),ae=J.findIndex(X=>X.split(",").includes("First Name"));if(ae===0)throw new Error("Invalid CSV: Missing header row.");de=J.slice(ae).join(`
|
|
5
|
+
`);const ne=Ze.parse(de,{header:!0,skipEmptyLines:!0}),ge=ne.meta.fields,he=ne.data;if(!he.length){s(t.setLoading(!1)),s(t.setAlert({type:"danger",message:"The file has no data or some column names are misformed."}));return}const H=10,ue=[];for(let X=0;X<he.length;X+=H){const ye=he.slice(X,X+H).map(je=>Object.values(je).map(ve=>(ve??"").toString().trim()));ge&&ye.unshift(ge),ue.push(ye)}for(let X=0;X<ue.length;X++)await Nt({index:X,chunks:ue[X]}),await new Promise(me=>setTimeout(me,500))}else j?r=="classReflection"&&await Je(N):await bt(N,r.toString());s(t.setAlert({type:"success",message:"Import CSV successfully"}))}catch(N){console.error("❌ Upload failed",N),s(t.setAlert({type:"danger",message:N.response?.data?.title||N.message}))}s(t.setLoading(!1));const v=document.getElementById(qe),p=document.getElementById("import-student"),d=document.getElementById("import-classReflection");v&&(v.value=""),p&&(p.value=""),d&&(d.value="")},[r]),Z=async k=>{if(!I){s(t.setAlert({type:"danger",message:"Select teacher before import csv"}));return}if(!r||!k)return;s(t.setLoading(!0));try{k=await t.ukYearCsvToGradeCsv(k);const p=new FormData;p.append("file",k,k.name),await wt(I,p),s(t.setAlert({type:"success",message:"Import CSV successfully"}))}catch(p){s(t.setAlert({type:"danger",message:p.response?.data?.title||p.message}))}s(t.setLoading(!1));const v=document.getElementById("teacherSelector");v&&(v.value="")},y=async k=>{if(!x||!x)return;s(t.setLoading(!0));try{const p=new FormData;p.append("file",x,x.name),p.append("teacherName",k.teacherName),p.append("teacherEmail",k.teacherEmail),k.studentIds.forEach(d=>{p.append("studentIds",d)}),await Je(p),s(t.setAlert({type:"success",message:"Import CSV successfully"})),S(We)}catch(p){s(t.setAlert({type:"danger",message:p.response?.data?.title||p.message}))}s(t.setLoading(!1));const v=document.getElementById(qe);v&&(v.value="")},$=k=>{O(k.value)},V=k=>{u(k),A(k?.name||"")},q=()=>{if(!D){s(t.setAlert({type:"danger",message:"Select CSV to import"}));return}Z(D)};return{isLoading:o,buttons:Q,id:qe,setType:c,upload:oe,initImportReflection:m,setInitImportReflection:S,onConfirm:y,CSVType:Ye,dataFile:x,setDataFile:n,setArrStudent:f,arrStudent:_,isCheckDomainIBS:j,onChangeTeacher:$,uploadByTeacherId:Z,setDataFileImportStudent:V,onUpLoadStudentFile:q,defaultTeacher:I,fileName:K,onStudentSubmit:()=>{s(t.setModal({isOpen:!0,type:"warning",message:"Are you sure upload this file?",onConfirm:()=>{q()}}))},downloadTemplateUser:re,errorsValidate:w,setErrorsValidate:L}},Ut=be.object({teacherName:be.string()?.trim().required(),teacherEmail:be.string()?.trim().email("Invalid email").required(),studentIds:be.array().required().test("test students","Please choose student",function(){return!!this.parent.studentIds&&!!this.parent.studentIds.length}),file:be.string()?.trim().required()}),Bt=()=>{const{initImportReflection:s,onConfirm:o,isLoading:r,setType:c,id:x,CSVType:n,dataFile:_,setDataFile:f,setArrStudent:m,buttons:S,upload:D,isCheckDomainIBS:u,downloadTemplateUser:w,errorsValidate:L,setErrorsValidate:E}=kt(),{t:j}=le.useTranslation();return e.jsx("div",{className:"animated fadeIn pt-3",children:u?e.jsxs(e.Fragment,{children:[e.jsx(l.Input,{className:"d-none",type:"file",id:"import-user",onChange:I=>D(I.target.files[0]),accept:"text/csv"}),e.jsx(l.Input,{className:"d-none",type:"file",id:"import-classReflection",onChange:I=>D(I.target.files[0]),accept:"text/csv"}),e.jsx("div",{className:"class-reflection",children:e.jsx(et.Formik,{initialValues:s,enableReinitialize:!0,validationSchema:Ut,onSubmit:(I,O)=>{o(I),f(""),m([]),O.resetForm()},children:I=>{const{touched:O,errors:K}=I;return e.jsxs(l.Row,{className:"mb-2",children:[e.jsx(l.Input,{className:"d-none",type:"file",id:x,onChange:A=>{f(A.target.files[0]),I.setFieldValue("file","imported");const Q=document.getElementById(x);Q&&(Q.value="")},accept:"text/csv"}),e.jsx(l.Col,{md:6,className:"mb-2 d-flex mt-5",children:e.jsxs(l.Row,{className:"w-100 flex-column",children:[e.jsxs(l.Col,{md:12,className:"",children:[e.jsx(t.RequiredLabel,{text:j("import_class_reflection")}),e.jsx(Ne,{htmlFor:"import-classReflection",text:j("import_class_reflection"),isDisabled:r,backgroundColor:"#e74c3c",onClick:()=>{c(n.ClassReflection)}},"Import class reflections"),!!_&&e.jsx("p",{style:{color:"#007bff",fontStyle:"italic",marginTop:"5px"},children:_.name})]}),!_&&e.jsx(l.Col,{md:12,className:"mb-2",children:O.file&&K.file&&e.jsx(t.ErrorHandler,{text:K.file})})]})}),e.jsx(l.Col,{md:6,className:"mb-2",children:e.jsxs(l.Row,{className:"flex-column",children:[e.jsx(l.Col,{md:12,className:"mb-2 text-right",style:{textAlign:"right"},children:e.jsx(l.Button,{role:"button",color:"primary",onClick:()=>w(),children:e.jsxs("p",{className:"d-flex align-items-center mb-0",children:[j("download_template")," ",e.jsx(W.AiOutlineDownload,{size:20,className:"ml-2"})]})})}),e.jsxs(l.Col,{md:12,className:"mb-2",children:[e.jsx(t.RequiredLabel,{text:j("import_users")}),S.map(A=>e.jsx(Ne,{htmlFor:"import-user",text:A.text,isDisabled:r,backgroundColor:A.backgroundColor,onClick:()=>c(A.type)},A.text))]}),L?.length>0&&L.map((A,Q)=>e.jsx(t.ErrorHandler,{text:A},Q))]})})]})}})})]}):e.jsx(e.Fragment,{children:e.jsxs(l.Row,{children:[e.jsx(l.Col,{md:12,className:"mt-2 mb-2 text-left",children:e.jsx(l.Button,{role:"button",color:"primary",onClick:()=>w(),children:e.jsxs("p",{className:"d-flex align-items-center mb-0",children:[j("download_template")," ",e.jsx(W.AiOutlineDownload,{size:20,className:"ml-2"})]})})}),e.jsxs(l.Col,{md:6,className:"mb-3",children:[e.jsx(l.Input,{id:"import-user",className:"d-none",type:"file",onChange:I=>D(I.target.files[0]),accept:"text/csv"}),e.jsx(t.RequiredLabel,{text:j("import_users")}),e.jsx(Ne,{htmlFor:"import-user",text:j("import_users"),isDisabled:r,backgroundColor:"#0abde3",onClick:()=>{c(n.AllUser),L.length>0&&E([])}},"import-users")]}),L.length>0&&L.map((I,O)=>e.jsx(t.ErrorHandler,{text:I},O)),e.jsxs(l.Col,{md:6,className:"mb-3",children:[e.jsx(l.Input,{className:"d-none",type:"file",id:x,onChange:I=>D(I.target.files[0]),accept:"text/csv"}),S.map(I=>e.jsxs(e.Fragment,{children:[e.jsx(t.RequiredLabel,{text:j(I.text)}),e.jsx(Ne,{htmlFor:x,text:j(I.text),isDisabled:r,backgroundColor:I.backgroundColor,onClick:()=>c(I.type)},I.text)]}))]})]})})})},Ot=[{path:"/admin/users/user-list",title:"user_list",component:W.UserList},{path:"/admin/users/assign-student",title:"assign_student",component:yt},{path:"/admin/users/user-deleted",title:"user_deleted",component:_t},{path:"/admin/users/import-csv",title:"csv_import",component:Bt}],Dt=()=>e.jsx(t.CustomTabs,{tabs:Ot});exports.default=Dt;
|