-
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.
feat: 🎸 add SearchAndFilter component
- Loading branch information
Showing
2 changed files
with
71 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
61 changes: 61 additions & 0 deletions
61
apps/web/src/components/searchAndFilter/SearchAndFilter.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 |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import React from 'react'; | ||
import Card from '@mui/material/Card'; | ||
import Pagination from '@mui/material/Pagination'; | ||
import FormControlLabel from '@mui/material/FormControlLabel'; | ||
import Switch from '@mui/material/Switch'; | ||
import { Typography } from '@mui/material'; | ||
|
||
interface Props { | ||
totalPageCount: number; | ||
page: number; | ||
handlePageChange: (e: React.ChangeEvent<unknown>, page: number) => void; | ||
handleSortByCreatedAt: (e: React.ChangeEvent<HTMLInputElement>) => void; | ||
handleSortByUpdatedAt: (e: React.ChangeEvent<HTMLInputElement>) => void; | ||
sortByCreatedAt: boolean; | ||
sortByUpdatedAt: boolean; | ||
} | ||
|
||
function SearchAndFilter({ | ||
totalPageCount, | ||
page, | ||
handlePageChange, | ||
handleSortByCreatedAt, | ||
handleSortByUpdatedAt, | ||
sortByCreatedAt, | ||
sortByUpdatedAt, | ||
}: Props) { | ||
return ( | ||
<Card className="p-5 mt-5"> | ||
<Typography variant="h5"> | ||
<span className="font-bold">Search and Filter</span> | ||
</Typography> | ||
<Pagination | ||
className="my-5" | ||
count={totalPageCount} | ||
page={page} | ||
onChange={handlePageChange} | ||
variant="outlined" | ||
color="primary" | ||
showFirstButton | ||
showLastButton | ||
/> | ||
|
||
<div className="flex flex-row items-center"> | ||
<FormControlLabel | ||
control={<Switch onChange={(e) => handleSortByCreatedAt(e)} />} | ||
label={`Sort by Created At (${ | ||
sortByCreatedAt ? 'Ascending' : 'Descending' | ||
})`} | ||
/> | ||
<FormControlLabel | ||
control={<Switch onChange={(e) => handleSortByUpdatedAt(e)} />} | ||
label={`Sort by Updated At (${ | ||
sortByUpdatedAt ? 'Ascending' : 'Descending' | ||
})`} | ||
/> | ||
</div> | ||
</Card> | ||
); | ||
} | ||
|
||
export default SearchAndFilter; |