-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
92 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 10 additions & 18 deletions
28
app/academia/components/subcomponents/Attendance/AttendanceContent.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,26 @@ | ||
import React, { useEffect } from "react"; | ||
import React from "react"; | ||
import { useAttendance } from "@/provider/AttendanceProvider"; | ||
import Error from "@/components/States/Error"; | ||
import Loading from "@/components/States/Loading"; | ||
import NoData from "../NoData"; | ||
import AttendanceList from "./Predict/AttendanceList"; | ||
import { AttendanceCourse } from "@/types/Attendance"; | ||
import { useMutateAll } from "@/hooks/useMutate"; | ||
|
||
export default function AttendanceContent(): JSX.Element { | ||
const { attendance, requestedAt, isLoading, error } = useAttendance(); | ||
const mutate = useMutateAll(); | ||
|
||
useEffect(() => { | ||
if ( | ||
!isLoading && | ||
!error && | ||
(!requestedAt || Date.now() - requestedAt > 60 * 60 * 1000) | ||
) { | ||
mutate({ mutateAttendance: true }); | ||
} | ||
}, [attendance, error, isLoading, mutate, requestedAt]); | ||
const { attendance, isOld, isLoading, error } = useAttendance(); | ||
|
||
if (isLoading) return <Loading size="max" />; | ||
if (error) return <Error component="Attendance" />; | ||
if (!attendance) return <NoData component="Attendance" />; | ||
|
||
return ( | ||
<AttendanceList | ||
open={false} | ||
displayedAttendance={attendance as AttendanceCourse[]} | ||
/> | ||
<div | ||
className={`${isOld ? "border-light-info-color dark:border-dark-info-color" : "border-transparent"} -mx-2 rounded-2xl border-4 border-dotted`} | ||
> | ||
<AttendanceList | ||
open={false} | ||
displayedAttendance={attendance as AttendanceCourse[]} | ||
/> | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters