From 395a5b884269092746008c581e446f9f0425321d Mon Sep 17 00:00:00 2001 From: Alexander Borg Date: Fri, 19 Sep 2025 14:26:27 +0200 Subject: [PATCH] Fix jwt-token --- client/src/pages/Devices.jsx | 72 ++++++++++++------------- client/src/utils/tempTranslations.js | 80 +++++++++++++++++++++++++--- 2 files changed, 108 insertions(+), 44 deletions(-) diff --git a/client/src/pages/Devices.jsx b/client/src/pages/Devices.jsx index a6289e3..50e94b8 100644 --- a/client/src/pages/Devices.jsx +++ b/client/src/pages/Devices.jsx @@ -63,7 +63,7 @@ const Devices = () => { }; const handleRejectDevice = async (deviceId) => { - if (window.confirm('Are you sure you want to reject this device?')) { + if (window.confirm(t('devices.confirmReject'))) { try { await api.post(`/devices/${deviceId}/approve`, { approved: false }); fetchDevices(); @@ -73,7 +73,7 @@ const Devices = () => { alert('Your session has expired. Please log in again.'); return; } - alert('Error rejecting device: ' + (error.response?.data?.message || error.message)); + alert(t('devices.errorRejecting') + ' ' + (error.response?.data?.message || error.message)); } } }; @@ -103,12 +103,12 @@ const Devices = () => { }; const handleDeleteDevice = async (deviceId) => { - if (window.confirm('Are you sure you want to deactivate this device?')) { + if (window.confirm(t('devices.confirmDelete'))) { try { await api.delete(`/devices/${deviceId}`); fetchDevices(); } catch (error) { - console.error('Error deleting device:', error); + console.error(t('devices.errorDeleting'), error); } } }; @@ -125,13 +125,13 @@ const Devices = () => { }; const getSignalStrength = (lastHeartbeat) => { - if (!lastHeartbeat) return 'Unknown'; + if (!lastHeartbeat) return t('devices.unknown'); const timeSince = (new Date() - new Date(lastHeartbeat)) / 1000 / 60; // minutes - if (timeSince < 5) return 'Strong'; - if (timeSince < 15) return 'Good'; - if (timeSince < 60) return 'Weak'; - return 'Lost'; + if (timeSince < 5) return t('devices.signalStrong'); + if (timeSince < 15) return t('devices.signalGood'); + if (timeSince < 60) return t('devices.signalWeak'); + return t('devices.signalLost'); }; const filteredDevices = devices.filter(device => { @@ -162,7 +162,7 @@ const Devices = () => { {t('devices.description')} {pendingCount > 0 && ( - {pendingCount} pending approval + {pendingCount} {t('devices.pendingApproval')} )}

@@ -187,7 +187,7 @@ const Devices = () => { : 'border-transparent text-gray-500 hover:text-gray-700 hover:border-gray-300' }`} > - All Devices ({devices.length}) + {t('devices.allDevices')} ({devices.length}) ) : null} @@ -356,13 +356,13 @@ const Devices = () => { onClick={() => handleViewDetails(device)} className="flex-1 text-xs bg-gray-100 text-gray-700 py-2 px-3 rounded hover:bg-gray-200 transition-colors" > - View Details + {t('devices.viewDetails')} @@ -375,14 +375,14 @@ const Devices = () => {

- No {filter === 'all' ? '' : filter} devices + {filter === 'all' ? t('devices.noDevices') : `${t('devices.noDevicesFiltered').replace('the current filter', filter)}`}

{filter === 'pending' - ? 'No devices are currently pending approval.' + ? t('devices.noDevicesPending') : filter === 'approved' - ? 'No devices have been approved yet.' - : 'No devices match the current filter.' + ? t('devices.noDevicesApproved') + : t('devices.noDevicesFiltered') }

@@ -391,9 +391,9 @@ const Devices = () => { {devices.length === 0 && (
-

No devices

+

{t('devices.noDevices')}

- Get started by adding your first drone detection device. + {t('devices.noDevicesDescription')}