Fix jwt-token
This commit is contained in:
@@ -311,7 +311,12 @@ export const DetectionDetailsModal = ({ detection, onClose }) => {
|
|||||||
</div>
|
</div>
|
||||||
<div className="flex justify-between">
|
<div className="flex justify-between">
|
||||||
<span className="text-gray-500">Detected At:</span>
|
<span className="text-gray-500">Detected At:</span>
|
||||||
<span>{format(new Date(detection.detected_at), 'MMM dd, yyyy HH:mm:ss')}</span>
|
<span>
|
||||||
|
{detection.detected_at
|
||||||
|
? format(new Date(detection.detected_at), 'MMM dd, yyyy HH:mm:ss')
|
||||||
|
: 'Unknown'
|
||||||
|
}
|
||||||
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<div className="flex justify-between">
|
<div className="flex justify-between">
|
||||||
<span className="text-gray-500">Device:</span>
|
<span className="text-gray-500">Device:</span>
|
||||||
|
|||||||
@@ -34,11 +34,15 @@ const Alerts = () => {
|
|||||||
api.get('/alerts/stats?hours=24')
|
api.get('/alerts/stats?hours=24')
|
||||||
]);
|
]);
|
||||||
|
|
||||||
setAlertRules(rulesRes.data.data);
|
setAlertRules(rulesRes.data?.data || []);
|
||||||
setAlertLogs(logsRes.data.data);
|
setAlertLogs(logsRes.data?.data || []);
|
||||||
setAlertStats(statsRes.data.data);
|
setAlertStats(statsRes.data?.data || null);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error fetching alert data:', error);
|
console.error('Error fetching alert data:', error);
|
||||||
|
// Set default values on error
|
||||||
|
setAlertRules([]);
|
||||||
|
setAlertLogs([]);
|
||||||
|
setAlertStats(null);
|
||||||
} finally {
|
} finally {
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
}
|
}
|
||||||
@@ -169,7 +173,7 @@ const Alerts = () => {
|
|||||||
: 'border-transparent text-gray-500 hover:text-gray-700 hover:border-gray-300'
|
: 'border-transparent text-gray-500 hover:text-gray-700 hover:border-gray-300'
|
||||||
}`}
|
}`}
|
||||||
>
|
>
|
||||||
Alert Logs ({alertLogs.length})
|
Alert Logs ({alertLogs?.length || 0})
|
||||||
</button>
|
</button>
|
||||||
</nav>
|
</nav>
|
||||||
</div>
|
</div>
|
||||||
@@ -177,7 +181,7 @@ const Alerts = () => {
|
|||||||
{/* Alert Rules Tab */}
|
{/* Alert Rules Tab */}
|
||||||
{activeTab === 'rules' && (
|
{activeTab === 'rules' && (
|
||||||
<div className="bg-white rounded-lg shadow overflow-hidden">
|
<div className="bg-white rounded-lg shadow overflow-hidden">
|
||||||
{alertRules.length === 0 ? (
|
{(alertRules?.length || 0) === 0 ? (
|
||||||
<div className="text-center py-12">
|
<div className="text-center py-12">
|
||||||
<BellIcon className="mx-auto h-12 w-12 text-gray-400" />
|
<BellIcon className="mx-auto h-12 w-12 text-gray-400" />
|
||||||
<h3 className="mt-2 text-sm font-medium text-gray-900">No alert rules</h3>
|
<h3 className="mt-2 text-sm font-medium text-gray-900">No alert rules</h3>
|
||||||
@@ -209,7 +213,7 @@ const Alerts = () => {
|
|||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
{alertRules.map((rule) => (
|
{(alertRules || []).map((rule) => (
|
||||||
<tr key={rule.id} className="hover:bg-gray-50">
|
<tr key={rule.id} className="hover:bg-gray-50">
|
||||||
<td>
|
<td>
|
||||||
<div>
|
<div>
|
||||||
@@ -232,7 +236,7 @@ const Alerts = () => {
|
|||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<div className="flex space-x-1">
|
<div className="flex space-x-1">
|
||||||
{rule.alert_channels.map((channel, index) => (
|
{(rule.alert_channels || []).map((channel, index) => (
|
||||||
<span
|
<span
|
||||||
key={index}
|
key={index}
|
||||||
className="px-2 py-1 bg-blue-100 text-blue-800 rounded text-xs"
|
className="px-2 py-1 bg-blue-100 text-blue-800 rounded text-xs"
|
||||||
@@ -297,7 +301,7 @@ const Alerts = () => {
|
|||||||
{/* Alert Logs Tab */}
|
{/* Alert Logs Tab */}
|
||||||
{activeTab === 'logs' && (
|
{activeTab === 'logs' && (
|
||||||
<div className="bg-white rounded-lg shadow overflow-hidden">
|
<div className="bg-white rounded-lg shadow overflow-hidden">
|
||||||
{alertLogs.length === 0 ? (
|
{(alertLogs?.length || 0) === 0 ? (
|
||||||
<div className="text-center py-12">
|
<div className="text-center py-12">
|
||||||
<BellIcon className="mx-auto h-12 w-12 text-gray-400" />
|
<BellIcon className="mx-auto h-12 w-12 text-gray-400" />
|
||||||
<h3 className="mt-2 text-sm font-medium text-gray-900">No alert logs</h3>
|
<h3 className="mt-2 text-sm font-medium text-gray-900">No alert logs</h3>
|
||||||
@@ -320,7 +324,7 @@ const Alerts = () => {
|
|||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
{alertLogs.map((log) => (
|
{(alertLogs || []).map((log) => (
|
||||||
<tr key={log.id} className="hover:bg-gray-50">
|
<tr key={log.id} className="hover:bg-gray-50">
|
||||||
<td>
|
<td>
|
||||||
<div className="flex items-center space-x-2">
|
<div className="flex items-center space-x-2">
|
||||||
|
|||||||
Reference in New Issue
Block a user