Loading...
-{error}
diff --git a/src/pages/dashboard/MangeFinancialAidRequests.jsx b/src/pages/dashboard/MangeFinancialAidRequests.jsx new file mode 100644 index 0000000..062e59e --- /dev/null +++ b/src/pages/dashboard/MangeFinancialAidRequests.jsx @@ -0,0 +1,107 @@ +import { useEffect, useState } from "react"; +import { useSelector } from "react-redux"; +import { customFetch } from "../../utils/customFetch"; + +import { + PageIntro, + PageContainer, + FinancialAidRequestHeader, + FinancialAidRequestElement, + Pagination, +} from "../../components"; + +const MangeFinancialAidRequests = () => { + const { token } = useSelector((state) => state.userReducers); + const [financialAidRequests, setFinancialAidRequests] = useState([]); + const [loading, setLoading] = useState(true); + const [error, setError] = useState(null); + const [isChanged, setIsChanged] = useState(false); + const [currentPage, setCurrentPage] = useState(1); + const [itemsPerPage, setItemsPerPage] = useState(15); + const [isMorePages, setIsMorePages] = useState(false); + + useEffect(() => { + const fetchFinancialAidRequests = async () => { + setLoading(true); + setError(null); + try { + const response = await customFetch.get( + "admin/getAllFinancialAidRequests", + { + headers: { + Authorization: `Bearer ${token}`, + }, + params: { + page: currentPage, + limit: itemsPerPage, + }, + } + ); + + const fetchedFinancialAidsApplications = + response.data.data.financialAidRequests; + + if (fetchedFinancialAidsApplications.length < itemsPerPage) { + setIsMorePages(false); + } else { + setIsMorePages(true); + } + + setFinancialAidRequests(fetchedFinancialAidsApplications); + } catch (error) { + setError( + error.message || "Failed to fetch Financial Aids Applications " + ); + } finally { + setLoading(false); + setIsChanged(false); + } + }; + + fetchFinancialAidRequests(); + }, [token, isChanged, currentPage, itemsPerPage]); + + return ( +{error}
++ No Financial Aid Requests were requested +
+