import React, { useState } from 'react';
import { useDispatch, useSelector } from 'react-redux';
import { useNavigate } from 'react-router-dom';
import Draggable from 'react-draggable';
import {
Card,
CardContent,
Typography,
CardActions,
IconButton,
Table,
TableBody,
TableRow,
TableCell,
Menu,
MenuItem,
CardMedia,
} from '@mui/material';
import makeStyles from '@mui/styles/makeStyles';
import CloseIcon from '@mui/icons-material/Close';
import ReplayIcon from '@mui/icons-material/Replay';
import PublishIcon from '@mui/icons-material/Publish';
import EditIcon from '@mui/icons-material/Edit';
import DeleteIcon from '@mui/icons-material/Delete';
import PendingIcon from '@mui/icons-material/Pending';
import { useTranslation } from './LocalizationProvider';
import RemoveDialog from './RemoveDialog';
import PositionValue from './PositionValue';
import { useDeviceReadonly } from '../util/permissions';
import usePositionAttributes from '../attributes/usePositionAttributes';
import { devicesActions } from '../../store';
import { useCatch, useCatchCallback } from '../../reactHelper';
import { useAttributePreference } from '../util/preferences';
const useStyles = makeStyles((theme) => ({
card: {
pointerEvents: 'auto',
width: theme.dimensions.popupMaxWidth,
},
media: {
height: theme.dimensions.popupImageHeight,
display: 'flex',
justifyContent: 'flex-end',
alignItems: 'flex-start',
},
mediaButton: {
color: theme.palette.primary.contrastText,
mixBlendMode: 'difference',
},
header: {
display: 'flex',
justifyContent: 'space-between',
alignItems: 'center',
padding: theme.spacing(1, 1, 0, 2),
},
content: {
paddingTop: theme.spacing(1),
paddingBottom: theme.spacing(1),
maxHeight: theme.dimensions.cardContentMaxHeight,
overflow: 'auto',
},
delete: {
color: theme.palette.error.main,
},
icon: {
width: '25px',
height: '25px',
filter: 'brightness(0) invert(1)',
},
table: {
'& .MuiTableCell-sizeSmall': {
paddingLeft: 0,
paddingRight: 0,
},
},
cell: {
borderBottom: 'none',
},
actions: {
justifyContent: 'space-between',
},
root: ({ desktopPadding }) => ({
pointerEvents: 'none',
position: 'fixed',
zIndex: 5,
left: '50%',
[theme.breakpoints.up('md')]: {
left: `calc(50% + ${desktopPadding} / 2)`,
bottom: theme.spacing(3),
},
[theme.breakpoints.down('md')]: {
left: '50%',
bottom: `calc(${theme.spacing(3)} + ${theme.dimensions.bottomBarHeight}px)`,
},
transform: 'translateX(-50%)',
}),
}));
const StatusRow = ({ name, content }) => {
const classes = useStyles();
return (