UNPKG

@selfcommunity/react-ui

Version:

React UI Components to integrate a Community created with SelfCommunity Platform.

40 lines (39 loc) 1.43 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.getUrlLesson = exports.getDripDelayAndUnit = exports.isCourseCompleted = exports.isCourseNew = void 0; const types_1 = require("@selfcommunity/types"); function isCourseNew(course) { if (course && course.join_status === types_1.SCCourseJoinStatusType.JOINED) { const createdAtDate = new Date(course.created_at); const twoWeeksAgo = new Date(); twoWeeksAgo.setDate(twoWeeksAgo.getDate() - 14); return createdAtDate >= twoWeeksAgo; } return false; } exports.isCourseNew = isCourseNew; function isCourseCompleted(course) { return (course === null || course === void 0 ? void 0 : course.user_completion_rate) === 100; } exports.isCourseCompleted = isCourseCompleted; var unitType; (function (unitType) { unitType["DAYS"] = "days"; unitType["WEEKS"] = "weeks"; })(unitType || (unitType = {})); function getDripDelayAndUnit(value) { if (value > 7 && value % 7 === 0) { return { delay: value / 7, _unit: unitType.WEEKS }; } return { delay: value, _unit: unitType.DAYS }; } exports.getDripDelayAndUnit = getDripDelayAndUnit; function getUrlLesson(course, lesson, section) { return { id: course.id, slug: course.slug, section_id: section ? section.id : lesson.section_id, lesson_id: lesson.id }; } exports.getUrlLesson = getUrlLesson;