diff --git a/src/app/page.tsx b/src/app/page.tsx index fe48a3f..2ee7112 100644 --- a/src/app/page.tsx +++ b/src/app/page.tsx @@ -48,17 +48,17 @@ const HomePage = () => { useEffect(() => { axiosInstance.get<{ id: string, name: string, createdAt: string }[]>("/@me/class") .then((classResponse) => { - classResponse.data.length > 0 && - axiosInstance.get(`/@me/class/${classResponse.data[0].id}/rooms`) - .then(classes => { - // Filter rooms by date, get future, actual and past rooms - const future = classes.data.filter(room => moment(room.date).isAfter(moment(), "day")); - const actual = classes.data.filter(room => moment(room.date).isSame(moment(), "day")); - const past = classes.data.filter(room => moment(room.date).isBefore(moment())); + if (classResponse.data.length) + axiosInstance.get(`/@me/class/${classResponse.data[0].id}/rooms`) + .then(classes => { + // Filter rooms by date, get future, actual and past rooms + const future = classes.data.filter(room => moment(room.date).isAfter(moment(), "day")); + const actual = classes.data.filter(room => moment(room.date).isSame(moment(), "day")); + const past = classes.data.filter(room => moment(room.date).isBefore(moment())); - setRooms({ future, actual, past }); - setRoomsLoading(false); - }); + setRooms({ future, actual, past }); + setRoomsLoading(false); + }); }) }, []);