Spaces:
Running
Running
axeronis commited on
Commit ·
076fca3
1
Parent(s): 9c325cc
debug: add console logs to diagnose notification settings issue
Browse files
frontend/app/settings/notifications/page.tsx
CHANGED
|
@@ -42,6 +42,8 @@ export default function NotificationSettingsPage() {
|
|
| 42 |
|
| 43 |
// Sync local state
|
| 44 |
useEffect(() => {
|
|
|
|
|
|
|
| 45 |
// Prioritize personal chat ID
|
| 46 |
if (user?.telegram_chat_id) {
|
| 47 |
setChatId(user.telegram_chat_id)
|
|
@@ -77,8 +79,7 @@ export default function NotificationSettingsPage() {
|
|
| 77 |
|
| 78 |
// 2. Save Global Settings (Owner only)
|
| 79 |
if (user?.role === 'OWNER') {
|
| 80 |
-
|
| 81 |
-
await api.put('/api/v1/notifications/settings', {
|
| 82 |
telegram_channel_id: channelId,
|
| 83 |
dashboard_enabled: true,
|
| 84 |
|
|
@@ -92,12 +93,18 @@ export default function NotificationSettingsPage() {
|
|
| 92 |
notify_escalation_high: notifyEscalationHigh,
|
| 93 |
notify_escalation_medium: notifyEscalationMedium,
|
| 94 |
notify_escalation_low: notifyEscalationLow
|
| 95 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 96 |
queryClient.invalidateQueries({ queryKey: ['notification-settings'] })
|
| 97 |
}
|
| 98 |
|
| 99 |
toast.success(t('notifications.settingsSaved'))
|
| 100 |
-
} catch {
|
|
|
|
| 101 |
toast.error(t('notifications.failedToSave'))
|
| 102 |
} finally {
|
| 103 |
setSaving(false)
|
|
|
|
| 42 |
|
| 43 |
// Sync local state
|
| 44 |
useEffect(() => {
|
| 45 |
+
console.log('🟡 [DEBUG] useEffect triggered. settingsData:', settingsData)
|
| 46 |
+
|
| 47 |
// Prioritize personal chat ID
|
| 48 |
if (user?.telegram_chat_id) {
|
| 49 |
setChatId(user.telegram_chat_id)
|
|
|
|
| 79 |
|
| 80 |
// 2. Save Global Settings (Owner only)
|
| 81 |
if (user?.role === 'OWNER') {
|
| 82 |
+
const payload = {
|
|
|
|
| 83 |
telegram_channel_id: channelId,
|
| 84 |
dashboard_enabled: true,
|
| 85 |
|
|
|
|
| 93 |
notify_escalation_high: notifyEscalationHigh,
|
| 94 |
notify_escalation_medium: notifyEscalationMedium,
|
| 95 |
notify_escalation_low: notifyEscalationLow
|
| 96 |
+
}
|
| 97 |
+
console.log('🔵 [DEBUG] Saving settings:', payload)
|
| 98 |
+
|
| 99 |
+
const response = await api.put('/api/v1/notifications/settings', payload)
|
| 100 |
+
console.log('🟢 [DEBUG] Server response:', response.data)
|
| 101 |
+
|
| 102 |
queryClient.invalidateQueries({ queryKey: ['notification-settings'] })
|
| 103 |
}
|
| 104 |
|
| 105 |
toast.success(t('notifications.settingsSaved'))
|
| 106 |
+
} catch (error) {
|
| 107 |
+
console.error('🔴 [DEBUG] Save error:', error)
|
| 108 |
toast.error(t('notifications.failedToSave'))
|
| 109 |
} finally {
|
| 110 |
setSaving(false)
|