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 Dec 4, 2023
1 parent 6eb39df commit 2257bdb
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 9 deletions.
33 changes: 33 additions & 0 deletions @
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
pick cc4964d (IrfanUddinAhmad <irfanahmad@arbisoft.com>) feat: ENT-7851 Added course section title for learners's first visit
f 0efcace (IrfanUddinAhmad <irfanahmad@arbisoft.com>) fff

# Rebase 6eb39df..0efcace onto 6eb39df (2 commands)
#
# Commands:
# p, pick <commit> = use commit
# r, reword <commit> = use commit, but edit the commit message
# e, edit <commit> = use commit, but stop for amending
# s, squash <commit> = use commit, but meld into previous commit
# f, fixup [-C | -c] <commit> = like "squash" but keep only the previous
# commit's log message, unless -C is used, in which case
# keep only this commit's message; -c is same as -C but
# opens the editor
# x, exec <command> = run command (the rest of the line) using shell
# b, break = stop here (continue rebase later with 'git rebase --continue')
# d, drop <commit> = remove commit
# l, label <label> = label current HEAD with a name
# t, reset <label> = reset HEAD to a label
# m, merge [-C <commit> | -c <commit>] <label> [# <oneline>]
# create a merge commit using the original merge commit's
# message (or the oneline, if no original merge commit was
# specified); use -c <commit> to reword the commit message
# u, update-ref <ref> = track a placeholder for the <ref> to be updated
# to this position in the new commits. The <ref> is
# updated at the end of the rebase
#
# These lines can be re-ordered; they are executed from top to bottom.
#
# If you remove a line here THAT COMMIT WILL BE LOST.
#
# However, if you remove everything, the rebase will be aborted.
#
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,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 @@ -16,12 +17,8 @@ import {
import { UserSubsidyContext } from '../../../enterprise-user-subsidy';
import { features } from '../../../../config';

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';

export const ASSIGNMENT_TYPES = {
accepted: 'accepted',
allocated: 'allocated',
Expand Down Expand Up @@ -49,6 +46,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 +149,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={assignedCourses}
/>
)}
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 || COURSE_SECTION_TITLES.firstTimeUserAndAssigned) {
return <sup><Badge variant="danger" className="rounded-circle">{coursesCount}</Badge></sup>;
}
return `(${coursesCount})`;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ import userEvent from '@testing-library/user-event';
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 2257bdb

Please sign in to comment.