2024-07-02 20:46:28 -07:00
import * as React from 'react' ;
2024-07-02 20:43:39 -07:00
import TextField from '@mui/material/TextField' ;
import Autocomplete , { createFilterOptions } from '@mui/material/Autocomplete' ;
2024-07-02 20:24:51 -07:00
import { styled , useTheme } from '@mui/material/styles' ;
2024-06-27 21:13:21 -07:00
import Table from '@mui/material/Table' ;
import TableBody from '@mui/material/TableBody' ;
import TableCell , { tableCellClasses } from '@mui/material/TableCell' ;
import TableContainer from '@mui/material/TableContainer' ;
import TableHead from '@mui/material/TableHead' ;
import TableRow from '@mui/material/TableRow' ;
import Paper from '@mui/material/Paper' ;
2024-07-02 20:24:51 -07:00
import Box from '@mui/material/Box' ;
2024-07-02 21:13:29 -07:00
import Typography from '@mui/material/Typography' ;
2024-06-29 17:07:04 -07:00
import { StatusLabel } from "../../Components/Label/" ;
2024-07-02 21:13:29 -07:00
import TuneIcon from '@mui/icons-material/Tune' ;
2024-05-22 17:14:34 -04:00
2024-06-27 21:13:21 -07:00
const StyledTableCell = styled ( TableCell )(({ theme }) => ({
[ `&. ${ tableCellClasses . head } ` ] : {
2024-07-02 20:24:51 -07:00
backgroundColor : theme . palette . action . hover ,
2024-06-27 21:13:21 -07:00
color : theme . palette . common . black ,
},
[ `&. ${ tableCellClasses . body } ` ] : {
fontSize : 14 ,
},
}));
const StyledTableRow = styled ( TableRow )(({ theme }) => ({
2024-07-02 20:43:39 -07:00
'&:nth-of-type(odd)' : {
2024-07-02 20:24:51 -07:00
backgroundColor : theme . palette . action . hover ,
2024-06-27 21:13:21 -07:00
},
2024-07-02 20:43:39 -07:00
'&:nth-of-type(even)' : {
2024-07-02 20:24:51 -07:00
backgroundColor : theme . palette . common . white ,
2024-06-27 21:13:21 -07:00
},
'&:last-child td, &:last-child th' : {
border : 0 ,
},
}));
2024-07-02 20:43:39 -07:00
const filterOptions = createFilterOptions ({
matchFrom : 'start' ,
stringify : ( option ) => option . title ,
});
2024-07-02 21:07:15 -07:00
const titles = [
{ title : 'Down' },
{ title : 'Cannot resolve' },
{ title : 'Clear / show all' },
2024-07-02 20:43:39 -07:00
];
2024-07-02 20:24:51 -07:00
function createData ( name , date , message ) {
return { name , date , message };
2024-05-22 17:14:34 -04:00
}
2024-06-27 21:13:21 -07:00
const rows = [
2024-06-28 17:42:28 -07:00
createData (< StatusLabel status = "Down" customStyles = {{ backgroundColor : '#fff9f9' , borderColor : '#ffcac6' , color : '#344054' }} />, '2024-03-14 21:41:09' , 'HTTP 350 - NOK' ),
createData (< StatusLabel status = "Down" customStyles = {{ backgroundColor : '#fff9f9' , borderColor : '#ffcac6' , color : '#344054' }} />, '2024-03-14 21:41:09' , 'timeout of 48000ms exceeded' ),
createData (< StatusLabel status = "Cannot resolve" customStyles = {{ backgroundColor : '#f2f4f7' , borderColor : '#d2d6de' , color : '#344054' }} />, '2024-03-14 21:41:09' , 'timeout of 48000ms exceeded' ),
createData (< StatusLabel status = "Cannot resolve" customStyles = {{ backgroundColor : '#f2f4f7' , borderColor : '#d2d6de' , color : '#344054' }} />, '2024-03-14 21:41:09' , 'timeout of 48000ms exceeded' ),
createData (< StatusLabel status = "Down" customStyles = {{ backgroundColor : '#fff9f9' , borderColor : '#ffcac6' , color : '#344054' }} />, '2024-03-14 21:41:09' , 'HTTP 350 - NOK' ),
2024-06-27 21:13:21 -07:00
];
export default function CustomizedTables () {
2024-07-02 20:24:51 -07:00
const theme = useTheme ();
2024-06-27 21:13:21 -07:00
return (
2024-07-02 20:24:51 -07:00
< Box
sx = {{
marginTop : theme . spacing ( 4 ),
marginX : 'auto' ,
width : '80%' ,
paddingX : theme . spacing ( 6 ),
[ theme . breakpoints . down ( 'md' )] : {
width : '100%' ,
},
}}
>
2024-07-02 21:13:29 -07:00
< Box sx = {{ display : 'flex' , justifyContent : 'space-between' , alignItems : 'center' , marginBottom : theme . spacing ( 2 ) }}>
< Typography variant = "h6" component = "div" sx = {{ fontWeight : 600 , fontSize : 16 }}>
Incident History
</ Typography >
2024-07-02 20:43:39 -07:00
< Filter />
</ Box >
2024-07-02 20:24:51 -07:00
< TableContainer component = { Paper }>
< Table sx = {{ minWidth : 700 }} aria - label = "customized table" >
< TableHead >
< TableRow >
< StyledTableCell > Status </ StyledTableCell >
< StyledTableCell align = "right" > Date & Time </ StyledTableCell >
< StyledTableCell align = "right" > Message </ StyledTableCell >
</ TableRow >
</ TableHead >
< TableBody >
{ rows . map (( row , index ) => (
< StyledTableRow key = { index }>
< StyledTableCell component = "th" scope = "row" >
{ row . name }
</ StyledTableCell >
< StyledTableCell align = "right" >{ row . date }</ StyledTableCell >
< StyledTableCell align = "right" >{ row . message }</ StyledTableCell >
</ StyledTableRow >
))}
</ TableBody >
</ Table >
</ TableContainer >
</ Box >
2024-06-27 21:13:21 -07:00
);
}
2024-07-02 20:43:39 -07:00
function Filter () {
return (
< Autocomplete
id = "filter-demo"
2024-07-02 21:07:15 -07:00
options = { titles }
2024-07-02 20:43:39 -07:00
getOptionLabel = {( option ) => option . title }
filterOptions = { filterOptions }
2024-07-02 21:07:15 -07:00
sx = {{
2024-07-02 21:13:29 -07:00
width : 170 ,
2024-07-02 21:07:15 -07:00
'& .MuiAutocomplete-inputRoot' : {
2024-07-02 21:13:29 -07:00
height : '50px' ,
2024-07-02 21:07:15 -07:00
},
'& .MuiAutocomplete-listbox' : {
2024-07-02 21:13:29 -07:00
maxHeight : '200px' ,
2024-07-02 21:07:15 -07:00
},
}}
disableClearable
2024-07-02 20:46:28 -07:00
renderInput = {( params ) => (
< TextField
{ ...params }
2024-07-02 21:07:15 -07:00
size = "small"
label = {
< React.Fragment >
< TuneIcon sx = {{ marginRight : '0.5rem' , position : 'relative' , top : '6px' }} />
Filter by status
</ React.Fragment >
}
InputProps = {{ ... params . InputProps , endAdornment : null }}
2024-07-02 20:46:28 -07:00
/>
)}
2024-07-02 20:43:39 -07:00
/>
);
}