@nualang/nualang-ui-components 0.1.1252 → 0.1.1253

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.
@@ -224,7 +224,7 @@ function AssignmentCard({
224
224
  children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(_material.Box, {
225
225
  children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_Typography.default, {
226
226
  variant: "h4",
227
- children: assignment.assignedStudents.length
227
+ children: assignment.assignedStudents?.length
228
228
  }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_Typography.default, {
229
229
  variant: "body2",
230
230
  color: "text.secondary",
@@ -324,6 +324,111 @@ function OverflowMenu({
324
324
  }, "UpgradeSubscription")]
325
325
  });
326
326
  }
327
+ function ClassroomLoading({
328
+ t = text => text
329
+ }) {
330
+ const {
331
+ classes
332
+ } = useStyles();
333
+ return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
334
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
335
+ className: classes.cardTop,
336
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Skeleton.default, {
337
+ variant: "rectangular",
338
+ sx: theme => ({
339
+ [theme.breakpoints.up("md")]: {
340
+ paddingTop: "15%"
341
+ },
342
+ height: 0,
343
+ paddingTop: "25%",
344
+ borderRadius: theme.spacing(2),
345
+ marginBottom: theme.spacing(4)
346
+ })
347
+ })
348
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
349
+ className: classes.header,
350
+ children: /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
351
+ className: classes.headerText,
352
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Typography, {
353
+ variant: "h5",
354
+ component: "h1",
355
+ gutterBottom: true,
356
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Skeleton.default, {
357
+ variant: "rectangular",
358
+ height: 32,
359
+ width: 150
360
+ })
361
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Typography, {
362
+ variant: "body2",
363
+ color: "textSecondary",
364
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Skeleton.default, {
365
+ variant: "rectangular",
366
+ height: 20,
367
+ width: 250
368
+ })
369
+ }), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_material.Box, {
370
+ display: "flex",
371
+ alignItems: "center",
372
+ mt: 2,
373
+ mb: 1,
374
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Box, {
375
+ mr: 1,
376
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Button, {
377
+ variant: "contained",
378
+ color: "primary",
379
+ startIcon: /*#__PURE__*/(0, _jsxRuntime.jsx)(_PersonAdd.default, {}),
380
+ size: "small",
381
+ disabled: true,
382
+ children: t("join")
383
+ })
384
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_DefaultColourButton.default, {
385
+ startIcon: /*#__PURE__*/(0, _jsxRuntime.jsx)(_MoreVert.default, {}),
386
+ size: "small",
387
+ className: classes.moreOptions,
388
+ disabled: true,
389
+ children: t("more_options")
390
+ })]
391
+ })]
392
+ })
393
+ }), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_ResponsiveTabs.default, {
394
+ t: t,
395
+ tabs: [{
396
+ label: t("courses"),
397
+ id: "Courses"
398
+ }, {
399
+ label: t("assignments"),
400
+ id: "Assignments"
401
+ }, {
402
+ label: t("progress"),
403
+ id: "Discuss"
404
+ }, {
405
+ label: t("members"),
406
+ id: "Members"
407
+ }, {
408
+ label: t("settings"),
409
+ id: "Settings",
410
+ disabled: true
411
+ }],
412
+ centered: true,
413
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Box, {
414
+ py: 1,
415
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Courses.default, {
416
+ t: t,
417
+ courses: null
418
+ })
419
+ }), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_material.Box, {
420
+ py: 1,
421
+ children: [t("loading"), "..."]
422
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Box, {
423
+ py: 1,
424
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Members.default, {
425
+ t: t,
426
+ members: null
427
+ })
428
+ })]
429
+ })]
430
+ });
431
+ }
327
432
  function Classroom({
328
433
  t = text => text,
329
434
  classroom,
@@ -659,99 +764,6 @@ function Classroom({
659
764
  setIsCreatorNotSubscribedUpgradeOpen(false);
660
765
  };
661
766
  const [avatarOptionClicked, setAvatarOptionClicked] = (0, _react.useState)(false);
662
- if (!classroom) {
663
- return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
664
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
665
- className: classes.cardTop,
666
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Skeleton.default, {
667
- variant: "rectangular",
668
- sx: theme => ({
669
- [theme.breakpoints.up("md")]: {
670
- paddingTop: "15%"
671
- },
672
- height: 0,
673
- paddingTop: "25%",
674
- borderRadius: theme.spacing(2),
675
- marginBottom: theme.spacing(4)
676
- })
677
- })
678
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
679
- className: classes.header,
680
- children: /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
681
- className: classes.headerText,
682
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Typography, {
683
- variant: "h5",
684
- component: "h1",
685
- gutterBottom: true,
686
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Skeleton.default, {
687
- variant: "rectangular",
688
- height: 32,
689
- width: 150
690
- })
691
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Typography, {
692
- variant: "body2",
693
- color: "textSecondary",
694
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Skeleton.default, {
695
- variant: "rectangular",
696
- height: 20,
697
- width: 250
698
- })
699
- }), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_material.Box, {
700
- display: "flex",
701
- alignItems: "center",
702
- mt: 2,
703
- mb: 1,
704
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Box, {
705
- mr: 1,
706
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Button, {
707
- variant: "contained",
708
- color: "primary",
709
- startIcon: /*#__PURE__*/(0, _jsxRuntime.jsx)(_PersonAdd.default, {}),
710
- size: "small",
711
- disabled: true,
712
- children: t("join")
713
- })
714
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_DefaultColourButton.default, {
715
- startIcon: /*#__PURE__*/(0, _jsxRuntime.jsx)(_MoreVert.default, {}),
716
- size: "small",
717
- className: classes.moreOptions,
718
- disabled: true,
719
- children: t("more_options")
720
- })]
721
- })]
722
- })
723
- }), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_ResponsiveTabs.default, {
724
- t: t,
725
- tabs: [{
726
- label: t("courses")
727
- }, {
728
- label: t("progress")
729
- }, {
730
- label: t("members")
731
- }, {
732
- label: t("settings"),
733
- disabled: true
734
- }],
735
- centered: true,
736
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Box, {
737
- py: 1,
738
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Courses.default, {
739
- t: t,
740
- courses: null
741
- })
742
- }), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_material.Box, {
743
- py: 1,
744
- children: [t("loading"), "..."]
745
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Box, {
746
- py: 1,
747
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Members.default, {
748
- t: t,
749
- members: null
750
- })
751
- })]
752
- })]
753
- });
754
- }
755
767
  const {
756
768
  classroomId,
757
769
  classroomName,
@@ -1167,19 +1179,20 @@ function Classroom({
1167
1179
  tabIndex: tabs.findIndex(tab => tab.id === "Courses"),
1168
1180
  variant: "circular"
1169
1181
  }, vchatFab, assignmentsFab]];
1170
- let initialTabValue;
1171
- if (window.location.hash) {
1172
- const selectedTab = window.location.hash;
1173
- initialTabValue = tabs.findIndex(tab => tab.id === selectedTab.replace("#", ""));
1174
- if (initialTabValue === 3 || initialTabValue === 4 && !isCreator) {
1175
- initialTabValue = 0;
1176
- }
1177
- if (initialTabValue < 0) {
1178
- initialTabValue = 0;
1182
+ const initialTabValue = (0, _react.useMemo)(() => {
1183
+ if (window.location.hash) {
1184
+ const selectedTabId = window.location.hash.slice(1);
1185
+ const index = tabs.findIndex(tab => tab.id === selectedTabId);
1186
+ const tab = tabs[index];
1187
+ const isDisabled = tab?.disabled;
1188
+ const isRestricted = (tab?.id === "Settings" || tab?.id === "Members") && !isCreator;
1189
+ if (index >= 0 && !isDisabled && !isRestricted) {
1190
+ return index;
1191
+ }
1179
1192
  }
1180
- } else {
1181
- initialTabValue = 0;
1182
- }
1193
+ return 0;
1194
+ }, [isCreator.tabs?.length]); // only recompute if isCreator or tabs change
1195
+
1183
1196
  return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
1184
1197
  children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
1185
1198
  className: classes.cardTop,
@@ -1543,7 +1556,7 @@ function ViewClassroom({
1543
1556
  return /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
1544
1557
  className: classes.root,
1545
1558
  children: [isLoading && !classroom && /*#__PURE__*/(0, _jsxRuntime.jsx)(_jsxRuntime.Fragment, {
1546
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(Classroom, {
1559
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(ClassroomLoading, {
1547
1560
  t: t
1548
1561
  })
1549
1562
  }), !isLoading && classroom && Object.keys(classroom).length && /*#__PURE__*/(0, _jsxRuntime.jsx)(_jsxRuntime.Fragment, {
@@ -238,11 +238,16 @@ function Progress({
238
238
  (0, _react.useEffect)(() => {
239
239
  if ("URLSearchParams" in window) {
240
240
  const searchParams = (0, _utils2.searchStringToObj)(window.location.search);
241
- const courseId = searchParams.courseId;
242
- const assignmentId = searchParams.assignmentId;
243
- if (searchParams.reportType && !reportType && reportTypes.includes(searchParams.reportType) && reportType !== searchParams.reportType) {
241
+ if (searchParams.reportType && searchParams.reportType !== reportTypes[0] && reportTypes.includes(searchParams.reportType) && reportType !== searchParams.reportType) {
244
242
  setReportType(searchParams.reportType);
245
243
  }
244
+ }
245
+ }, []);
246
+ (0, _react.useEffect)(() => {
247
+ if ("URLSearchParams" in window) {
248
+ const searchParams = (0, _utils2.searchStringToObj)(window.location.search);
249
+ const courseId = searchParams.courseId;
250
+ const assignmentId = searchParams.assignmentId;
246
251
  if (assignmentId && !selectedAssignment && assignments && assignments.length) {
247
252
  const assignmentIndex = assignments.findIndex(a => a.assignmentId === assignmentId);
248
253
  const assignment = assignments[assignmentIndex];
@@ -598,7 +598,7 @@ function TableRow({
598
598
  fetchMemberCourseCompletions,
599
599
  filter,
600
600
  index,
601
- featureFlags,
601
+ featureFlags = {},
602
602
  selectedAssignment,
603
603
  reportType,
604
604
  tableExercises,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nualang/nualang-ui-components",
3
- "version": "0.1.1252",
3
+ "version": "0.1.1253",
4
4
  "main": "dist/index.js",
5
5
  "files": [
6
6
  "dist",