Skip to content

Commit

Permalink
feat: ENT-7851 Added course section title for learners's first visit
Browse files Browse the repository at this point in the history
  • Loading branch information
IrfanUddinAhmad committed Jan 15, 2024
1 parent 5403d62 commit b72df26
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 10 deletions.
8 changes: 8 additions & 0 deletions src/components/dashboard/data/constants.js
Original file line number Diff line number Diff line change
@@ -1 +1,9 @@
export const LICENSE_ACTIVATION_MESSAGE = 'Your license was successfully activated.';

export const COURSE_SECTION_TITLES = {
current: 'My courses',
completed: 'Completed courses',
savedForLater: 'Saved for later',
assigned: 'Assigned Courses',
firstTimeUserAndAssigned: 'Your learning journey starts now!',
};
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
import React, { useContext } from 'react';
import React, {
useContext, useEffect, useState,
} from 'react';
import Cookies from 'universal-cookie';

import PropTypes from 'prop-types';

import CourseSection from './CourseSection';
Expand All @@ -9,12 +13,7 @@ import { features } from '../../../../config';
import { useCourseEnrollmentsBySection, useContentAssignments } from './data';
import { UserSubsidyContext } from '../../../enterprise-user-subsidy';

export const COURSE_SECTION_TITLES = {
current: 'My courses',
completed: 'Completed courses',
savedForLater: 'Saved for later',
assigned: 'Assigned Courses',
};
import { COURSE_SECTION_TITLES } from '../../data/constants';

const CourseEnrollments = ({ children }) => {
const { redeemableLearnerCreditPolicies } = useContext(UserSubsidyContext);
Expand Down Expand Up @@ -42,6 +41,16 @@ const CourseEnrollments = ({ children }) => {
courseEnrollmentsByStatus,
assignments,
});
const [isFirstVisit, setIsFirstVisit] = useState(false);

useEffect(() => {
const cookies = new Cookies();
const hasUserVisitedDashboard = cookies.get('has-user-seen-enrollments');
if (!hasUserVisitedDashboard) {
cookies.set('has-user-seen-enrollments', true, { path: '/' });
setIsFirstVisit(true);
}
}, []);

if (fetchCourseEnrollmentsError) {
return (
Expand Down Expand Up @@ -78,7 +87,7 @@ const CourseEnrollments = ({ children }) => {
<>
{features.FEATURE_ENABLE_TOP_DOWN_ASSIGNMENT && (
<CourseSection
title={COURSE_SECTION_TITLES.assigned}
title={isFirstVisit ? COURSE_SECTION_TITLES.firstTimeUserAndAssigned : COURSE_SECTION_TITLES.assigned}
courseRuns={assignments}
/>
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {

import { UpgradeableCourseEnrollmentContextProvider } from './UpgradeableCourseEnrollmentContextProvider';
import { COURSE_STATUSES, COURSE_MODES } from '../../../../constants';
import { COURSE_SECTION_TITLES } from '../../data/constants';

const CARD_COMPONENT_BY_COURSE_STATUS = {
[COURSE_STATUSES.upcoming]: UpcomingCourseCard,
Expand All @@ -35,7 +36,7 @@ class CourseSection extends React.Component {

getCoursesCount = (isOpen, title, coursesCount) => {
if (!isOpen) {
if (title === 'Assigned Courses') {
if (title === COURSE_SECTION_TITLES.assigned || title === COURSE_SECTION_TITLES.firstTimeUserAndAssigned) {
return <sup><Bubble variant="error">{coursesCount}</Bubble></sup>;
}
return `(${coursesCount})`;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ import userEvent from '@testing-library/user-event';

import { renderWithRouter } from '../../../../../utils/tests';
import { createCourseEnrollmentWithStatus } from './enrollment-testutils';
import CourseEnrollments, { COURSE_SECTION_TITLES } from '../CourseEnrollments';

import { COURSE_SECTION_TITLES } from '../../../data/constants';
import CourseEnrollments from '../CourseEnrollments';
import { MARK_MOVE_TO_IN_PROGRESS_DEFAULT_LABEL } from '../course-cards/move-to-in-progress-modal/MoveToInProgressModal';
import { MARK_SAVED_FOR_LATER_DEFAULT_LABEL } from '../course-cards/mark-complete-modal/MarkCompleteModal';
import { updateCourseCompleteStatusRequest } from '../course-cards/mark-complete-modal/data/service';
Expand Down

0 comments on commit b72df26

Please sign in to comment.