Skip to content

Commit

Permalink
CHE-144 Some temporary state handling for loading/errors until migrat…
Browse files Browse the repository at this point in the history
…ed to Redux
  • Loading branch information
brok3turtl3 committed Jun 4, 2024
1 parent 019cf4b commit d0efa8d
Showing 1 changed file with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,13 @@ const ApplicationDashboard = (): JSX.Element => {
const [applicationsByStatus, setApplicationsByStatus] = useState<
IStatusCount[]
>([]);
const [loading, setLoading] = useState(false);
const [error, setError] = useState<string | null>(null);
const user = useAppSelector((state) => state.user.userData);

useEffect(() => {
async function fetchAggregatedData() {
setLoading(true);
try {
const response = await axios.get(
`/api/applications/aggregated-user-stats/${user?._id}`
Expand All @@ -24,8 +27,12 @@ const ApplicationDashboard = (): JSX.Element => {
response.data || {};
setTotalApplications(totalApplications);
setApplicationsByStatus(applicationsByStatus);
} catch (error) {
setLoading(false);
} catch (err) {
const error = err as Error;
console.error("Error fetching aggregated data:", error);
setError(error.message);
setLoading(false);
}
}

Expand Down

0 comments on commit d0efa8d

Please sign in to comment.