Skip to content

Commit

Permalink
Merge pull request #95 from Pearson-Advance/vue/PADV-1412
Browse files Browse the repository at this point in the history
PADV-1412 - Fix course details link
  • Loading branch information
sergivalero20 authored Jun 19, 2024
2 parents 8df2c99 + 480a21a commit c5c9311
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
10 changes: 5 additions & 5 deletions src/features/Courses/CourseDetailTable/__test__/columns.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ describe('columns', () => {
});

renderWithProviders(
<MemoryRouter initialEntries={['/courses/Demo%20Course%201']}>
<MemoryRouter initialEntries={['/courses/course-v1:USB+CDDD+2023']}>
<Route path="/courses/:courseId">
<Component />
</Route>
Expand All @@ -73,7 +73,7 @@ describe('columns', () => {
const linkElement = screen.getByText('Class example');
expect(linkElement).toBeInTheDocument();
expect(linkElement).toHaveClass('text-truncate link');
expect(linkElement).toHaveAttribute('href', '/courses/Demo Course 1/Class example?classId=class id&previous=courses');
expect(linkElement).toHaveAttribute('href', '/courses/course-v1:USB+CDDD+2023/Class example?classId=class id&previous=courses');
});

test('Should render the dates', () => {
Expand Down Expand Up @@ -156,7 +156,7 @@ describe('columns', () => {
};

const component = renderWithProviders(
<MemoryRouter initialEntries={['/courses/Demo%20Course%201']}>
<MemoryRouter initialEntries={['/courses/course-v1:USB+CDDD+2023']}>
<Route path="/courses/:courseId">
<Component />
</Route>
Expand Down Expand Up @@ -210,7 +210,7 @@ describe('columns', () => {
};

const component = renderWithProviders(
<MemoryRouter initialEntries={['/courses/Demo%20Course%201']}>
<MemoryRouter initialEntries={['/courses/course-v1:USB+CDDD+2023']}>
<Route path="/courses/:courseId">
<ComponentNoInstructor />
</Route>
Expand Down Expand Up @@ -255,7 +255,7 @@ describe('columns', () => {
};

const component = renderWithProviders(
<MemoryRouter initialEntries={['/courses/Demo%20Course%201']}>
<MemoryRouter initialEntries={['/courses/course-v1:USB+CDDD+2023']}>
<Route path="/courses/:courseId">
<Component />
</Route>
Expand Down
10 changes: 5 additions & 5 deletions src/features/Courses/CoursesDetailPage/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,15 @@ const CoursesDetailPage = () => {
numberOfStudents: '-',
numberOfPendingStudents: '-',
masterCourseId: '-',
masterCourseName: '-',
};

const courseInfo = useSelector((state) => state.courses.table.data)
.find((course) => course?.masterCourseName === courseId) || defaultCourseInfo;
.find((course) => course?.masterCourseId === courseId) || defaultCourseInfo;
const institution = useSelector((state) => state.main.selectedInstitution);
const classes = useSelector((state) => state.classes.table);
const totalStudents = courseInfo.numberOfStudents + courseInfo.numberOfPendingStudents;
const courseDetailsLink = `${getConfig().LEARNING_MICROFRONTEND_URL}/course/${courseInfo.masterCourseId}/home`;

const handlePagination = (targetPage) => {
setCurrentPage(targetPage);
dispatch(updateCurrentPage(targetPage));
Expand All @@ -51,18 +51,18 @@ const CoursesDetailPage = () => {
};

if (institution.id) {
dispatch(fetchClassesData(institution.id, initialPage, courseId));
dispatch(fetchClassesData(institution.id, initialPage, courseInfo.masterCourseName));
dispatch(fetchCoursesData(institution.id, initialPage, null));
}

return () => {
dispatch(fetchCoursesDataSuccess(initialState));
dispatch(fetchClassesDataSuccess(initialState));
};
}, [dispatch, institution.id, courseId]);
}, [dispatch, institution.id, courseId]); // eslint-disable-line react-hooks/exhaustive-deps

useEffect(() => {
dispatch(fetchClassesData(institution.id, currentPage, courseId));
dispatch(fetchClassesData(institution.id, currentPage, courseInfo.masterCourseName));
}, [currentPage]); // eslint-disable-line react-hooks/exhaustive-deps

useEffect(() => {
Expand Down
2 changes: 1 addition & 1 deletion src/features/Courses/CoursesTable/columns.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const columns = [
{
Header: 'Courses',
accessor: 'masterCourseName',
Cell: ({ row }) => (<Link to={`/courses/${row.values.masterCourseName}`} className="link">{row.values.masterCourseName}</Link>),
Cell: ({ row }) => (<Link to={`/courses/${row.original.masterCourseId}`} className="link">{row.values.masterCourseName}</Link>),
},
{
Header: 'Classes',
Expand Down
2 changes: 1 addition & 1 deletion src/features/Licenses/LicenseDetailTable/columns.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const columns = [
Header: 'Course',
accessor: 'masterCourseName',
Cell: ({ row }) => (
<Link to={`/courses/${row.values.masterCourseName}`} className="link">{row.values.masterCourseName}</Link>
<Link to={`/courses/${row.original.masterCourseId}`} className="link">{row.values.masterCourseName}</Link>
),
},
{
Expand Down

0 comments on commit c5c9311

Please sign in to comment.