@selfcommunity/react-templates
Version:
React Templates Components to integrate a Community created with SelfCommunity.
40 lines (39 loc) • 1.75 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
const jsx_runtime_1 = require("react/jsx-runtime");
const constants_1 = require("./constants");
const material_1 = require("@mui/material");
const react_core_1 = require("@selfcommunity/react-core");
const classnames_1 = tslib_1.__importDefault(require("classnames"));
const react_ui_1 = require("@selfcommunity/react-ui");
const api_services_1 = require("@selfcommunity/api-services");
const classes = {
root: `${constants_1.PREFIX}-root`
};
const Root = (0, material_1.styled)(material_1.Box, {
name: constants_1.PREFIX,
slot: 'Root'
})(() => ({}));
function Course(inProps) {
// PROPS
const props = (0, material_1.useThemeProps)({
props: inProps,
name: constants_1.PREFIX
});
const { id = 'course', className = null, course = null, courseId = null, viewDashboard } = props;
// HOOKS
const { scCourse, error } = (0, react_core_1.useSCFetchCourse)({
id: courseId,
course,
params: { view: viewDashboard ? api_services_1.CourseInfoViewType.DASHBOARD : api_services_1.CourseInfoViewType.USER }
});
if (error) {
return null;
}
if (viewDashboard) {
return ((0, jsx_runtime_1.jsx)(Root, Object.assign({ id: id, className: (0, classnames_1.default)(classes.root, className) }, { children: (0, jsx_runtime_1.jsx)(react_ui_1.CourseDashboard.Teacher, { course: scCourse }) })));
}
return ((0, jsx_runtime_1.jsx)(Root, Object.assign({ id: id, className: (0, classnames_1.default)(classes.root, className) }, { children: (0, jsx_runtime_1.jsx)(react_ui_1.CourseDashboard.Student, { course: scCourse }) })));
}
exports.default = Course;