@selfcommunity/react-templates 0.4.5-courses.116 → 0.4.5-courses.117

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 { SCCourseLessonType } from '@selfcommunity/types';
1
+ import { SCCourseLessonType, SCCourseType } from '@selfcommunity/types';
2
2
  import { LessonAppbarProps, LessonDrawerProps } from '@selfcommunity/react-ui';
3
3
  export interface LessonProps {
4
4
  /**
@@ -6,6 +6,10 @@ export interface LessonProps {
6
6
  * @default null
7
7
  */
8
8
  className?: string;
9
+ /**
10
+ * The course object
11
+ */
12
+ course?: SCCourseType;
9
13
  /**
10
14
  * The course id
11
15
  */
@@ -47,7 +51,7 @@ export interface LessonProps {
47
51
  * Handler on lesson change
48
52
  * @default null
49
53
  */
50
- onLessonChange?: (id: any) => void;
54
+ onLessonChange?: (lessonId: any, sectionId: any) => void;
51
55
  /**
52
56
  * Any other properties
53
57
  */
@@ -36,13 +36,13 @@ function Lesson(inProps) {
36
36
  props: inProps,
37
37
  name: constants_1.PREFIX
38
38
  });
39
- const { className = null, courseId, sectionId, lesson = null, lessonId, LessonAppbarProps = {}, LessonDrawerProps = {}, editMode = false, onEditModeClose = null, onLessonChange = null } = props, rest = tslib_1.__rest(props, ["className", "courseId", "sectionId", "lesson", "lessonId", "LessonAppbarProps", "LessonDrawerProps", "editMode", "onEditModeClose", "onLessonChange"]);
39
+ const { className = null, course, courseId, sectionId, lesson = null, lessonId, LessonAppbarProps = {}, LessonDrawerProps = {}, editMode = false, onEditModeClose = null, onLessonChange = null } = props, rest = tslib_1.__rest(props, ["className", "course", "courseId", "sectionId", "lesson", "lessonId", "LessonAppbarProps", "LessonDrawerProps", "editMode", "onEditModeClose", "onLessonChange"]);
40
40
  // HOOKS
41
41
  const theme = (0, material_1.useTheme)();
42
42
  const isMobile = (0, material_1.useMediaQuery)(theme.breakpoints.down('md'));
43
43
  const [_lessonId, setLessonId] = (0, react_1.useState)(lessonId);
44
44
  const [_sectionId, setSectionId] = (0, react_1.useState)(sectionId);
45
- const { scCourse } = (0, react_core_1.useSCFetchCourse)({ id: courseId, params: { view: editMode ? api_services_1.CourseInfoViewType.EDIT : api_services_1.CourseInfoViewType.USER } });
45
+ const { scCourse } = (0, react_core_1.useSCFetchCourse)({ id: courseId, course, params: { view: editMode ? api_services_1.CourseInfoViewType.EDIT : api_services_1.CourseInfoViewType.USER } });
46
46
  const { scLesson, setSCLesson } = (0, react_core_1.useSCFetchLesson)({ id: _lessonId, lesson, courseId, sectionId: _sectionId });
47
47
  // STATE
48
48
  const [activePanel, setActivePanel] = (0, react_1.useState)(null);
@@ -75,7 +75,7 @@ function Lesson(inProps) {
75
75
  setLessonId(l.id);
76
76
  setSectionId(s.id);
77
77
  setCurrentSection(s);
78
- onLessonChange && onLessonChange(l.id);
78
+ onLessonChange && onLessonChange(l.id, s.id);
79
79
  };
80
80
  /**
81
81
  * Handles Lesson Edit
@@ -1,4 +1,4 @@
1
- import { SCCourseLessonType } from '@selfcommunity/types';
1
+ import { SCCourseLessonType, SCCourseType } from '@selfcommunity/types';
2
2
  import { LessonAppbarProps, LessonDrawerProps } from '@selfcommunity/react-ui';
3
3
  export interface LessonProps {
4
4
  /**
@@ -6,6 +6,10 @@ export interface LessonProps {
6
6
  * @default null
7
7
  */
8
8
  className?: string;
9
+ /**
10
+ * The course object
11
+ */
12
+ course?: SCCourseType;
9
13
  /**
10
14
  * The course id
11
15
  */
@@ -47,7 +51,7 @@ export interface LessonProps {
47
51
  * Handler on lesson change
48
52
  * @default null
49
53
  */
50
- onLessonChange?: (id: any) => void;
54
+ onLessonChange?: (lessonId: any, sectionId: any) => void;
51
55
  /**
52
56
  * Any other properties
53
57
  */
@@ -34,13 +34,13 @@ export default function Lesson(inProps) {
34
34
  props: inProps,
35
35
  name: PREFIX
36
36
  });
37
- const { className = null, courseId, sectionId, lesson = null, lessonId, LessonAppbarProps = {}, LessonDrawerProps = {}, editMode = false, onEditModeClose = null, onLessonChange = null } = props, rest = __rest(props, ["className", "courseId", "sectionId", "lesson", "lessonId", "LessonAppbarProps", "LessonDrawerProps", "editMode", "onEditModeClose", "onLessonChange"]);
37
+ const { className = null, course, courseId, sectionId, lesson = null, lessonId, LessonAppbarProps = {}, LessonDrawerProps = {}, editMode = false, onEditModeClose = null, onLessonChange = null } = props, rest = __rest(props, ["className", "course", "courseId", "sectionId", "lesson", "lessonId", "LessonAppbarProps", "LessonDrawerProps", "editMode", "onEditModeClose", "onLessonChange"]);
38
38
  // HOOKS
39
39
  const theme = useTheme();
40
40
  const isMobile = useMediaQuery(theme.breakpoints.down('md'));
41
41
  const [_lessonId, setLessonId] = useState(lessonId);
42
42
  const [_sectionId, setSectionId] = useState(sectionId);
43
- const { scCourse } = useSCFetchCourse({ id: courseId, params: { view: editMode ? CourseInfoViewType.EDIT : CourseInfoViewType.USER } });
43
+ const { scCourse } = useSCFetchCourse({ id: courseId, course, params: { view: editMode ? CourseInfoViewType.EDIT : CourseInfoViewType.USER } });
44
44
  const { scLesson, setSCLesson } = useSCFetchLesson({ id: _lessonId, lesson, courseId, sectionId: _sectionId });
45
45
  // STATE
46
46
  const [activePanel, setActivePanel] = useState(null);
@@ -73,7 +73,7 @@ export default function Lesson(inProps) {
73
73
  setLessonId(l.id);
74
74
  setSectionId(s.id);
75
75
  setCurrentSection(s);
76
- onLessonChange && onLessonChange(l.id);
76
+ onLessonChange && onLessonChange(l.id, s.id);
77
77
  };
78
78
  /**
79
79
  * Handles Lesson Edit