1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
import React from "react";
import Box from "@mui/material/Box";
import { DataGrid } from "@mui/x-data-grid";
import useLocalStorage from "../../hooks/useLocalStorage";
import { Link } from "react-router-dom";
const columns = [
{
field: "name",
headerName: "Name",
width: 150,
},
{
field: "next_run_at",
headerName: "Next Run",
width: 150,
},
{
field: "edit_survey_link",
headerName: "",
renderCell: ({ row }) => <Link to={`${row?.path}`}>Edit</Link>,
width: 150,
},
{
field: "results_survey_link",
headerName: "",
renderCell: ({ row }) => <Link to={`${row?.path}/results`}>Results</Link>,
width: 150,
},
];
export default function SurveysList() {
const [forms] = useLocalStorage(`forms`, {});
const rows = Object.keys(forms).map((id, i) => ({
id,
name: `Survey ${i}`,
next_run_at: "Mon 28 Aug 16:35:36 EDT 2023",
path: `/surveys/${id}`,
}));
return (
<Box sx={{ minHeight: "100%", width: "100%" }}>
<DataGrid
rows={rows}
columns={columns}
initialState={{
pagination: {
paginationModel: {
pageSize: 25,
},
},
}}
pageSizeOptions={[25, 50, 100]}
checkboxSelection
disableRowSelectionOnClick
/>
</Box>
);
}
|