Skip to content

Commit

Permalink
fix: show all courses for Global Admin and filtered courses for IA.
Browse files Browse the repository at this point in the history
  • Loading branch information
anfbermudezme committed Dec 12, 2023
1 parent fe40370 commit 1e39ccb
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 16 deletions.
8 changes: 3 additions & 5 deletions src/features/Courses/CoursesPage/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ const CoursesPage = () => {
const [currentPage, setCurrentPage] = useState(1);
const [filters, setFilters] = useState({});

let id = 0;
if (stateInstitution.length > 0) {
let id = '';
if (stateInstitution.length === 1) {
id = stateInstitution[0].id;
}

Expand All @@ -52,9 +52,7 @@ const CoursesPage = () => {
};

useEffect(() => {
if (id > 0) {
fetchData(filters);
}
fetchData(filters);
}, [currentPage, id, filters]); // eslint-disable-line react-hooks/exhaustive-deps

const handlePagination = (targetPage) => {
Expand Down
8 changes: 3 additions & 5 deletions src/features/Instructors/InstructorsFilters/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ const InstructorsFilters = ({ fetchData, resetPagination, setFilters }) => {
const [instructorEmail, setInstructorEmail] = useState('');
const [courseSelected, setCourseSelected] = useState(null);
// check this after implementation of selector institution
let id = 0;
if (stateInstitution.length > 0) {
let id = '';
if (stateInstitution.length === 1) {
id = stateInstitution[0].id;
}

Expand Down Expand Up @@ -74,9 +74,7 @@ const InstructorsFilters = ({ fetchData, resetPagination, setFilters }) => {
};

useEffect(() => {
if (id > 0) {
fetchCoursesData();
} // eslint-disable-next-line react-hooks/exhaustive-deps
fetchCoursesData(); // eslint-disable-next-line react-hooks/exhaustive-deps
}, [id]);

useEffect(() => {
Expand Down
8 changes: 3 additions & 5 deletions src/features/Students/StudentsFilters/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ const StudentsFilters = ({ resetPagination, fetchData, setFilters }) => {
const [statusSelected, setStatusSelected] = useState(null);
const [examSelected, setExamSelected] = useState(null);
// check this after implementation of selector institution
let id = 0;
if (stateInstitution.length > 0) {
let id = '';
if (stateInstitution.length === 1) {
id = stateInstitution[0].id;
}

Expand Down Expand Up @@ -87,9 +87,7 @@ const StudentsFilters = ({ resetPagination, fetchData, setFilters }) => {
};

useEffect(() => {
if (id > 0) {
fetchCoursesData();
} // eslint-disable-next-line react-hooks/exhaustive-deps
fetchCoursesData(); // eslint-disable-next-line react-hooks/exhaustive-deps
}, [id]);

useEffect(() => {
Expand Down
4 changes: 3 additions & 1 deletion src/features/Students/data/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,11 @@ function handleEnrollments(data, courseId) {
}

function getClassesByInstitution(institutionId, courseName) {
const encodedCourseName = encodeURIComponent(courseName);

return getAuthenticatedHttpClient().get(
`${getConfig().COURSE_OPERATIONS_API_V2_BASE_URL}/classes`
+ `/?limit=false&institution_id=${institutionId}&course_name=${courseName}`,
+ `/?limit=false&institution_id=${institutionId}&course_name=${encodedCourseName}`,
);
}

Expand Down

0 comments on commit 1e39ccb

Please sign in to comment.