@selfcommunity/react-templates 0.4.5-courses.197 → 0.4.5-courses.199

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,4 +1,4 @@
1
- import { LessonAppbarProps, LessonDrawerProps } from '@selfcommunity/react-ui';
1
+ import { LessonAppbarProps, LessonDrawerProps, SCLessonActionsType } from '@selfcommunity/react-ui';
2
2
  export interface LessonProps {
3
3
  /**
4
4
  * Overrides or extends the styles applied to the component.
@@ -52,6 +52,16 @@ export interface LessonProps {
52
52
  * @default null
53
53
  */
54
54
  onActivePanelChange?: (panel: any) => void;
55
+ /**
56
+ * Handler on status change
57
+ * @default null
58
+ */
59
+ onLessonStatusChange?: () => void;
60
+ /**
61
+ * If passed renders the component with a specific section opened
62
+ * @default null
63
+ */
64
+ lessonAction?: SCLessonActionsType;
55
65
  /**
56
66
  * Any other properties
57
67
  */
@@ -42,7 +42,7 @@ function Lesson(inProps) {
42
42
  props: inProps,
43
43
  name: constants_1.PREFIX
44
44
  });
45
- const { className = null, courseId, sectionId, lessonId, LessonAppbarProps = {}, LessonDrawerProps = {}, editMode = false, previewMode = false, onEditModeClose = null, onLessonChange = null, onActivePanelChange = null } = props, rest = tslib_1.__rest(props, ["className", "courseId", "sectionId", "lessonId", "LessonAppbarProps", "LessonDrawerProps", "editMode", "previewMode", "onEditModeClose", "onLessonChange", "onActivePanelChange"]);
45
+ const { className = null, courseId, sectionId, lessonId, LessonAppbarProps = {}, LessonDrawerProps = {}, editMode = false, previewMode = false, onEditModeClose = null, onLessonChange = null, onActivePanelChange = null, onLessonStatusChange = null, lessonAction = null } = props, rest = tslib_1.__rest(props, ["className", "courseId", "sectionId", "lessonId", "LessonAppbarProps", "LessonDrawerProps", "editMode", "previewMode", "onEditModeClose", "onLessonChange", "onActivePanelChange", "onLessonStatusChange", "lessonAction"]);
46
46
  // HOOKS
47
47
  const theme = (0, material_1.useTheme)();
48
48
  const isMobile = (0, material_1.useMediaQuery)(theme.breakpoints.down('md'));
@@ -56,7 +56,7 @@ function Lesson(inProps) {
56
56
  const { enqueueSnackbar } = (0, notistack_1.useSnackbar)();
57
57
  const scRoutingContext = (0, react_core_1.useSCRouting)();
58
58
  // STATE
59
- const [activePanel, setActivePanel] = (0, react_1.useState)(null);
59
+ const [activePanel, setActivePanel] = (0, react_1.useState)(lessonAction);
60
60
  const [settings, setSettings] = (0, react_1.useState)(null);
61
61
  const [updating, setUpdating] = (0, react_1.useState)(false);
62
62
  const [lessonContent, setLessonContent] = (0, react_1.useState)('');
@@ -176,6 +176,7 @@ function Lesson(inProps) {
176
176
  if (updatedCourse.num_lessons === updatedCourse.num_lessons_completed) {
177
177
  setOpenDialog(true);
178
178
  }
179
+ onLessonStatusChange === null || onLessonStatusChange === void 0 ? void 0 : onLessonStatusChange();
179
180
  })
180
181
  .catch((error) => {
181
182
  setLoading(false);
@@ -1,4 +1,4 @@
1
- import { LessonAppbarProps, LessonDrawerProps } from '@selfcommunity/react-ui';
1
+ import { LessonAppbarProps, LessonDrawerProps, SCLessonActionsType } from '@selfcommunity/react-ui';
2
2
  export interface LessonProps {
3
3
  /**
4
4
  * Overrides or extends the styles applied to the component.
@@ -52,6 +52,16 @@ export interface LessonProps {
52
52
  * @default null
53
53
  */
54
54
  onActivePanelChange?: (panel: any) => void;
55
+ /**
56
+ * Handler on status change
57
+ * @default null
58
+ */
59
+ onLessonStatusChange?: () => void;
60
+ /**
61
+ * If passed renders the component with a specific section opened
62
+ * @default null
63
+ */
64
+ lessonAction?: SCLessonActionsType;
55
65
  /**
56
66
  * Any other properties
57
67
  */
@@ -40,7 +40,7 @@ export default function Lesson(inProps) {
40
40
  props: inProps,
41
41
  name: PREFIX
42
42
  });
43
- const { className = null, courseId, sectionId, lessonId, LessonAppbarProps = {}, LessonDrawerProps = {}, editMode = false, previewMode = false, onEditModeClose = null, onLessonChange = null, onActivePanelChange = null } = props, rest = __rest(props, ["className", "courseId", "sectionId", "lessonId", "LessonAppbarProps", "LessonDrawerProps", "editMode", "previewMode", "onEditModeClose", "onLessonChange", "onActivePanelChange"]);
43
+ const { className = null, courseId, sectionId, lessonId, LessonAppbarProps = {}, LessonDrawerProps = {}, editMode = false, previewMode = false, onEditModeClose = null, onLessonChange = null, onActivePanelChange = null, onLessonStatusChange = null, lessonAction = null } = props, rest = __rest(props, ["className", "courseId", "sectionId", "lessonId", "LessonAppbarProps", "LessonDrawerProps", "editMode", "previewMode", "onEditModeClose", "onLessonChange", "onActivePanelChange", "onLessonStatusChange", "lessonAction"]);
44
44
  // HOOKS
45
45
  const theme = useTheme();
46
46
  const isMobile = useMediaQuery(theme.breakpoints.down('md'));
@@ -54,7 +54,7 @@ export default function Lesson(inProps) {
54
54
  const { enqueueSnackbar } = useSnackbar();
55
55
  const scRoutingContext = useSCRouting();
56
56
  // STATE
57
- const [activePanel, setActivePanel] = useState(null);
57
+ const [activePanel, setActivePanel] = useState(lessonAction);
58
58
  const [settings, setSettings] = useState(null);
59
59
  const [updating, setUpdating] = useState(false);
60
60
  const [lessonContent, setLessonContent] = useState('');
@@ -174,6 +174,7 @@ export default function Lesson(inProps) {
174
174
  if (updatedCourse.num_lessons === updatedCourse.num_lessons_completed) {
175
175
  setOpenDialog(true);
176
176
  }
177
+ onLessonStatusChange === null || onLessonStatusChange === void 0 ? void 0 : onLessonStatusChange();
177
178
  })
178
179
  .catch((error) => {
179
180
  setLoading(false);