link-stack/packages/leafcutter-ui/components/RawDataViewer.tsx

98 lines
2.2 KiB
TypeScript
Raw Permalink Normal View History

2023-06-26 10:07:12 +00:00
"use client";
2023-02-13 13:46:56 +00:00
import { FC } from "react";
2024-03-20 17:51:21 +01:00
import { useRouter } from "next/navigation";
2023-02-13 13:46:56 +00:00
import { Box, Grid } from "@mui/material";
import { DataGridPro } from "@mui/x-data-grid-pro";
import { useTranslate } from "react-polyglot";
interface RawDataViewerProps {
rows: any[];
height: number;
}
export const RawDataViewer: FC<RawDataViewerProps> = ({ rows, height }) => {
const t = useTranslate();
2024-03-20 17:51:21 +01:00
const router = useRouter();
2023-02-13 13:46:56 +00:00
const columns = [
{
2024-03-20 17:51:21 +01:00
field: "open_date",
headerName: "Open Date", //t("date"),
2023-02-13 13:46:56 +00:00
editable: false,
flex: 0.7,
2023-05-24 20:27:57 +00:00
valueFormatter: ({ value }: any) => new Date(value).toLocaleDateString(),
2023-02-13 13:46:56 +00:00
},
2024-03-20 17:51:21 +01:00
{
field: "close_date",
headerName: "Close Date", // t("date"),
editable: false,
flex: 0.7,
valueFormatter: ({ value }: any) => new Date(value).toLocaleDateString(),
},
2023-02-13 13:46:56 +00:00
{
field: "incident",
headerName: t("incident"),
editable: false,
flex: 1,
},
{
field: "technology",
headerName: t("technology"),
editable: false,
flex: 0.8,
},
{
field: "targeted_group",
headerName: t("targetedGroup"),
editable: false,
flex: 1.3,
},
{
field: "country",
headerName: t("country"),
editable: false,
flex: 1,
},
{
field: "region",
headerName: t("subregion"),
editable: false,
flex: 1,
},
{
field: "continent",
headerName: t("continent"),
editable: false,
flex: 1,
},
];
return (
<Grid item xs={12}>
2023-05-24 20:27:57 +00:00
<Box
sx={{ width: "100%", height }}
onClick={(e: any) => e.stopPropagation()}
>
2023-02-13 13:46:56 +00:00
<Grid container direction="column" spacing={2}>
<Grid item>
<DataGridPro
sx={{ width: "100%", height }}
rows={rows}
columns={columns}
density="compact"
2023-05-24 20:27:57 +00:00
pageSizeOptions={[100]}
disableRowSelectionOnClick
2023-02-13 13:46:56 +00:00
hideFooter
disableColumnMenu
scrollbarSize={10}
2023-03-31 11:47:51 +02:00
disableVirtualization
2024-03-20 17:51:21 +01:00
onCellClick={(e) => router.push("/tickets/" + e.row.id)}
2023-02-13 13:46:56 +00:00
/>
</Grid>
</Grid>
</Box>
2023-05-24 20:27:57 +00:00
</Grid>
2023-02-13 13:46:56 +00:00
);
};