Skip to content

Commit

Permalink
chore: address comments
Browse files Browse the repository at this point in the history
  • Loading branch information
sergivalero20 committed Dec 12, 2024
1 parent ebe2edd commit 9da4931
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 9 deletions.
10 changes: 8 additions & 2 deletions src/features/Instructors/InstructorsPage/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,19 @@ const InstructorsPage = () => {

useEffect(() => {
if (Object.keys(selectedInstitution).length > 0) {
dispatch(fetchInstructorsData(selectedInstitution.id, currentPage, stateInstructors.filters));
dispatch(fetchInstructorsData(selectedInstitution.id, initialPage));
}

return () => {
dispatch(resetInstructorsRequest());
};
}, [selectedInstitution, dispatch, currentPage]); // eslint-disable-line react-hooks/exhaustive-deps
}, [selectedInstitution, dispatch]); // eslint-disable-line react-hooks/exhaustive-deps

useEffect(() => {
if (Object.keys(selectedInstitution).length > 0) {
dispatch(fetchInstructorsData(selectedInstitution.id, currentPage, stateInstructors.filters));
}
}, [currentPage]); // eslint-disable-line react-hooks/exhaustive-deps

const handlePagination = (targetPage) => {
setCurrentPage(targetPage);
Expand Down
5 changes: 1 addition & 4 deletions src/features/Licenses/LicensesFilters/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,11 @@ const LicensesFilters = ({ resetPagination }) => {
const form = e.target;
const formData = new FormData(form);
const formJson = Object.fromEntries(formData.entries());
const urlParamsFilters = Object.entries(formJson)
.map(([key, value]) => `${key}=${encodeURIComponent(value)}`)
.join('&');

try {
dispatch(updateFilters(formJson));
dispatch(updateCurrentPage(initialPage));
dispatch(fetchLicensesData(institution.id, initialPage, urlParamsFilters));
dispatch(fetchLicensesData(institution.id, initialPage, formJson));
} catch (error) {
logError(error);
}
Expand Down
10 changes: 8 additions & 2 deletions src/features/Licenses/LicensesPage/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,17 @@ const LicensesPage = () => {

useEffect(() => {
if (Object.keys(selectedInstitution).length > 0) {
dispatch(fetchLicensesData(selectedInstitution?.id, currentPage, stateLicenses.filters));
dispatch(fetchLicensesData(selectedInstitution.id, initialPage));
}

return () => dispatch(resetLicensesTable());
}, [selectedInstitution, dispatch, currentPage]); // eslint-disable-line react-hooks/exhaustive-deps
}, [selectedInstitution, dispatch]); // eslint-disable-line react-hooks/exhaustive-deps

useEffect(() => {
if (Object.keys(selectedInstitution).length > 0) {
dispatch(fetchLicensesData(selectedInstitution.id, currentPage, stateLicenses.filters));
}
}, [currentPage]); // eslint-disable-line react-hooks/exhaustive-deps

return (
<Container size="xl" className="px-4">
Expand Down
8 changes: 7 additions & 1 deletion src/features/Students/StudentsPage/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,20 @@ const StudentsPage = () => {

useEffect(() => {
if (Object.keys(selectedInstitution).length > 0) {
dispatch(fetchStudentsData(selectedInstitution.id, currentPage, stateStudents.filters));
dispatch(fetchStudentsData(selectedInstitution.id, initialPage));
}

return () => {
dispatch(resetStudentsTable());
};
}, [selectedInstitution, dispatch]); // eslint-disable-line react-hooks/exhaustive-deps

useEffect(() => {
if (Object.keys(selectedInstitution).length > 0) {
dispatch(fetchStudentsData(selectedInstitution.id, currentPage, stateStudents.filters));
}
}, [currentPage]); // eslint-disable-line react-hooks/exhaustive-deps

const resetPagination = () => {
setCurrentPage(initialPage);
};
Expand Down

0 comments on commit 9da4931

Please sign in to comment.