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 { 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)
); );
navigate("/courses", { // Update courses if setCourses is passed as a prop (from CourseTable)
state: { if (setCourses) {
courses: filteredCourses, setCourses(filteredCourses);
academicYear: formData.academicYear, } else {
}, // Navigate to the courses page without updating the parent state
}); navigate("/courses", {
state: {
courses: filteredCourses,
academicYear: formData.academicYear,
},
});
}
} else { } else {
toast.error("No courses found for the selected filters."); toast.error("No courses found for the selected filters.");
} }