aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--modern/src/SocketController.js10
-rw-r--r--modern/src/common/formatter.js2
2 files changed, 7 insertions, 5 deletions
diff --git a/modern/src/SocketController.js b/modern/src/SocketController.js
index ac95019..7718db8 100644
--- a/modern/src/SocketController.js
+++ b/modern/src/SocketController.js
@@ -4,18 +4,19 @@ import { useDispatch, useSelector, connect } from 'react-redux';
import { useHistory } from 'react-router-dom';
import { positionsActions, devicesActions, sessionActions } from './store';
import { useEffectAsync } from './reactHelper';
+import { useTranslation } from './LocalizationProvider';
-const displayNotifications = (events) => {
+const displayNotifications = (events, t) => {
if ('Notification' in window) {
if (Notification.permission === 'granted') {
events.forEach((event) => {
- const notification = new Notification(`Event: ${event.type}`);
+ const notification = new Notification(`Evento: ${t(event.type)}`);
setTimeout(notification.close.bind(notification), 4 * 1000);
});
} else if (Notification.permission !== 'denied') {
Notification.requestPermission((permission) => {
if (permission === 'granted') {
- displayNotifications(events);
+ displayNotifications(events, t);
}
});
}
@@ -25,6 +26,7 @@ const displayNotifications = (events) => {
const SocketController = () => {
const dispatch = useDispatch();
const history = useHistory();
+ const t = useTranslation();
const authenticated = useSelector((state) => !!state.session.user);
@@ -48,7 +50,7 @@ const SocketController = () => {
dispatch(positionsActions.update(data.positions));
}
if (data.events) {
- displayNotifications(data.events);
+ displayNotifications(data.events, t);
}
};
};
diff --git a/modern/src/common/formatter.js b/modern/src/common/formatter.js
index 87d8b00..d824e83 100644
--- a/modern/src/common/formatter.js
+++ b/modern/src/common/formatter.js
@@ -7,7 +7,7 @@ export const formatNumber = (value, precision = 1) => Number(value.toFixed(preci
export const formatDate = (value, locale = 'es') => value ? new Intl.DateTimeFormat(locale, {
dateStyle: 'medium',
timeStyle: 'short',
- hour12: true,
+ hourCycle: 'h12',
}).format(new Date(value)) : '';
export const formatPosition = (value, key, t, locale = 'es') => {