@selfcommunity/react-ui
Version:
React UI Components to integrate a Community created with SelfCommunity Platform.
45 lines (44 loc) • 1.84 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.formatLessonUrl = exports.getRouteParams = exports.getRouteName = void 0;
const course_1 = require("../../../types/course");
const types_1 = require("@selfcommunity/types");
const react_core_1 = require("@selfcommunity/react-core");
function formatLessonUrl(notificationObject) {
return {
id: notificationObject.course.id,
slug: notificationObject.course.slug,
section_id: notificationObject.comment.section_id,
lesson_id: notificationObject.comment.lesson_id
};
}
exports.formatLessonUrl = formatLessonUrl;
function formatCourseRequestsUrl(notificationObject) {
return {
id: notificationObject.course.id,
slug: notificationObject.course.slug,
tab: course_1.SCCourseEditTabType.REQUESTS
};
}
const getRouteName = (notificationObject) => {
switch (notificationObject.type) {
case types_1.SCNotificationTypologyType.USER_COMMENTED_A_COURSE_LESSON:
return react_core_1.SCRoutes.COURSE_LESSON_COMMENTS_ROUTE_NAME;
case types_1.SCNotificationTypologyType.USER_REQUESTED_TO_JOIN_COURSE:
return react_core_1.SCRoutes.COURSE_EDIT_ROUTE_NAME;
default:
return react_core_1.SCRoutes.COURSE_ROUTE_NAME;
}
};
exports.getRouteName = getRouteName;
const getRouteParams = (notificationObject) => {
switch (notificationObject.type) {
case types_1.SCNotificationTypologyType.USER_COMMENTED_A_COURSE_LESSON:
return formatLessonUrl(notificationObject);
case types_1.SCNotificationTypologyType.USER_REQUESTED_TO_JOIN_COURSE:
return formatCourseRequestsUrl(notificationObject);
default:
return notificationObject.course;
}
};
exports.getRouteParams = getRouteParams;