UNPKG

@selfcommunity/react-templates

Version:

React Templates Components to integrate a Community created with SelfCommunity.

36 lines (35 loc) 1.36 kB
import { jsx as _jsx } from "react/jsx-runtime"; import { PREFIX } from './constants'; import { Box, styled, useThemeProps } from '@mui/material'; import { useSCFetchCourse } from '@selfcommunity/react-core'; import classNames from 'classnames'; import { CourseDashboard } from '@selfcommunity/react-ui'; import { CourseInfoViewType } from '@selfcommunity/api-services'; const classes = { root: `${PREFIX}-root` }; const Root = styled(Box, { name: PREFIX, slot: 'Root' })(() => ({})); export default function Course(inProps) { // PROPS const props = useThemeProps({ props: inProps, name: PREFIX }); const { id = 'course', className = null, course = null, courseId = null, viewDashboard } = props; // HOOKS const { scCourse, error } = useSCFetchCourse({ id: courseId, course, params: { view: viewDashboard ? CourseInfoViewType.DASHBOARD : CourseInfoViewType.USER } }); if (error) { return null; } if (viewDashboard) { return (_jsx(Root, Object.assign({ id: id, className: classNames(classes.root, className) }, { children: _jsx(CourseDashboard.Teacher, { course: scCourse }) }))); } return (_jsx(Root, Object.assign({ id: id, className: classNames(classes.root, className) }, { children: _jsx(CourseDashboard.Student, { course: scCourse }) }))); }