Files
Checkmate/Client/src/Pages/Incidents/index.jsx
T

180 lines
4.1 KiB
React
Raw Normal View History

2024-07-16 15:00:30 -07:00
import * as React from "react";
import TextField from "@mui/material/TextField";
import Autocomplete, { createFilterOptions } from "@mui/material/Autocomplete";
import { useTheme } from "@mui/material/styles";
import Box from "@mui/material/Box";
import Typography from "@mui/material/Typography";
import TuneIcon from "@mui/icons-material/Tune";
import { StatusLabel } from "../../Components/Label/";
const filterOptions = createFilterOptions({
2024-07-16 15:00:30 -07:00
matchFrom: "start",
stringify: (option) => option.title,
});
2024-07-02 21:07:15 -07:00
const titles = [
2024-07-16 15:00:30 -07:00
{ title: "Down" },
{ title: "Cannot resolve" },
{ title: "Clear / show all" },
];
2024-07-02 21:19:44 -07:00
/**
* Filter component with autocomplete for status filtering.
* @returns {JSX.Element} The JSX element representing the filter component.
*/
function Filter() {
return (
<Autocomplete
id="filter-demo"
2024-07-02 21:07:15 -07:00
options={titles}
getOptionLabel={(option) => option.title}
filterOptions={filterOptions}
2024-07-02 21:07:15 -07:00
sx={{
2024-07-02 21:19:44 -07:00
width: 170,
2024-07-16 15:00:30 -07:00
"& .MuiAutocomplete-inputRoot": {
height: "50px",
2024-07-02 21:07:15 -07:00
},
2024-07-16 15:00:30 -07:00
"& .MuiAutocomplete-listbox": {
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:19:44 -07:00
size="small"
2024-07-02 21:07:15 -07:00
label={
<React.Fragment>
2024-07-16 15:00:30 -07:00
<TuneIcon
sx={{ marginRight: "0.5rem", position: "relative", top: "6px" }}
/>
2024-07-02 21:07:15 -07:00
Filter by status
</React.Fragment>
}
InputProps={{ ...params.InputProps, endAdornment: null }}
2024-07-02 20:46:28 -07:00
/>
)}
/>
);
}
const sampleData = [
2024-07-16 15:00:30 -07:00
{
name: (
<StatusLabel
status="Down"
customStyles={{
backgroundColor: "#fff9f9",
borderColor: "#ffcac6",
color: "#344054",
}}
/>
),
date: "2024-03-14 21:41:09",
message: "HTTP 350 - NOK",
},
{
name: (
<StatusLabel
status="Down"
customStyles={{
backgroundColor: "#fff9f9",
borderColor: "#ffcac6",
color: "#344054",
}}
/>
),
date: "2024-03-14 21:41:09",
message: "timeout of 48000ms exceeded",
},
{
name: (
<StatusLabel
status="Cannot resolve"
customStyles={{
backgroundColor: "#f2f4f7",
borderColor: "#d2d6de",
color: "#344054",
}}
/>
),
date: "2024-03-14 21:41:09",
message: "timeout of 48000ms exceeded",
},
{
name: (
<StatusLabel
status="Cannot resolve"
customStyles={{
backgroundColor: "#f2f4f7",
borderColor: "#d2d6de",
color: "#344054",
}}
/>
),
date: "2024-03-14 21:41:09",
message: "timeout of 48000ms exceeded",
},
{
name: (
<StatusLabel
status="Down"
customStyles={{
backgroundColor: "#fff9f9",
borderColor: "#ffcac6",
color: "#344054",
}}
/>
),
date: "2024-03-14 21:41:09",
message: "HTTP 350 - NOK",
},
];
const columns = [
2024-07-16 15:00:30 -07:00
{ id: "name", header: "Status" },
{ id: "date", header: "Date & Time" },
{ id: "message", header: "Message" },
];
/**
* Customized table component displaying incident history with a filter.
* @returns {JSX.Element} The JSX element representing the customized table with a filter.
*/
export default function CustomizedTables() {
const theme = useTheme();
return (
<Box
sx={{
marginTop: theme.spacing(4),
2024-07-16 15:00:30 -07:00
marginX: "auto",
width: "80%",
paddingX: theme.spacing(6),
2024-07-16 15:00:30 -07:00
[theme.breakpoints.down("md")]: {
width: "100%",
},
}}
>
2024-07-16 15:00:30 -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>
<Filter />
</Box>
2024-07-16 15:00:30 -07:00
{/* TODO Replace with BasicTable */}
{/* <StatusTable data={sampleData} columns={columns} /> */}
</Box>
);
}