-
Notifications
You must be signed in to change notification settings - Fork 0
/
RainDetectionControl.tsx
67 lines (60 loc) · 1.75 KB
/
RainDetectionControl.tsx
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
61
62
63
64
65
66
67
import { Box, CardHeader, Typography, styled } from '@mui/material';
import { RainDetectionTransmitterChannel } from './../../types/types';
import { StyledHeaderIcon } from '../components/StyledIcons';
import { useTranslations } from './../../i18n/utils';
const StyledBox = styled(Box)({
display: 'flex',
flexDirection: 'row',
justifyContent: 'center',
width: '100%',
gap: '20px',
});
const StyledIconBox = styled(Box)({
display: 'flex',
alignItems: 'center',
gap: '5px',
});
interface RainDetectionControlProps {
channel: RainDetectionTransmitterChannel;
}
export const RainDetectionControl: React.FC<RainDetectionControlProps> = ({
channel,
}) => {
const {
datapoints: { HEATER_STATE, RAINING },
} = channel;
const isRaining = RAINING === 'true';
const isHeating = HEATER_STATE === 'true';
const t = useTranslations();
return (
<CardHeader
title={
<StyledBox>
<StyledIconBox>
{isRaining ? (
<StyledHeaderIcon icon="mdi:weather-heavy-rain" color="#0077B6" />
) : (
<StyledHeaderIcon icon="mdi:clouds" />
)}
<Typography variant="caption">
{isRaining ? t('RAINING') : t('NOT_RAINING')}
</Typography>
</StyledIconBox>
<StyledIconBox>
{isHeating ? (
<StyledHeaderIcon
icon="material-symbols:mode-heat"
color="#FF4500"
/>
) : (
<StyledHeaderIcon icon="material-symbols:mode-heat-off" />
)}
<Typography variant="caption">
{isHeating ? t('HEATING') : t('NOT_HEATING')}
</Typography>
</StyledIconBox>
</StyledBox>
}
/>
);
};