@selfcommunity/react-ui 0.10.2-courses.127 → 0.10.2-courses.129

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,7 +1,7 @@
1
1
  /// <reference types="react" />
2
2
  import { SCCourseType } from '@selfcommunity/types';
3
3
  interface HeaderCourseDashboardProps {
4
- course: SCCourseType | null;
4
+ course: SCCourseType;
5
5
  hasAction?: boolean;
6
6
  }
7
7
  declare function HeaderCourseDashboard(props: HeaderCourseDashboardProps): JSX.Element;
@@ -7,6 +7,7 @@ const react_intl_1 = require("react-intl");
7
7
  const constants_1 = require("./constants");
8
8
  const react_1 = require("react");
9
9
  const react_core_1 = require("@selfcommunity/react-core");
10
+ const types_2 = require("../../types");
10
11
  const classes = {
11
12
  header: `${constants_1.PREFIX}-header`,
12
13
  img: `${constants_1.PREFIX}-header-img`,
@@ -14,6 +15,13 @@ const classes = {
14
15
  innerWrapper: `${constants_1.PREFIX}-header-inner-wrapper`,
15
16
  iconWrapper: `${constants_1.PREFIX}-header-icon-wrapper`
16
17
  };
18
+ function getUrlEditDashboard(course) {
19
+ return {
20
+ id: course.id,
21
+ slug: course.slug,
22
+ tab: types_2.SCCourseEditTabType.LESSONS
23
+ };
24
+ }
17
25
  function HeaderCourseDashboard(props) {
18
26
  // PROPS
19
27
  const { course, hasAction = false } = props;
@@ -22,7 +30,7 @@ function HeaderCourseDashboard(props) {
22
30
  // HOOKS
23
31
  const intl = (0, react_intl_1.useIntl)();
24
32
  const iconData = (0, react_1.useMemo)(() => {
25
- const underId = (course === null || course === void 0 ? void 0 : course.privacy) === types_1.SCCoursePrivacyType.DRAFT ? 'draft' : course === null || course === void 0 ? void 0 : course.privacy;
33
+ const underId = course.privacy === types_1.SCCoursePrivacyType.DRAFT ? 'draft' : course.privacy;
26
34
  return [
27
35
  {
28
36
  id: 'ui.course.label',
@@ -34,7 +42,7 @@ function HeaderCourseDashboard(props) {
34
42
  id: 'ui.course.type',
35
43
  icon: 'courses',
36
44
  key: 'typeOfCourse',
37
- underId: `ui.course.type.${course === null || course === void 0 ? void 0 : course.type}`
45
+ underId: `ui.course.type.${course.type}`
38
46
  }
39
47
  ];
40
48
  }, [course]);
@@ -43,6 +51,6 @@ function HeaderCourseDashboard(props) {
43
51
  id: data.underId,
44
52
  defaultMessage: data.underId
45
53
  })
46
- } }) }))] }), i))) })), hasAction && ((0, jsx_runtime_1.jsx)(material_1.Button, Object.assign({ component: react_core_1.Link, to: scRoutingContext.url(react_core_1.SCRoutes.COURSE_EDIT_ROUTE_NAME, course), size: "small", color: "primary", variant: "contained" }, { children: (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "body2" }, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.course.dashboard.teacher.btn.label", defaultMessage: "ui.course.dashboard.teacher.btn.label" }) })) })))] }))] })));
54
+ } }) }))] }), i))) })), hasAction && ((0, jsx_runtime_1.jsx)(material_1.Button, Object.assign({ component: react_core_1.Link, to: scRoutingContext.url(react_core_1.SCRoutes.COURSE_EDIT_ROUTE_NAME, getUrlEditDashboard(course)), size: "small", color: "primary", variant: "contained" }, { children: (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "body2" }, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.course.dashboard.teacher.btn.label", defaultMessage: "ui.course.dashboard.teacher.btn.label" }) })) })))] }))] })));
47
55
  }
48
56
  exports.default = (0, react_1.memo)(HeaderCourseDashboard);
@@ -1,7 +1,7 @@
1
1
  /// <reference types="react" />
2
2
  import { SCCourseEditTabType } from '../../types';
3
3
  interface EditCourseSkeletonProps {
4
- tab: SCCourseEditTabType;
4
+ tab?: SCCourseEditTabType;
5
5
  }
6
6
  declare function EditCourseSkeleton(props: EditCourseSkeletonProps): JSX.Element;
7
7
  declare const _default: import("react").MemoExoticComponent<typeof EditCourseSkeleton>;
@@ -16,7 +16,7 @@ const useDisabled = () => {
16
16
  return () => {
17
17
  updateDragStatus.current && pubsub_js_1.default.unsubscribe(updateDragStatus.current);
18
18
  };
19
- }, []);
19
+ }, [setIsDisabled]);
20
20
  return { isDisabled };
21
21
  };
22
22
  exports.useDisabled = useDisabled;
@@ -1,7 +1,7 @@
1
1
  /// <reference types="react" />
2
2
  import { SCCourseType } from '@selfcommunity/types';
3
3
  interface HeaderCourseDashboardProps {
4
- course: SCCourseType | null;
4
+ course: SCCourseType;
5
5
  hasAction?: boolean;
6
6
  }
7
7
  declare function HeaderCourseDashboard(props: HeaderCourseDashboardProps): JSX.Element;
@@ -5,6 +5,7 @@ import { FormattedMessage, useIntl } from 'react-intl';
5
5
  import { PREFIX } from './constants';
6
6
  import { memo, useMemo } from 'react';
7
7
  import { Link, SCRoutes, useSCRouting } from '@selfcommunity/react-core';
8
+ import { SCCourseEditTabType } from '../../types';
8
9
  const classes = {
9
10
  header: `${PREFIX}-header`,
10
11
  img: `${PREFIX}-header-img`,
@@ -12,6 +13,13 @@ const classes = {
12
13
  innerWrapper: `${PREFIX}-header-inner-wrapper`,
13
14
  iconWrapper: `${PREFIX}-header-icon-wrapper`
14
15
  };
16
+ function getUrlEditDashboard(course) {
17
+ return {
18
+ id: course.id,
19
+ slug: course.slug,
20
+ tab: SCCourseEditTabType.LESSONS
21
+ };
22
+ }
15
23
  function HeaderCourseDashboard(props) {
16
24
  // PROPS
17
25
  const { course, hasAction = false } = props;
@@ -20,7 +28,7 @@ function HeaderCourseDashboard(props) {
20
28
  // HOOKS
21
29
  const intl = useIntl();
22
30
  const iconData = useMemo(() => {
23
- const underId = (course === null || course === void 0 ? void 0 : course.privacy) === SCCoursePrivacyType.DRAFT ? 'draft' : course === null || course === void 0 ? void 0 : course.privacy;
31
+ const underId = course.privacy === SCCoursePrivacyType.DRAFT ? 'draft' : course.privacy;
24
32
  return [
25
33
  {
26
34
  id: 'ui.course.label',
@@ -32,7 +40,7 @@ function HeaderCourseDashboard(props) {
32
40
  id: 'ui.course.type',
33
41
  icon: 'courses',
34
42
  key: 'typeOfCourse',
35
- underId: `ui.course.type.${course === null || course === void 0 ? void 0 : course.type}`
43
+ underId: `ui.course.type.${course.type}`
36
44
  }
37
45
  ];
38
46
  }, [course]);
@@ -41,6 +49,6 @@ function HeaderCourseDashboard(props) {
41
49
  id: data.underId,
42
50
  defaultMessage: data.underId
43
51
  })
44
- } }) }))] }), i))) })), hasAction && (_jsx(Button, Object.assign({ component: Link, to: scRoutingContext.url(SCRoutes.COURSE_EDIT_ROUTE_NAME, course), size: "small", color: "primary", variant: "contained" }, { children: _jsx(Typography, Object.assign({ variant: "body2" }, { children: _jsx(FormattedMessage, { id: "ui.course.dashboard.teacher.btn.label", defaultMessage: "ui.course.dashboard.teacher.btn.label" }) })) })))] }))] })));
52
+ } }) }))] }), i))) })), hasAction && (_jsx(Button, Object.assign({ component: Link, to: scRoutingContext.url(SCRoutes.COURSE_EDIT_ROUTE_NAME, getUrlEditDashboard(course)), size: "small", color: "primary", variant: "contained" }, { children: _jsx(Typography, Object.assign({ variant: "body2" }, { children: _jsx(FormattedMessage, { id: "ui.course.dashboard.teacher.btn.label", defaultMessage: "ui.course.dashboard.teacher.btn.label" }) })) })))] }))] })));
45
53
  }
46
54
  export default memo(HeaderCourseDashboard);
@@ -1,7 +1,7 @@
1
1
  /// <reference types="react" />
2
2
  import { SCCourseEditTabType } from '../../types';
3
3
  interface EditCourseSkeletonProps {
4
- tab: SCCourseEditTabType;
4
+ tab?: SCCourseEditTabType;
5
5
  }
6
6
  declare function EditCourseSkeleton(props: EditCourseSkeletonProps): JSX.Element;
7
7
  declare const _default: import("react").MemoExoticComponent<typeof EditCourseSkeleton>;
@@ -12,6 +12,6 @@ export const useDisabled = () => {
12
12
  return () => {
13
13
  updateDragStatus.current && PubSub.unsubscribe(updateDragStatus.current);
14
14
  };
15
- }, []);
15
+ }, [setIsDisabled]);
16
16
  return { isDisabled };
17
17
  };