Fix jwt-token

This commit is contained in:
2025-09-23 10:22:21 +02:00
parent 0d9cbd5e20
commit 1e1a1ad488

View File

@@ -361,7 +361,14 @@ const Alerts = () => {
<span className={`px-2 py-1 rounded-full text-xs font-medium ${
getPriorityColor(rule.priority)
}`}>
{t(`alerts.${rule.priority}`)}
{(() => {
// DEBUG: Check if priority is an object
if (typeof rule.priority === 'object' && rule.priority !== null) {
console.error('DEBUG: Priority is an object:', rule.priority, 'for rule:', rule.id);
return 'Invalid Priority';
}
return t(`alerts.${rule.priority}`);
})()}
</span>
</td>
<td>
@@ -369,6 +376,15 @@ const Alerts = () => {
{(() => {
// Normalize alert_channels - ensure it's always an array
let alertChannels = rule.alert_channels || [];
// DEBUG: Add debugging to catch object rendering
if (typeof alertChannels === 'object' && alertChannels !== null) {
const hasKeys = Object.keys(alertChannels).some(key => ['sms', 'webhook', 'email'].includes(key));
if (hasKeys) {
console.log('DEBUG: Found problematic alert_channels object:', alertChannels, 'for rule:', rule.id);
}
}
if (typeof alertChannels === 'object' && !Array.isArray(alertChannels)) {
// Convert object like {sms: true, webhook: false, email: true} to array
alertChannels = Object.keys(alertChannels).filter(key => alertChannels[key]);
@@ -376,14 +392,22 @@ const Alerts = () => {
if (!Array.isArray(alertChannels)) {
alertChannels = []; // fallback to empty array
}
return alertChannels.map((channel, index) => (
<span
key={index}
className="px-2 py-1 bg-blue-100 text-blue-800 rounded text-xs"
>
{channel}
</span>
));
// DEBUG: Ensure we're only rendering strings
return alertChannels.map((channel, index) => {
if (typeof channel !== 'string') {
console.error('DEBUG: Non-string channel detected:', channel, typeof channel);
return null;
}
return (
<span
key={index}
className="px-2 py-1 bg-blue-100 text-blue-800 rounded text-xs"
>
{channel}
</span>
);
}).filter(Boolean);
})()}
</div>
</td>