filterpage render fixed
This commit is contained in:
@@ -6,7 +6,7 @@ import Navbar from "./Navbar";
|
|||||||
import { toast, ToastContainer } from "react-toastify";
|
import { toast, ToastContainer } from "react-toastify";
|
||||||
import "react-toastify/dist/ReactToastify.css";
|
import "react-toastify/dist/ReactToastify.css";
|
||||||
|
|
||||||
const FilterPage = () => {
|
const FilterPage = ({ setCourses }) => {
|
||||||
const currentYear = new Date().getFullYear();
|
const currentYear = new Date().getFullYear();
|
||||||
|
|
||||||
// Load saved filters from localStorage or set default values
|
// Load saved filters from localStorage or set default values
|
||||||
@@ -53,12 +53,18 @@ const FilterPage = () => {
|
|||||||
JSON.stringify(filteredCourses)
|
JSON.stringify(filteredCourses)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// Update courses if setCourses is passed as a prop (from CourseTable)
|
||||||
|
if (setCourses) {
|
||||||
|
setCourses(filteredCourses);
|
||||||
|
} else {
|
||||||
|
// Navigate to the courses page without updating the parent state
|
||||||
navigate("/courses", {
|
navigate("/courses", {
|
||||||
state: {
|
state: {
|
||||||
courses: filteredCourses,
|
courses: filteredCourses,
|
||||||
academicYear: formData.academicYear,
|
academicYear: formData.academicYear,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
toast.error("No courses found for the selected filters.");
|
toast.error("No courses found for the selected filters.");
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user