Skip to content

Commit

Permalink
fix: classes endpoint is called correctly after class creation
Browse files Browse the repository at this point in the history
  • Loading branch information
sergivalero20 committed Aug 27, 2024
1 parent d25ec34 commit 1d18533
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions src/features/Courses/AddClass/index.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import React, { useEffect, useState } from 'react';
import { useDispatch, useSelector } from 'react-redux';
import { useParams } from 'react-router-dom';
import PropTypes from 'prop-types';

import {
Expand All @@ -23,7 +22,6 @@ import 'features/Courses/AddClass/index.scss';
const AddClass = ({
isOpen, onClose, courseInfo, isCoursePage, isEditing, isDetailClassPage,
}) => {
const { courseName } = useParams();
const dispatch = useDispatch();
const selectedInstitution = useSelector((state) => state.main.selectedInstitution);
const instructorsList = useSelector((state) => state.instructors.selectOptions.data);
Expand All @@ -37,8 +35,6 @@ const AddClass = ({
const [startDate, setStartDate] = useState('');
const [endDate, setEndDate] = useState('');

const courseNameDecoded = courseName ? decodeURIComponent(courseName) : '';

const handleAddClass = async (e) => {
e.preventDefault();
const form = e.target;
Expand All @@ -61,9 +57,9 @@ const AddClass = ({
logError(error);
} finally {
if (isDetailClassPage) {
dispatch(fetchAllClassesData(selectedInstitution.id, courseNameDecoded));
dispatch(fetchAllClassesData(selectedInstitution.id, courseInfo.masterCourseId));
} else {
dispatch(fetchClassesData(selectedInstitution.id, initialPage, courseNameDecoded));
dispatch(fetchClassesData(selectedInstitution.id, initialPage, courseInfo.masterCourseId));
dispatch(updateClassesCurrentPage(initialPage));
}
}
Expand All @@ -87,7 +83,7 @@ const AddClass = ({
dispatch(fetchCoursesData(selectedInstitution.id, initialPage));
dispatch(updateCoursesCurrentPage(initialPage));
} else {
dispatch(fetchClassesData(selectedInstitution.id, initialPage, courseNameDecoded));
dispatch(fetchClassesData(selectedInstitution.id, initialPage, courseInfo.masterCourseId));
dispatch(updateClassesCurrentPage(initialPage));
}
}
Expand Down

0 comments on commit 1d18533

Please sign in to comment.