@nualang/nualang-ui-components 0.1.1330 → 0.1.1332

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.
@@ -1,6 +1,7 @@
1
1
  import { useState, useEffect, useRef } from "react";
2
2
  import { Card, CardContent, CardActions, Typography, Avatar, Box, Button, TextField, Chip, Grid, IconButton, Tooltip, Checkbox } from "@mui/material";
3
- import { grey, green } from "@mui/material/colors";
3
+ import { grey, green, red } from "@mui/material/colors";
4
+ import ErrorIcon from "@mui/icons-material/Error";
4
5
  import AutoFixHighIcon from "@mui/icons-material/AutoFixHigh";
5
6
  import ErrorOutlineIcon from "@mui/icons-material/ErrorOutline";
6
7
  import CheckCircleIcon from "@mui/icons-material/CheckCircle";
@@ -73,7 +74,8 @@ export default function FeedbackCard({
73
74
  startTimes = {},
74
75
  canSubmitAll = {},
75
76
  setCanSubmit = () => {},
76
- setIsGeneratingIndividual = () => {}
77
+ setIsGeneratingIndividual = () => {},
78
+ hasBadLanguage
77
79
  }) {
78
80
  const [isRecordingDialogOpen, setIsRecordingDialogOpen] = useState(false);
79
81
  const [hasBeenEdited, setHasBeenEdited] = useState(false);
@@ -307,10 +309,37 @@ export default function FeedbackCard({
307
309
  fontWeight: 600,
308
310
  color: "text.secondary"
309
311
  },
310
- children: [/*#__PURE__*/_jsx(Checkbox, {
311
- checked: checkedSubmissions[discussionData.meetingId || discussionData.meetingID || discussionData.extMeetingId] || false,
312
- disabled: !hasSubmission,
313
- onChange: handleChangeCheckbox
312
+ children: [/*#__PURE__*/_jsxs(Box, {
313
+ sx: {
314
+ display: "flex",
315
+ alignItems: "center",
316
+ justifyContent: "space-between",
317
+ mb: 1
318
+ },
319
+ children: [/*#__PURE__*/_jsx(Checkbox, {
320
+ checked: checkedSubmissions[discussionData.meetingId || discussionData.meetingID || discussionData.extMeetingId] || false,
321
+ disabled: !hasSubmission,
322
+ onChange: handleChangeCheckbox
323
+ }), hasBadLanguage && /*#__PURE__*/_jsxs(Box, {
324
+ sx: {
325
+ display: "flex",
326
+ alignItems: "center",
327
+ px: 2,
328
+ py: 0.5,
329
+ backgroundColor: red[800],
330
+ borderRadius: "50px",
331
+ color: "white"
332
+ },
333
+ children: [/*#__PURE__*/_jsx(ErrorIcon, {
334
+ sx: {
335
+ mr: 1
336
+ }
337
+ }), /*#__PURE__*/_jsx(Typography, {
338
+ fontWeight: "bold",
339
+ variant: "subtitle2",
340
+ children: t("inappropriate_language_detected")
341
+ })]
342
+ })]
314
343
  }), /*#__PURE__*/_jsxs(Grid, {
315
344
  container: true,
316
345
  alignItems: "center",
@@ -329,24 +358,32 @@ export default function FeedbackCard({
329
358
  xs: 12,
330
359
  md: 9.5
331
360
  },
332
- children: /*#__PURE__*/_jsxs(Box, {
361
+ children: /*#__PURE__*/_jsx(Box, {
333
362
  sx: {
334
363
  display: "flex",
335
- alignItems: "center"
364
+ alignItems: "center",
365
+ justifyContent: "space-between",
366
+ width: "100%"
336
367
  },
337
- children: [/*#__PURE__*/_jsx(Typography, {
338
- variant: "subtitle2",
339
- children: t("feedback")
340
- }), /*#__PURE__*/_jsx(Tooltip, {
341
- title: t("rubric_info_desc"),
342
- children: /*#__PURE__*/_jsx(IconButton, {
343
- onClick: handleOpenPDF,
344
- color: "primary",
345
- "aria-label": t("rubric_info"),
346
- size: "small",
347
- children: /*#__PURE__*/_jsx(HelpOutlineIcon, {})
348
- })
349
- })]
368
+ children: /*#__PURE__*/_jsxs(Box, {
369
+ sx: {
370
+ display: "flex",
371
+ alignItems: "center"
372
+ },
373
+ children: [/*#__PURE__*/_jsx(Typography, {
374
+ variant: "subtitle2",
375
+ children: t("feedback")
376
+ }), /*#__PURE__*/_jsx(Tooltip, {
377
+ title: t("rubric_info_desc"),
378
+ children: /*#__PURE__*/_jsx(IconButton, {
379
+ onClick: handleOpenPDF,
380
+ color: "primary",
381
+ "aria-label": t("rubric_info"),
382
+ size: "small",
383
+ children: /*#__PURE__*/_jsx(HelpOutlineIcon, {})
384
+ })
385
+ })]
386
+ })
350
387
  })
351
388
  })]
352
389
  })]
@@ -550,7 +587,6 @@ export default function FeedbackCard({
550
587
  s3Url: s3Url,
551
588
  playerRef: playerRef,
552
589
  aiGrade: aiGrade,
553
- hasBadLanguage: discussionData?.hasBadLanguage || false,
554
590
  goToTimestamp: goToTimestamp,
555
591
  videoStartTime: startTimes[0]
556
592
  }), /*#__PURE__*/_jsx(PDFViewer, {
@@ -221,6 +221,20 @@ export default function GroupFeedbackDialog({
221
221
  throw error;
222
222
  }
223
223
  };
224
+ const hasBadLanguageByMeetingId = useMemo(() => {
225
+ const badLanguageMap = {};
226
+ submissionsForGroup.forEach(submission => {
227
+ const extMeetingId = submission.extMeetingId;
228
+ if (!extMeetingId) return;
229
+ if (badLanguageMap[extMeetingId] === undefined) {
230
+ badLanguageMap[extMeetingId] = false;
231
+ }
232
+ if (submission.hasBadLanguage === true) {
233
+ badLanguageMap[extMeetingId] = true;
234
+ }
235
+ });
236
+ return badLanguageMap;
237
+ }, [submissionsForGroup]);
224
238
  const feedbackByMeetingId = useMemo(() => {
225
239
  const feedbackMap = {};
226
240
  submissionsForGroup.forEach(submission => {
@@ -531,7 +545,8 @@ export default function GroupFeedbackDialog({
531
545
  startTimes: startTimes,
532
546
  canSubmitAll: canSubmit,
533
547
  setCanSubmit: setCanSubmit,
534
- setIsGeneratingIndividual: setIsGeneratingIndividual
548
+ setIsGeneratingIndividual: setIsGeneratingIndividual,
549
+ hasBadLanguage: hasBadLanguageByMeetingId[discMeetingId]
535
550
  }, discussion.meetingId || discussion.meetingID || index);
536
551
  }), /*#__PURE__*/_jsx("div", {
537
552
  ref: bottomRefCallback,
@@ -176,7 +176,6 @@ export default function RecordingDialog({
176
176
  playerRef,
177
177
  conversation,
178
178
  attendeesData,
179
- hasBadLanguage,
180
179
  videoStartTime
181
180
  }) {
182
181
  const theme = useTheme();
@@ -186,34 +185,15 @@ export default function RecordingDialog({
186
185
  open: open,
187
186
  handleClose: handleClose,
188
187
  maxWidth: 1,
189
- dialogTitle: /*#__PURE__*/_jsxs(Box, {
188
+ dialogTitle: /*#__PURE__*/_jsx(Box, {
190
189
  sx: {
191
190
  display: "flex",
192
191
  alignItems: "center",
193
192
  gap: 2
194
193
  },
195
- children: [/*#__PURE__*/_jsx(Typography, {
194
+ children: /*#__PURE__*/_jsx(Typography, {
196
195
  children: t("recording_info")
197
- }), hasBadLanguage && /*#__PURE__*/_jsxs(Box, {
198
- sx: {
199
- display: "flex",
200
- alignItems: "center",
201
- px: 2,
202
- py: 1,
203
- backgroundColor: red[800],
204
- borderRadius: "4px",
205
- color: "white"
206
- },
207
- children: [/*#__PURE__*/_jsx(ErrorIcon, {
208
- sx: {
209
- mr: 1
210
- }
211
- }), /*#__PURE__*/_jsx(Typography, {
212
- fontWeight: "bold",
213
- variant: "subtitle1",
214
- children: t("inappropriate_language_detected")
215
- })]
216
- })]
196
+ })
217
197
  }),
218
198
  children: /*#__PURE__*/_jsxs(Grid, {
219
199
  container: true,
@@ -47,11 +47,6 @@ function MeetingForm({
47
47
  meetingDate,
48
48
  level
49
49
  } = values;
50
- const currentDateTime = dayjs();
51
- let defaultMeetingDate = currentDateTime.add(1, "day").format("MM/DD/YYYY");
52
- const defaultMeetingTime = currentDateTime.format("h:mm A");
53
- const [newMeetingDate, setNewMeetingDate] = useState(defaultMeetingDate);
54
- const [newMeetingTime, setNewMeetingTime] = useState(defaultMeetingTime);
55
50
  const [initialBackgroundImages, setInitialBackgroundImages] = useState([]);
56
51
  const [initialMeetingImages, setInitialMeetingImages] = useState([]);
57
52
  const [openDialog, setOpenDialog] = useState(false);
@@ -92,20 +87,6 @@ function MeetingForm({
92
87
  setInitialMeetingImages(editMeetingImages);
93
88
  }
94
89
  }, [editMeetingImages, editBackgroundImages]);
95
- useEffect(() => {
96
- handleChange({
97
- target: {
98
- name: "meetingDate",
99
- value: newMeetingDate
100
- }
101
- });
102
- handleChange({
103
- target: {
104
- name: "meetingTime",
105
- value: newMeetingTime
106
- }
107
- });
108
- }, [newMeetingDate, newMeetingTime, handleChange]);
109
90
  const onChange = event => {
110
91
  handleChange({
111
92
  target: {
@@ -148,7 +129,40 @@ function MeetingForm({
148
129
  });
149
130
  }
150
131
  }, [level]);
151
- const dateTimePlaceholder = meetingTime && meetingDate ? dayjs(meetingDate + " " + meetingTime) : dayjs(defaultMeetingDate + " " + defaultMeetingTime);
132
+ useEffect(() => {
133
+ // Initialize date/time if not set or invalid
134
+ const currentDateTime = dayjs();
135
+ const defaultDateTime = currentDateTime.add(1, "day");
136
+ const isDateValid = meetingDate && dayjs(meetingDate, "MM/DD/YYYY", true).isValid();
137
+ const isTimeValid = meetingTime && dayjs(meetingTime, "h:mm A", true).isValid();
138
+ if (!isDateValid) {
139
+ handleChange({
140
+ target: {
141
+ name: "meetingDate",
142
+ value: defaultDateTime.format("MM/DD/YYYY")
143
+ }
144
+ });
145
+ }
146
+ if (!isTimeValid) {
147
+ handleChange({
148
+ target: {
149
+ name: "meetingTime",
150
+ value: defaultDateTime.format("h:mm A")
151
+ }
152
+ });
153
+ }
154
+ }, [meetingDate, meetingTime]);
155
+
156
+ // Update the dateTimePlaceholder calculation
157
+ const dateTimePlaceholder = (() => {
158
+ if (meetingTime && meetingDate) {
159
+ const parsed = dayjs(`${meetingDate} ${meetingTime}`, "MM/DD/YYYY h:mm A", true);
160
+ if (parsed.isValid()) {
161
+ return parsed;
162
+ }
163
+ }
164
+ return dayjs().add(1, "day");
165
+ })();
152
166
  return /*#__PURE__*/_jsxs(Grid, {
153
167
  container: true,
154
168
  sx: {
@@ -170,6 +184,7 @@ function MeetingForm({
170
184
  children: [/*#__PURE__*/_jsx(TextField, {
171
185
  autoFocus: true,
172
186
  id: "meetingTopic",
187
+ "data-cy": "meetingTopic",
173
188
  name: "meetingTopic",
174
189
  label: t("add_a_discussion_topic"),
175
190
  value: meetingTopic ? meetingTopic : "",
@@ -417,10 +432,18 @@ function MeetingForm({
417
432
  value: dateTimePlaceholder,
418
433
  onChange: newValue => {
419
434
  const datePickerValue = dayjs(newValue);
420
- const date = datePickerValue.format("MM/DD/YYYY");
421
- const time = datePickerValue.format("h:mm A");
422
- setNewMeetingDate(date);
423
- setNewMeetingTime(time);
435
+ handleChange({
436
+ target: {
437
+ name: "meetingDate",
438
+ value: datePickerValue.format("MM/DD/YYYY")
439
+ }
440
+ });
441
+ handleChange({
442
+ target: {
443
+ name: "meetingTime",
444
+ value: datePickerValue.format("h:mm A")
445
+ }
446
+ });
424
447
  }
425
448
  })
426
449
  })
@@ -688,6 +688,7 @@ function BotListItem({
688
688
  disabled: isCreator ? false : true,
689
689
  onClick: handleClickMenu,
690
690
  "aria-expanded": Boolean(anchorEl),
691
+ "data-cy": `${bot.botName}-more-options`,
691
692
  children: /*#__PURE__*/_jsx(MoreVertIcon, {})
692
693
  })
693
694
  })
@@ -829,6 +830,7 @@ function BotListItem({
829
830
  onClick: () => handleRemoveBot(bot),
830
831
  "aria-label": "Remove Bot",
831
832
  disabled: isCreator ? false : true,
833
+ "data-cy": `${bot.botName}-remove-bot`,
832
834
  children: [/*#__PURE__*/_jsx(ListItemIcon, {
833
835
  children: /*#__PURE__*/_jsx(Delete, {})
834
836
  }), /*#__PURE__*/_jsx(ListItemText, {
@@ -153,7 +153,8 @@ export default function WaitingRoom({
153
153
  color: "textSecondary",
154
154
  children: t(exerciseDescription)
155
155
  })
156
- })
156
+ }),
157
+ "data-cy": "waitingRoomExercise"
157
158
  })]
158
159
  }), isCreator && videoUrl && /*#__PURE__*/_jsx(Button, {
159
160
  variant: "contained",
@@ -203,6 +204,7 @@ export default function WaitingRoom({
203
204
  handleUpdateGame();
204
205
  },
205
206
  id: "startGame",
207
+ "data-cy": "startGameButton",
206
208
  children: t("start")
207
209
  })
208
210
  })
@@ -145,32 +145,33 @@ function HoverText({
145
145
  }
146
146
  }
147
147
  const words = props => {
148
- const childrenArray = props.children ? [props.children] : [];
149
- return childrenArray.map(child => child.map(childElement => {
150
- if (childElement && typeof childElement === "string") {
151
- return removeExtraWhiteSpaces(childElement).split(" ").map((word, index) => {
152
- if (word && typeof word === "string") {
153
- return /*#__PURE__*/_jsx(WordText, {
154
- value: `${word} `,
155
- disableTranslation: disableTranslation,
156
- handleTranslate: handleTranslate,
157
- handleSpeak: handleSpeak,
158
- learnLang: learnLang,
159
- forLang: forLang,
160
- voice: voice,
161
- voicePitch: voicePitch,
162
- voiceSpeed: voiceSpeed,
163
- muteSound: muteSound,
164
- disableHover: disableHover
165
- }, index);
166
- } else {
148
+ const childrenArray = Array.isArray(props.children) ? props.children : [props.children];
149
+ return childrenArray.map(child => {
150
+ const childArray = Array.isArray(child) ? child : [child];
151
+ return childArray.map(childElement => {
152
+ if (childElement && typeof childElement === "string") {
153
+ return removeExtraWhiteSpaces(childElement).split(" ").map((word, index) => {
154
+ if (word && typeof word === "string") {
155
+ return /*#__PURE__*/_jsx(WordText, {
156
+ value: `${word} `,
157
+ disableTranslation: disableTranslation,
158
+ handleTranslate: handleTranslate,
159
+ handleSpeak: handleSpeak,
160
+ learnLang: learnLang,
161
+ forLang: forLang,
162
+ voice: voice,
163
+ voicePitch: voicePitch,
164
+ voiceSpeed: voiceSpeed,
165
+ muteSound: muteSound,
166
+ disableHover: disableHover
167
+ }, index);
168
+ }
167
169
  return word;
168
- }
169
- });
170
- } else {
170
+ });
171
+ }
171
172
  return childElement;
172
- }
173
- }));
173
+ });
174
+ });
174
175
  };
175
176
  const components = {
176
177
  p: ({
@@ -536,7 +536,6 @@ function Classroom({
536
536
  editMeetingImages,
537
537
  setSelectedDiscussion,
538
538
  meetingRecsData,
539
- hasBadLanguage,
540
539
  handleArchiveSubmissions,
541
540
  isVideoChatEnabled,
542
541
  isVideoChatEnabledInSettings,
@@ -1053,7 +1052,6 @@ function Classroom({
1053
1052
  selectedRecording: selectedRecording,
1054
1053
  setSelectedRecording: setSelectedRecording,
1055
1054
  meetingRecsData: meetingRecsData,
1056
- hasBadLanguage: hasBadLanguage,
1057
1055
  handleArchiveSubmissions: handleArchiveSubmissions,
1058
1056
  startTimes: startTimes,
1059
1057
  learnLang: classroom?.learnLang
@@ -1375,6 +1373,7 @@ function Classroom({
1375
1373
  startIcon: /*#__PURE__*/_jsx(LiveTvIcon, {}),
1376
1374
  size: "small",
1377
1375
  id: "play-live",
1376
+ "data-cy": "playLiveButton",
1378
1377
  sx: {
1379
1378
  animation: createdGame && createdGame.createdBy === username ? `${theme.palette.mode === "light" ? glowPulseLight : glowPulseDark} 2s infinite ease-in-out` : null,
1380
1379
  boxShadow: createdGame && createdGame.createdBy === username ? `0 0 0 0 ${theme.palette.mode === "light" ? "rgba(101, 0, 221, 0.7)" : "rgba(171, 120, 255, 0.7)"}` : null
@@ -34,7 +34,6 @@ const MeetingPromptsList = withStyles(({
34
34
  aiGrade,
35
35
  meetingRecsData,
36
36
  resetVideoState,
37
- hasBadLanguage,
38
37
  setSelectedRecording,
39
38
  selectedRecording,
40
39
  getMeeting,
@@ -446,8 +445,7 @@ const MeetingPromptsList = withStyles(({
446
445
  recordingsTableData: groupedData[groupedId],
447
446
  handleBatchGradeConversations: handleBatchGradeConversations,
448
447
  aiGrade: aiGrade,
449
- playerRef: playerRef,
450
- hasBadLanguage: hasBadLanguage
448
+ playerRef: playerRef
451
449
  })
452
450
  })
453
451
  }), /*#__PURE__*/_jsx(CreateMeetingMultiStepForm, {
@@ -24,7 +24,6 @@ const RecordingListCards = withStyles(({
24
24
  selectedRecording,
25
25
  handleBatchGradeConversations,
26
26
  aiGrade,
27
- hasBadLanguage,
28
27
  t = text => text,
29
28
  isTeacher = false,
30
29
  attendeesData = []
@@ -123,8 +122,7 @@ const RecordingListCards = withStyles(({
123
122
  getMeeting: getMeeting,
124
123
  conversation: conversation,
125
124
  handleBatchGradeConversations: handleBatchGradeConversations,
126
- aiGrade: aiGrade,
127
- hasBadLanguage: hasBadLanguage
125
+ aiGrade: aiGrade
128
126
  }), /*#__PURE__*/_jsx(FeedbackDialog, {
129
127
  t: t,
130
128
  attendees: attendeeUsernames,
@@ -27,7 +27,6 @@ const SubmissionsTableCards = withStyles(({
27
27
  handleArchiveSubmissions = () => {},
28
28
  getMeeting = () => {},
29
29
  meetingRecsData,
30
- hasBadLanguage,
31
30
  resetVideoState = () => {},
32
31
  t = text => text
33
32
  }) => {
@@ -163,8 +162,7 @@ const SubmissionsTableCards = withStyles(({
163
162
  recordingsTableData: groupedData[groupedId],
164
163
  handleBatchGradeConversations: handleBatchGradeConversations,
165
164
  aiGrade: aiGrade,
166
- playerRef: playerRef,
167
- hasBadLanguage: hasBadLanguage
165
+ playerRef: playerRef
168
166
  })
169
167
  })
170
168
  }), /*#__PURE__*/_jsx(List, {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nualang/nualang-ui-components",
3
- "version": "0.1.1330",
3
+ "version": "0.1.1332",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "files": [