aboutsummaryrefslogtreecommitdiff
path: root/modern/src/settings/MaintenancesPage.js
diff options
context:
space:
mode:
Diffstat (limited to 'modern/src/settings/MaintenancesPage.js')
-rw-r--r--modern/src/settings/MaintenancesPage.js26
1 files changed, 24 insertions, 2 deletions
diff --git a/modern/src/settings/MaintenancesPage.js b/modern/src/settings/MaintenancesPage.js
index 9cbf51a5..5e74e5a6 100644
--- a/modern/src/settings/MaintenancesPage.js
+++ b/modern/src/settings/MaintenancesPage.js
@@ -6,6 +6,10 @@ import t from '../common/localization';
import { useEffectAsync } from '../reactHelper';
import EditCollectionView from '../EditCollectionView';
+import positionAttributes from '../attributes/positionAttributes';
+import { formatDistance, formatSpeed } from '../common/formatter';
+import { useAttributePreference } from '../common/preferences';
+
const useStyles = makeStyles(theme => ({
columnAction: {
width: theme.spacing(1),
@@ -17,6 +21,8 @@ const MaintenancesView = ({ updateTimestamp, onMenuClick }) => {
const classes = useStyles();
const [items, setItems] = useState([]);
+ const speedUnit = useAttributePreference('speedUnit');
+ const distanceUnit = useAttributePreference('distanceUnit');
useEffectAsync(async () => {
const response = await fetch('/api/maintenance');
@@ -25,6 +31,22 @@ const MaintenancesView = ({ updateTimestamp, onMenuClick }) => {
}
}, [updateTimestamp]);
+ const convertAttribute = (key, value) => {
+ const attribute = positionAttributes[key];
+ if (attribute && attribute.dataType) {
+ switch (attribute.dataType) {
+ case 'speed':
+ return formatSpeed(value, speedUnit);
+ case 'distance':
+ return formatDistance(value, distanceUnit);
+ default:
+ return value;
+ }
+ }
+
+ return value;
+ }
+
return (
<TableContainer>
<Table>
@@ -47,8 +69,8 @@ const MaintenancesView = ({ updateTimestamp, onMenuClick }) => {
</TableCell>
<TableCell>{item.name}</TableCell>
<TableCell>{item.type}</TableCell>
- <TableCell>{item.start}</TableCell>
- <TableCell>{item.period}</TableCell>
+ <TableCell>{convertAttribute(item.type, item.start)}</TableCell>
+ <TableCell>{convertAttribute(item.type, item.period)}</TableCell>
</TableRow>
))}
</TableBody>