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 Nov 28, 2023
1 parent 6eb39df commit 12585c8
Showing 1 changed file with 13 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React, {
useContext, useEffect, useMemo, useState,
} from 'react';
import Cookies from 'universal-cookie';

import PropTypes from 'prop-types';
import { AppContext } from '@edx/frontend-platform/react';
Expand All @@ -21,6 +22,7 @@ export const COURSE_SECTION_TITLES = {
completed: 'Completed courses',
savedForLater: 'Saved for later',
assigned: 'Assigned Courses',
firstTimeUserAndAssigned: 'Your learning journey starts now!',
};
export const ASSIGNMENT_TYPES = {
accepted: 'accepted',
Expand Down Expand Up @@ -49,6 +51,16 @@ const CourseEnrollments = ({ children }) => {
const [assignments, setAssignments] = useState([]);
const [showCancelledAssignmentsAlert, setShowCancelledAssignmentsAlert] = useState(false);
const [showExpiredAssignmentsAlert, setShowExpiredAssignmentsAlert] = useState(false);
const [isFirstVisit, setIsFirstVisit] = useState(false);

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

useEffect(() => {
const data = redeemableLearnerCreditPolicies?.flatMap(item => item?.learnerContentAssignments || []);
Expand Down Expand Up @@ -142,7 +154,7 @@ const CourseEnrollments = ({ children }) => {
<>
{features.FEATURE_ENABLE_TOP_DOWN_ASSIGNMENT && (
<CourseSection

Check warning on line 156 in src/components/dashboard/main-content/course-enrollments/CourseEnrollments.jsx

View check run for this annotation

Codecov / codecov/patch

src/components/dashboard/main-content/course-enrollments/CourseEnrollments.jsx#L156

Added line #L156 was not covered by tests
title={COURSE_SECTION_TITLES.assigned}
title={isFirstVisit ? COURSE_SECTION_TITLES.firstTimeUserAndAssigned : COURSE_SECTION_TITLES.assigned}
courseRuns={assignedCourses}
/>
)}
Expand Down

0 comments on commit 12585c8

Please sign in to comment.