filterpage render fixed

This commit is contained in:
Harikrishnan Gopal
2025-04-15 20:43:39 +05:30
parent 7aad05fb7a
commit 59c12d6668

View File

@@ -6,7 +6,7 @@ import Navbar from "./Navbar";
import { toast, ToastContainer } from "react-toastify";
import "react-toastify/dist/ReactToastify.css";
const FilterPage = () => {
const FilterPage = ({ setCourses }) => {
const currentYear = new Date().getFullYear();
// Load saved filters from localStorage or set default values
@@ -53,12 +53,18 @@ const FilterPage = () => {
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", {
state: {
courses: filteredCourses,
academicYear: formData.academicYear,
},
});
}
} else {
toast.error("No courses found for the selected filters.");
}