-
Notifications
You must be signed in to change notification settings - Fork 0
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
1 parent
2ec3de7
commit 7bcc5ec
Showing
8 changed files
with
127 additions
and
35 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
import { Typography, IconButton, Box } from "@mui/material"; | ||
import NavigateNextIcon from "@mui/icons-material/NavigateNext"; | ||
import NavigateBeforeIcon from "@mui/icons-material/NavigateBefore"; | ||
import { useEffect, useState } from "react"; | ||
|
||
const PaginationFooter = (props: { | ||
page: number; | ||
totalPages: number; | ||
totalItems: number; | ||
handlePageChange: (page: number) => void; | ||
}) => { | ||
const [isPreviousPageDisabled, setIsPreviousPageDisabled] = | ||
useState<boolean>(false); | ||
const [isNextPageDisabled, setIsNextPageDisabled] = useState<boolean>(false); | ||
|
||
useEffect(() => { | ||
setIsPreviousPageDisabled(props.page === 1); | ||
setIsNextPageDisabled(props.page === props.totalPages); | ||
}, [props.page, props.totalPages]); | ||
|
||
const nextPage = () => { | ||
if (props.page < props.totalPages) { | ||
props.handlePageChange(props.page + 1); | ||
} | ||
}; | ||
const previousPage = () => { | ||
if (props.page > 1) { | ||
props.handlePageChange(props.page - 1); | ||
} | ||
}; | ||
|
||
return ( | ||
<Box | ||
sx={{ | ||
display: "flex", | ||
flexDirection: "row", | ||
alignItems: "center", | ||
width: "100%", | ||
borderBottom: "none", | ||
}} | ||
> | ||
<IconButton | ||
onClick={previousPage} | ||
disabled={isPreviousPageDisabled} | ||
role="button" | ||
aria-label="previousPageButton" | ||
> | ||
<NavigateBeforeIcon /> | ||
</IconButton> | ||
<Typography> | ||
Page {props.page} of {props.totalPages} | ||
</Typography> | ||
<IconButton | ||
onClick={nextPage} | ||
disabled={isNextPageDisabled} | ||
role="button" | ||
aria-label="nextPageButton" | ||
> | ||
<NavigateNextIcon /> | ||
</IconButton> | ||
<Typography>Total quizzes: {props.totalItems}</Typography> | ||
</Box> | ||
); | ||
}; | ||
|
||
export default PaginationFooter; |
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 |
---|---|---|
|
@@ -11,4 +11,4 @@ const Layout = (props: { children: React.ReactNode }) => { | |
); | ||
}; | ||
|
||
export default Layout; | ||
export default Layout; |
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 |
---|---|---|
|
@@ -22,4 +22,4 @@ const Navbar = () => { | |
); | ||
}; | ||
|
||
export default Navbar; | ||
export default Navbar; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,31 @@ | ||
export interface Quiz { | ||
id: number; | ||
name: string; | ||
description: string; | ||
questions: Question[]; | ||
id: number; | ||
name: string; | ||
description: string; | ||
questions: Question[]; | ||
} | ||
|
||
export interface Question { | ||
id: number; | ||
question: string; | ||
answers: Answer[]; | ||
id: number; | ||
question: string; | ||
answers: Answer[]; | ||
} | ||
|
||
|
||
export interface Answer { | ||
id: number; | ||
answer: string; | ||
isCorrect: boolean; | ||
id: number; | ||
answer: string; | ||
isCorrect: boolean; | ||
} | ||
|
||
export interface User { | ||
id: number; | ||
name: string; | ||
email: string; | ||
password: string; | ||
id: number; | ||
name: string; | ||
email: string; | ||
password: string; | ||
} | ||
|
||
export interface UserAnswer { | ||
id: number; | ||
questionId: number; | ||
answerId: number; | ||
} | ||
id: number; | ||
questionId: number; | ||
answerId: number; | ||
} |
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