aboutsummaryrefslogtreecommitdiff
path: root/modern/src/StatusView.js
blob: 61fd150427a8233e595f54976514985f31756ac1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import t from './common/localization'
import React from 'react';
import { useSelector } from 'react-redux';
import { formatPosition } from './common/formatter';

const StatusView = (props) => {
  const device = useSelector(state => state.devices.items[props.deviceId]);
  const position = useSelector(state => state.positions.items[props.deviceId]);

  return (
    <>
      <b>{t('deviceStatus')}:</b> {formatPosition(device.status, 'status')}<br />
      <b>{t('sharedLocation')}:</b> {formatPosition(position, 'latitude')} {formatPosition(position, 'longitude')}<br />
      <b>{t('positionSpeed')}:</b> {formatPosition(position.speed, 'speed')}<br />
      <b>{t('positionCourse')}:</b> {formatPosition(position.course, 'course')}<br />
      <b>{t('positionDistance')}:</b> {formatPosition(position.attributes.totalDistance, 'distance')}<br />
      {position.attributes.batteryLevel &&
        <><b>{t('positionBattery')}:</b> {formatPosition(position.attributes.batteryLevel, 'batteryLevel')}<br /></>
      }
    </>
  );
};

export default StatusView;