-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMaintenanceGroup.jsx
More file actions
55 lines (52 loc) · 2.21 KB
/
MaintenanceGroup.jsx
File metadata and controls
55 lines (52 loc) · 2.21 KB
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
import React, {useState} from 'react';
import { Button, Box, TableCell, TextField } from '@mui/material';
const MaintenanceGroup = ({device, handleOffline, handleDelete, handleOnline, handleUpdateInfo, showMaintenanceMode}) => {
const [editInfoMode, setEditInfoMode] = useState(false);
const [infoValue, setInfoValue] = useState(device.info || '');
const handleEditClick = () => {
if (editInfoMode) {
handleUpdateInfo(device.name, infoValue);
}
setEditInfoMode(!editInfoMode);
}
return (
<TableCell style={{ visibility: showMaintenanceMode ? 'visible' : 'hidden' }}>
<Box display={"flex"} alignItems={"center"} sx={{ gap: 1 }}>
{editInfoMode && (
<TextField
size="small"
multiline
value={infoValue}
onChange={(e) => setInfoValue(e.target.value)}
/>
)}
<Button variant="contained" color="primary" onClick={handleEditClick}>
{editInfoMode ? 'Save Info' : 'Edit Info'}
</Button>
{device.status !== "offline" ? (
<Button
variant="contained"
color="primary"
onClick={() => handleOffline(device.name)}
>
Set Offline
</Button>
) : (
<Button variant="contained"
color="primary"
onClick={() => handleOnline(device.name)}
>
Set Online
</Button>
)}
<Button
variant="contained"
color="secondary" onClick={() => handleDelete(device.name)}
>
Delete
</Button>
</Box>
</TableCell>
);
}
export default MaintenanceGroup;