@nualang/nualang-ui-components 0.1.1257 → 0.1.1259

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.
@@ -19,7 +19,6 @@ var _OndemandVideo = _interopRequireDefault(require("@mui/icons-material/Ondeman
19
19
  var _AssignmentRoleplaySelection = _interopRequireDefault(require("../AssignmentRoleplaySelection/AssignmentRoleplaySelection"));
20
20
  var _CardElements = require("../../Cards/CardElements");
21
21
  var _Progress = require("@nualang/nualang-api-and-queries/APIs/Progress");
22
- var _mui = require("tss-react/mui");
23
22
  var _Queries = require("@nualang/nualang-api-and-queries/Queries");
24
23
  var _reactRouterDom = require("react-router-dom");
25
24
  var _Exercises = require("../../Lists/Exercises/Exercises");
@@ -369,7 +368,7 @@ function Topic({
369
368
  const theme = (0, _styles.useTheme)();
370
369
  const isLargeScreen = (0, _useMediaQuery.default)(theme.breakpoints.up("sm"));
371
370
  const topicRef = (0, _react.useRef)(null);
372
- const [lasClickedCourseId, lasClickedSectionId, lasClickedTopicId, lastClickedAssignmentId] = lastClickedExerciseId?.split("|") || [];
371
+ const [lasClickedTopicId, lastClickedAssignmentId] = lastClickedExerciseId?.split("|") || [];
373
372
  const [isExerciseListOpen, setExerciseListOpen] = (0, _react.useState)(lasClickedTopicId === topicId && lastClickedAssignmentId === assignment.assignmentId);
374
373
  const [isWholeTopicSelected, setIsWholeTopicSelected] = (0, _react.useState)(false);
375
374
  (0, _react.useEffect)(() => {
@@ -462,15 +461,16 @@ function Topic({
462
461
  setIsWholeTopicSelected(totalSelected === totalExpected);
463
462
  }, [selectedExercises, exercises, roleplays, bots, courseId, sectionId, topicId, games]);
464
463
  const handleSelectAll = () => {
465
- if (isWholeTopicSelected) {
466
- const removeExercises = selectedExercises?.filter(exercise => exercise.courseSectionTopicId === `${courseId}|${sectionId}|${topicId}` || exercise.roleplayId && roleplays?.some(roleplay => roleplay.roleplayId === exercise.roleplayId) || exercise.botId && bots?.some(bot => bot.botId === exercise.botId));
464
+ const isAllSelected = selectedCount === totalCount;
465
+ if (isAllSelected) {
466
+ const removeExercises = selectedExercises?.filter(exercise => exercise.courseSectionTopicId === courseSectionTopicId || exercise.roleplayId && roleplays?.some(r => r.roleplayId === exercise.roleplayId) || exercise.botId && bots?.some(b => b.botId === exercise.botId));
467
467
  handleSelectExercise(removeExercises);
468
468
  } else {
469
469
  let exercisesToAdd = [];
470
470
  exercises?.filter(e => e.name !== "roleplays").forEach(exercise => {
471
- if (!selectedExercises?.some(e => e.courseSectionTopicId === `${courseId}|${sectionId}|${topicId}` && e.name === exercise.name)) {
471
+ if (!selectedExercises?.some(e => e.courseSectionTopicId === courseSectionTopicId && e.name === exercise.name)) {
472
472
  exercisesToAdd.push({
473
- courseSectionTopicId: `${courseId}|${sectionId}|${topicId}`,
473
+ courseSectionTopicId: courseSectionTopicId,
474
474
  name: exercise.name
475
475
  });
476
476
  }
@@ -480,8 +480,8 @@ function Topic({
480
480
  if (!selectedExercises?.some(e => e.roleplayId === roleplay.roleplayId && e.name === name)) {
481
481
  exercisesToAdd.push({
482
482
  roleplayId: roleplay.roleplayId,
483
- name: name,
484
- courseSectionTopicId: `${courseId}|${sectionId}|${topicId}`,
483
+ name,
484
+ courseSectionTopicId: courseSectionTopicId,
485
485
  roleplayName: roleplay.roleplayName
486
486
  });
487
487
  }
@@ -491,7 +491,7 @@ function Topic({
491
491
  if (!selectedExercises?.some(e => e.botId === bot.botId)) {
492
492
  exercisesToAdd.push({
493
493
  botId: bot.botId,
494
- courseSectionTopicId: `${courseId}|${sectionId}|${topicId}`
494
+ courseSectionTopicId: courseSectionTopicId
495
495
  });
496
496
  }
497
497
  });
@@ -502,6 +502,16 @@ function Topic({
502
502
  setExerciseListOpen(!isExerciseListOpen);
503
503
  };
504
504
  const hasNonEmptyRoleplay = roleplays?.some(roleplay => roleplay?.script?.length !== 0 && roleplay?.script?.some(line => line.text !== undefined));
505
+ const courseSectionTopicId = `${courseId}|${sectionId}|${topicId}`;
506
+ const selectedRegular = selectedExercises?.filter(e => e.courseSectionTopicId === courseSectionTopicId && !e.roleplayId && !e.botId && e.name !== "roleplays" && e.name !== "bots").length || 0;
507
+ const selectedRoleplays = selectedExercises?.filter(e => e.courseSectionTopicId === courseSectionTopicId && e.roleplayId).length || 0;
508
+ const selectedBots = selectedExercises?.filter(e => e.courseSectionTopicId === courseSectionTopicId && e.botId).length || 0;
509
+ const selectedCount = selectedRegular + selectedRoleplays + selectedBots;
510
+ const totalRegular = 3;
511
+ const totalRoleplays = (roleplays?.length || 0) * (games?.length || 0);
512
+ const totalBots = bots?.length || 0;
513
+ const totalCount = totalRegular + totalRoleplays + totalBots;
514
+ const isTopicDisabled = phrases.length === 0 && !hasNonEmptyRoleplay || isExerciseSelected;
505
515
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(_jsxRuntime.Fragment, {
506
516
  children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_material.Tooltip, {
507
517
  title: phrases.length === 0 ? t("topic_no_phrases") : "",
@@ -592,11 +602,20 @@ function Topic({
592
602
  })]
593
603
  })
594
604
  })]
605
+ }), !isTopicDisabled && useCase === "assignment-select" && /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Chip, {
606
+ label: `${selectedCount} / ${totalCount}`,
607
+ size: "medium",
608
+ disabled: selectedCount === 0,
609
+ color: selectedCount === totalCount ? 'primary' : 'default',
610
+ sx: {
611
+ fontWeight: 'bold',
612
+ marginRight: 3
613
+ }
595
614
  }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.ListItemIcon, {
596
615
  children: isExerciseListOpen ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_ExpandLess.default, {}) : /*#__PURE__*/(0, _jsxRuntime.jsx)(_ExpandMore.default, {})
597
616
  }), useCase === "assignment-select" && /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.ListItemIcon, {
598
617
  children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Checkbox, {
599
- checked: isWholeTopicSelected,
618
+ checked: selectedCount === totalCount,
600
619
  onClick: event => {
601
620
  event.stopPropagation();
602
621
  },
@@ -72,11 +72,9 @@ function CardVisibility({
72
72
  fontWeight: "bold",
73
73
  textTransform: "capitalize",
74
74
  pointerEvents: "none",
75
- boxShadow: theme.shadows[1],
76
- backgroundColor: theme.palette.mode === "light" ? _colors.blue[700] : _colors.blue[500],
77
- ...(theme.palette.mode === "light" && {
78
- color: "white"
79
- })
75
+ boxShadow: theme.shadows[5],
76
+ backgroundColor: theme.palette.background.paper,
77
+ color: theme.palette.text.secondary
80
78
  })
81
79
  })]
82
80
  });
@@ -56,7 +56,8 @@ function OverflowMenu({
56
56
  classroomId,
57
57
  isClassroomArchived = false,
58
58
  canDuplicateCourse,
59
- hiddenCourses = []
59
+ hiddenCourses = [],
60
+ isTeacher
60
61
  }) {
61
62
  return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_material.Menu, {
62
63
  id: `card-menu-${courseId}`,
@@ -103,7 +104,7 @@ function OverflowMenu({
103
104
  }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Typography, {
104
105
  children: t("change_settings")
105
106
  })]
106
- }), !isClassroomArchived && /*#__PURE__*/(0, _jsxRuntime.jsx)(_jsxRuntime.Fragment, {
107
+ }), !isClassroomArchived && isTeacher && /*#__PURE__*/(0, _jsxRuntime.jsx)(_jsxRuntime.Fragment, {
107
108
  children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Tooltip, {
108
109
  title: !canDuplicateCourse ? t("duplicate_disabled_tooltip") : "",
109
110
  disableHoverListener: canDuplicateCourse,
@@ -124,15 +125,6 @@ function OverflowMenu({
124
125
  })
125
126
  })
126
127
  })
127
- }), handleRemoveCourse && !isClassroomArchived && /*#__PURE__*/(0, _jsxRuntime.jsxs)(_material.MenuItem, {
128
- onClick: () => handleRemoveCourse(courseId),
129
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_CardElements.CardMenuIcon, {
130
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Close.default, {
131
- fontSize: "small"
132
- })
133
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Typography, {
134
- children: t("remove_course")
135
- })]
136
128
  }), handleHideCourse && !hiddenCourses.includes(courseId) && !isClassroomArchived && /*#__PURE__*/(0, _jsxRuntime.jsxs)(_material.MenuItem, {
137
129
  onClick: () => handleHideCourse(courseId),
138
130
  children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_CardElements.CardMenuIcon, {
@@ -149,7 +141,16 @@ function OverflowMenu({
149
141
  fontSize: "small"
150
142
  })
151
143
  }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Typography, {
152
- children: t("show_course")
144
+ children: t("show_to_students")
145
+ })]
146
+ }), handleRemoveCourse && !isClassroomArchived && /*#__PURE__*/(0, _jsxRuntime.jsxs)(_material.MenuItem, {
147
+ onClick: () => handleRemoveCourse(courseId),
148
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_CardElements.CardMenuIcon, {
149
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Close.default, {
150
+ fontSize: "small"
151
+ })
152
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Typography, {
153
+ children: t("hide_from_students")
153
154
  })]
154
155
  })]
155
156
  });
@@ -243,6 +244,7 @@ function CourseCard({
243
244
  cardTitleComponent = "h2",
244
245
  isClassroomArchived = false,
245
246
  email,
247
+ isTeacher,
246
248
  hiddenCourses = []
247
249
  }) {
248
250
  const [placeholderRef, visible] = (0, _reactIntersectionObserver.useInView)({
@@ -568,7 +570,8 @@ function CourseCard({
568
570
  course: course,
569
571
  isClassroomArchived: isClassroomArchived,
570
572
  canDuplicateCourse: canDuplicateCourse,
571
- hiddenCourses: hiddenCourses
573
+ hiddenCourses: hiddenCourses,
574
+ isTeacher: isTeacher
572
575
  }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_Members.default, {
573
576
  getMemberDetails: getMemberDetails,
574
577
  t: t,
@@ -180,11 +180,11 @@ function GeneratePhrases({
180
180
  };
181
181
  const handleCancel = () => {
182
182
  setGeneratedPhrases([]);
183
- handleClose();
184
183
  };
185
184
  return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_ResponsiveDialog.default, {
186
185
  open: open,
187
- handleClose: handleCancel,
186
+ closeText: generatedPhrases.length > 0 ? t("cancel") : t("close"),
187
+ handleClose: generatedPhrases.length > 0 ? handleCancel : handleClose,
188
188
  handleSubmit: generatedPhrases.length > 0 ? handleConfirm : handleGeneratePhrases,
189
189
  submitText: generatedPhrases.length > 0 ? t("confirm") : t("generate_phrases"),
190
190
  dialogTitle: isGenerating ? t("generating_phrases") : t("generate_phrases"),
@@ -33,6 +33,7 @@ function CourseList({
33
33
  classroomId,
34
34
  isClassroomArchived = false,
35
35
  email,
36
+ isTeacher,
36
37
  ...otherProps
37
38
  }) {
38
39
  const [items, ref] = (0, _useListScroll.default)({
@@ -98,6 +99,7 @@ function CourseList({
98
99
  classroomId: classroomId,
99
100
  isClassroomArchived: isClassroomArchived,
100
101
  email: email,
102
+ isTeacher: isTeacher,
101
103
  ...otherProps
102
104
  }, course.courseId)
103
105
  }, course.courseId);
@@ -141,6 +143,7 @@ function CourseList({
141
143
  handleDuplicateCourse: handleDuplicateCourse,
142
144
  classroomId: classroomId,
143
145
  isClassroomArchived: isClassroomArchived,
146
+ isTeacher: isTeacher,
144
147
  ...otherProps
145
148
  }, course.courseId)
146
149
  }, course.courseId);
@@ -893,7 +893,8 @@ function Classroom({
893
893
  classroomId: classroomId,
894
894
  isClassroomArchived: isArchived,
895
895
  hiddenCourses: hiddenCourses,
896
- email: email
896
+ email: email,
897
+ isTeacher: isTeacher
897
898
  }) : /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
898
899
  id: "add-courses-fab",
899
900
  children: isCreator ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_ClassCourses.default, {
@@ -0,0 +1,156 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _react = require("react");
8
+ var _mui = require("tss-react/mui");
9
+ var _CircularProgress = _interopRequireDefault(require("@mui/material/CircularProgress"));
10
+ var _Styles = _interopRequireDefault(require("../../utils/Styles"));
11
+ var _reactRouterDom = require("react-router-dom");
12
+ var _material = require("@mui/material");
13
+ var _Refresh = _interopRequireDefault(require("@mui/icons-material/Refresh"));
14
+ var _jsxRuntime = require("react/jsx-runtime");
15
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
16
+ // Components
17
+
18
+ function UsersTable({
19
+ classes,
20
+ refresh,
21
+ loading,
22
+ users,
23
+ propsRowChange,
24
+ propsPageChange
25
+ }) {
26
+ const [page, setPage] = (0, _react.useState)(0);
27
+ const [rowsPerPage, setRowsPerPage] = (0, _react.useState)(5);
28
+ const handleChangePage = (event, page) => {
29
+ propsPageChange(page);
30
+ setPage(page);
31
+ };
32
+ const handleChangeRowsPerPage = event => {
33
+ setRowsPerPage(event.target.value);
34
+ propsRowChange(event.target.value);
35
+ };
36
+ const emptyRows = rowsPerPage - Math.min(rowsPerPage, users.length - page * rowsPerPage);
37
+ const handleDownloadCSV = data => {
38
+ const headers = ["Email", "ID", "Number of Classrooms", "Student Count", "Subscription Status", "Verification Status", "Expiration Date"];
39
+ const rows = data.map(row => [row.Attributes.email || "", row.Username || "", row.classrooms || 0, `${row.studentCount || 0}/200`, row.subscriptionStatus || 0, row.verificationStatus || "", row.subscriptionPeriodEnd ? new Date(row.subscriptionPeriodEnd * 1000).toLocaleDateString() : "-"]);
40
+ const csvContent = [headers, ...rows].map(e => e.map(val => `"${String(val).replace(/"/g, '""')}"`) // escape quotes
41
+ .join(",")).join("\n");
42
+ const blob = new Blob([csvContent], {
43
+ type: "text/csv;charset=utf-8;"
44
+ });
45
+ const url = URL.createObjectURL(blob);
46
+ const link = document.createElement("a");
47
+ link.href = url;
48
+ link.setAttribute("download", "users_table.csv");
49
+ document.body.appendChild(link);
50
+ link.click();
51
+ document.body.removeChild(link);
52
+ };
53
+ console.log({
54
+ wah: users,
55
+ location: window.location.origin
56
+ });
57
+ return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_material.Paper, {
58
+ className: classes.root,
59
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(_material.Toolbar, {
60
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Typography, {
61
+ variant: "headline",
62
+ color: "inherit",
63
+ children: "Users"
64
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
65
+ className: classes.grow
66
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Button, {
67
+ variant: "outlined",
68
+ color: "primary",
69
+ onClick: () => handleDownloadCSV(users),
70
+ children: "Download CSV"
71
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.IconButton, {
72
+ "aria-label": "Refresh",
73
+ onClick: refresh,
74
+ size: "large",
75
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Refresh.default, {})
76
+ })]
77
+ }), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_material.Table, {
78
+ className: classes.table,
79
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_material.TableHead, {
80
+ children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_material.TableRow, {
81
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_material.TableCell, {
82
+ className: classes.tableCell,
83
+ children: "Email"
84
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.TableCell, {
85
+ className: classes.tableCell,
86
+ children: "Number of Classrooms"
87
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.TableCell, {
88
+ className: classes.tableCell,
89
+ children: "Student Count"
90
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.TableCell, {
91
+ className: classes.tableCell,
92
+ children: "Subscription Status"
93
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.TableCell, {
94
+ className: classes.tableCell,
95
+ children: "Verification Status"
96
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.TableCell, {
97
+ className: classes.tableCell,
98
+ children: "Expiration Date"
99
+ })]
100
+ })
101
+ }), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_material.TableBody, {
102
+ children: [!loading ? users.slice(page * rowsPerPage, page * rowsPerPage + rowsPerPage).map(row => /*#__PURE__*/(0, _jsxRuntime.jsxs)(_material.TableRow, {
103
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_material.TableCell, {
104
+ className: classes.tableCell,
105
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactRouterDom.Link, {
106
+ href: `${window.location.origin}/analytics#/activity/member/${row.Username}`,
107
+ target: "_blank",
108
+ color: "inherit",
109
+ children: row.Attributes.email || ""
110
+ })
111
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.TableCell, {
112
+ className: classes.tableCell,
113
+ children: row.classrooms || 0
114
+ }), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_material.TableCell, {
115
+ className: classes.tableCell,
116
+ children: [row.studentCount || 0, "/200"]
117
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.TableCell, {
118
+ className: classes.tableCell,
119
+ children: row.subscriptionStatus || 0
120
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.TableCell, {
121
+ className: classes.tableCell,
122
+ children: row.verificationStatus || 0
123
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.TableCell, {
124
+ className: classes.tableCell,
125
+ children: row.subscriptionPeriodEnd ? new Date(row.subscriptionPeriodEnd * 1000).toLocaleDateString() : "-"
126
+ })]
127
+ }, row.Username)) : /*#__PURE__*/(0, _jsxRuntime.jsx)(_CircularProgress.default, {
128
+ className: classes.loadingSpinner
129
+ }), emptyRows > 0 && /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.TableRow, {
130
+ style: {
131
+ height: 49 * emptyRows
132
+ },
133
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.TableCell, {
134
+ colSpan: 7,
135
+ className: classes.tableCell
136
+ })
137
+ })]
138
+ })]
139
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.TablePagination, {
140
+ rowsPerPageOptions: [5, 10, 50, 100],
141
+ component: "div",
142
+ count: users !== undefined && users.length > 0 ? users.length : 0,
143
+ rowsPerPage: rowsPerPage,
144
+ page: page,
145
+ backIconButtonProps: {
146
+ "aria-label": "Previous Page"
147
+ },
148
+ nextIconButtonProps: {
149
+ "aria-label": "Next Page"
150
+ },
151
+ onPageChange: handleChangePage,
152
+ onRowsPerPageChange: handleChangeRowsPerPage
153
+ })]
154
+ });
155
+ }
156
+ var _default = exports.default = (0, _mui.withStyles)(UsersTable, _Styles.default);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nualang/nualang-ui-components",
3
- "version": "0.1.1257",
3
+ "version": "0.1.1259",
4
4
  "main": "dist/index.js",
5
5
  "files": [
6
6
  "dist",