@selfcommunity/react-ui 0.10.2-courses.126 → 0.10.2-courses.128

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;
@@ -12,6 +12,8 @@ const react_intl_1 = require("react-intl");
12
12
  const lab_1 = require("@mui/lab");
13
13
  const classes = {
14
14
  root: `${constants_1.PREFIX}-root`,
15
+ startItems: `${constants_1.PREFIX}-start-items`,
16
+ endItems: `${constants_1.PREFIX}-end-items`,
15
17
  title: `${constants_1.PREFIX}-title`
16
18
  };
17
19
  const Root = (0, styles_1.styled)(material_1.AppBar, {
@@ -27,6 +29,6 @@ function LessonAppbar(inProps) {
27
29
  name: constants_1.PREFIX
28
30
  });
29
31
  const { className = null, title = '', showComments, activePanel = null, handleOpen, onSave, editMode, onArrowBackClick, updating } = props, rest = tslib_1.__rest(props, ["className", "title", "showComments", "activePanel", "handleOpen", "onSave", "editMode", "onArrowBackClick", "updating"]);
30
- return ((0, jsx_runtime_1.jsx)(Root, Object.assign({ position: "fixed", open: Boolean(activePanel), className: (0, classnames_1.default)(classes.root, className) }, rest, { children: (0, jsx_runtime_1.jsxs)(material_1.Toolbar, { children: [(0, jsx_runtime_1.jsx)(material_1.IconButton, Object.assign({ edge: "start", onClick: onArrowBackClick }, { children: (0, jsx_runtime_1.jsx)(material_1.Icon, { children: "arrow_back" }) })), (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "h6", className: classes.title }, { children: title })), editMode ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(material_1.IconButton, Object.assign({ onClick: () => handleOpen(types_1.SCLessonActionsType.SETTINGS), color: "primary" }, { children: (0, jsx_runtime_1.jsx)(material_1.Icon, { children: "settings" }) })), (0, jsx_runtime_1.jsx)(lab_1.LoadingButton, Object.assign({ variant: "contained", size: "small", onClick: onSave, loading: updating }, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.lessonAppbar.button.save", defaultMessage: "ui.lessonAppbar.button.save" }) }))] })) : ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [showComments && ((0, jsx_runtime_1.jsx)(material_1.IconButton, Object.assign({ onClick: () => handleOpen(types_1.SCLessonActionsType.COMMENTS) }, { children: (0, jsx_runtime_1.jsx)(material_1.Icon, { children: "chat_bubble_outline" }) }))), (0, jsx_runtime_1.jsx)(material_1.IconButton, Object.assign({ onClick: () => handleOpen(types_1.SCLessonActionsType.LESSONS) }, { children: (0, jsx_runtime_1.jsx)(material_1.Icon, { children: "courses" }) }))] }))] }) })));
32
+ return ((0, jsx_runtime_1.jsx)(Root, Object.assign({ position: "fixed", open: Boolean(activePanel), className: (0, classnames_1.default)(classes.root, className) }, rest, { children: (0, jsx_runtime_1.jsxs)(material_1.Toolbar, { children: [(0, jsx_runtime_1.jsxs)(material_1.Box, Object.assign({ className: classes.startItems }, { children: [(0, jsx_runtime_1.jsx)(material_1.IconButton, Object.assign({ edge: "start", onClick: onArrowBackClick }, { children: (0, jsx_runtime_1.jsx)(material_1.Icon, { children: "arrow_back" }) })), (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "h6", className: classes.title }, { children: title }))] })), editMode ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(material_1.IconButton, Object.assign({ onClick: () => handleOpen(types_1.SCLessonActionsType.SETTINGS), color: "primary" }, { children: (0, jsx_runtime_1.jsx)(material_1.Icon, { children: "settings" }) })), (0, jsx_runtime_1.jsx)(lab_1.LoadingButton, Object.assign({ variant: "contained", size: "small", onClick: onSave, loading: updating }, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.lessonAppbar.button.save", defaultMessage: "ui.lessonAppbar.button.save" }) }))] })) : ((0, jsx_runtime_1.jsxs)(material_1.Box, Object.assign({ className: classes.endItems }, { children: [showComments && ((0, jsx_runtime_1.jsx)(material_1.IconButton, Object.assign({ onClick: () => handleOpen(types_1.SCLessonActionsType.COMMENTS) }, { children: (0, jsx_runtime_1.jsx)(material_1.Icon, { children: "chat_bubble_outline" }) }))), (0, jsx_runtime_1.jsx)(material_1.IconButton, Object.assign({ onClick: () => handleOpen(types_1.SCLessonActionsType.LESSONS) }, { children: (0, jsx_runtime_1.jsx)(material_1.Icon, { children: "courses" }) }))] })))] }) })));
31
33
  }
32
34
  exports.default = LessonAppbar;
@@ -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
  };
@@ -1,15 +1,17 @@
1
1
  import { __rest } from "tslib";
2
- import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
3
3
  import { styled } from '@mui/material/styles';
4
4
  import { useThemeProps } from '@mui/system';
5
5
  import classNames from 'classnames';
6
- import { AppBar, Icon, IconButton, Toolbar, Typography } from '@mui/material';
6
+ import { AppBar, Icon, IconButton, Toolbar, Typography, Box } from '@mui/material';
7
7
  import { PREFIX } from './constants';
8
8
  import { SCLessonActionsType } from '../../types';
9
9
  import { FormattedMessage } from 'react-intl';
10
10
  import { LoadingButton } from '@mui/lab';
11
11
  const classes = {
12
12
  root: `${PREFIX}-root`,
13
+ startItems: `${PREFIX}-start-items`,
14
+ endItems: `${PREFIX}-end-items`,
13
15
  title: `${PREFIX}-title`
14
16
  };
15
17
  const Root = styled(AppBar, {
@@ -25,5 +27,5 @@ export default function LessonAppbar(inProps) {
25
27
  name: PREFIX
26
28
  });
27
29
  const { className = null, title = '', showComments, activePanel = null, handleOpen, onSave, editMode, onArrowBackClick, updating } = props, rest = __rest(props, ["className", "title", "showComments", "activePanel", "handleOpen", "onSave", "editMode", "onArrowBackClick", "updating"]);
28
- return (_jsx(Root, Object.assign({ position: "fixed", open: Boolean(activePanel), className: classNames(classes.root, className) }, rest, { children: _jsxs(Toolbar, { children: [_jsx(IconButton, Object.assign({ edge: "start", onClick: onArrowBackClick }, { children: _jsx(Icon, { children: "arrow_back" }) })), _jsx(Typography, Object.assign({ variant: "h6", className: classes.title }, { children: title })), editMode ? (_jsxs(_Fragment, { children: [_jsx(IconButton, Object.assign({ onClick: () => handleOpen(SCLessonActionsType.SETTINGS), color: "primary" }, { children: _jsx(Icon, { children: "settings" }) })), _jsx(LoadingButton, Object.assign({ variant: "contained", size: "small", onClick: onSave, loading: updating }, { children: _jsx(FormattedMessage, { id: "ui.lessonAppbar.button.save", defaultMessage: "ui.lessonAppbar.button.save" }) }))] })) : (_jsxs(_Fragment, { children: [showComments && (_jsx(IconButton, Object.assign({ onClick: () => handleOpen(SCLessonActionsType.COMMENTS) }, { children: _jsx(Icon, { children: "chat_bubble_outline" }) }))), _jsx(IconButton, Object.assign({ onClick: () => handleOpen(SCLessonActionsType.LESSONS) }, { children: _jsx(Icon, { children: "courses" }) }))] }))] }) })));
30
+ return (_jsx(Root, Object.assign({ position: "fixed", open: Boolean(activePanel), className: classNames(classes.root, className) }, rest, { children: _jsxs(Toolbar, { children: [_jsxs(Box, Object.assign({ className: classes.startItems }, { children: [_jsx(IconButton, Object.assign({ edge: "start", onClick: onArrowBackClick }, { children: _jsx(Icon, { children: "arrow_back" }) })), _jsx(Typography, Object.assign({ variant: "h6", className: classes.title }, { children: title }))] })), editMode ? (_jsxs(_Fragment, { children: [_jsx(IconButton, Object.assign({ onClick: () => handleOpen(SCLessonActionsType.SETTINGS), color: "primary" }, { children: _jsx(Icon, { children: "settings" }) })), _jsx(LoadingButton, Object.assign({ variant: "contained", size: "small", onClick: onSave, loading: updating }, { children: _jsx(FormattedMessage, { id: "ui.lessonAppbar.button.save", defaultMessage: "ui.lessonAppbar.button.save" }) }))] })) : (_jsxs(Box, Object.assign({ className: classes.endItems }, { children: [showComments && (_jsx(IconButton, Object.assign({ onClick: () => handleOpen(SCLessonActionsType.COMMENTS) }, { children: _jsx(Icon, { children: "chat_bubble_outline" }) }))), _jsx(IconButton, Object.assign({ onClick: () => handleOpen(SCLessonActionsType.LESSONS) }, { children: _jsx(Icon, { children: "courses" }) }))] })))] }) })));
29
31
  }