Added the filter by status dropdown to the page.
This commit is contained in:
1 parent
c2b47e5cc4
commit
c9ca639f23
1 file changed
+31
-2
@@ -1,3 +1,5 @@
|
|||||||
|
import TextField from '@mui/material/TextField';
|
||||||
|
import Autocomplete, { createFilterOptions } from '@mui/material/Autocomplete';
|
||||||
import { styled, useTheme } from '@mui/material/styles';
|
import { styled, useTheme } from '@mui/material/styles';
|
||||||
import Table from '@mui/material/Table';
|
import Table from '@mui/material/Table';
|
||||||
import TableBody from '@mui/material/TableBody';
|
import TableBody from '@mui/material/TableBody';
|
||||||
@@ -20,10 +22,10 @@ const StyledTableCell = styled(TableCell)(({ theme }) => ({
|
|||||||
}));
|
}));
|
||||||
|
|
||||||
const StyledTableRow = styled(TableRow)(({ theme }) => ({
|
const StyledTableRow = styled(TableRow)(({ theme }) => ({
|
||||||
'&:nth-of-type(1)': {
|
'&:nth-of-type(odd)': {
|
||||||
backgroundColor: theme.palette.action.hover,
|
backgroundColor: theme.palette.action.hover,
|
||||||
},
|
},
|
||||||
'&:nth-of-type(n+1)': {
|
'&:nth-of-type(even)': {
|
||||||
backgroundColor: theme.palette.common.white,
|
backgroundColor: theme.palette.common.white,
|
||||||
},
|
},
|
||||||
'&:last-child td, &:last-child th': {
|
'&:last-child td, &:last-child th': {
|
||||||
@@ -31,6 +33,17 @@ const StyledTableRow = styled(TableRow)(({ theme }) => ({
|
|||||||
},
|
},
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
const filterOptions = createFilterOptions({
|
||||||
|
matchFrom: 'start',
|
||||||
|
stringify: (option) => option.title,
|
||||||
|
});
|
||||||
|
|
||||||
|
const top100Films = [
|
||||||
|
{ title: 'The Shawshank Redemption', year: 1994 },
|
||||||
|
{ title: 'The Dark Knight', year: 2008 },
|
||||||
|
{ title: '12 Angry Men', year: 1957 },
|
||||||
|
];
|
||||||
|
|
||||||
function createData(name, date, message) {
|
function createData(name, date, message) {
|
||||||
return { name, date, message };
|
return { name, date, message };
|
||||||
}
|
}
|
||||||
@@ -58,6 +71,9 @@ export default function CustomizedTables() {
|
|||||||
},
|
},
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
|
<Box sx={{ display: 'flex', justifyContent: 'flex-end', marginBottom: theme.spacing(2) }}>
|
||||||
|
<Filter />
|
||||||
|
</Box>
|
||||||
<TableContainer component={Paper}>
|
<TableContainer component={Paper}>
|
||||||
<Table sx={{ minWidth: 700 }} aria-label="customized table">
|
<Table sx={{ minWidth: 700 }} aria-label="customized table">
|
||||||
<TableHead>
|
<TableHead>
|
||||||
@@ -83,3 +99,16 @@ export default function CustomizedTables() {
|
|||||||
</Box>
|
</Box>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function Filter() {
|
||||||
|
return (
|
||||||
|
<Autocomplete
|
||||||
|
id="filter-demo"
|
||||||
|
options={top100Films}
|
||||||
|
getOptionLabel={(option) => option.title}
|
||||||
|
filterOptions={filterOptions}
|
||||||
|
sx={{ width: 300 }}
|
||||||
|
renderInput={(params) => <TextField {...params} label="Filter by status" />}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
}
|
||||||
Reference in new issue
Block a user