diff --git a/frontend/src/components/NotificationSettingsModal.tsx b/frontend/src/components/NotificationSettingsModal.tsx index 7a096cfd..2964c7f7 100644 --- a/frontend/src/components/NotificationSettingsModal.tsx +++ b/frontend/src/components/NotificationSettingsModal.tsx @@ -13,6 +13,7 @@ import { Button } from '@/components/ui/button'; import { Label } from '@/components/ui/label'; import { Slider } from '@/components/ui/slider'; import { toast } from 'sonner'; +import { apiFetch } from '@/lib/api'; interface Agent { type: 'discord' | 'slack' | 'webhook'; @@ -51,7 +52,7 @@ export function NotificationSettingsModal({ isOpen, onClose }: NotificationSetti const fetchAgents = async () => { try { - const res = await fetch('/api/agents'); + const res = await apiFetch('/agents'); if (res.ok) { const data: Agent[] = await res.json(); const newAgents = { ...agents }; @@ -67,7 +68,7 @@ export function NotificationSettingsModal({ isOpen, onClose }: NotificationSetti const fetchSettings = async () => { try { - const res = await fetch('/api/settings'); + const res = await apiFetch('/settings'); if (res.ok) { const data = await res.json(); setSettings(prev => ({ ...prev, ...data })); @@ -91,9 +92,8 @@ export function NotificationSettingsModal({ isOpen, onClose }: NotificationSetti const saveAgent = async (type: string) => { setIsLoading(true); try { - const res = await fetch('/api/agents', { + const res = await apiFetch('/agents', { method: 'POST', - headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(agents[type]) }); if (res.ok) { @@ -115,9 +115,8 @@ export function NotificationSettingsModal({ isOpen, onClose }: NotificationSetti } setIsLoading(true); try { - const res = await fetch('/api/notifications/test', { + const res = await apiFetch('/notifications/test', { method: 'POST', - headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ type, url: agents[type].url }) }); if (res.ok) { @@ -137,9 +136,8 @@ export function NotificationSettingsModal({ isOpen, onClose }: NotificationSetti setIsLoading(true); try { for (const [key, value] of Object.entries(settings)) { - await fetch('/api/settings', { + await apiFetch('/settings', { method: 'POST', - headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ key, value }) }); } diff --git a/frontend/src/components/StackAlertSheet.tsx b/frontend/src/components/StackAlertSheet.tsx index 92787303..531897ae 100644 --- a/frontend/src/components/StackAlertSheet.tsx +++ b/frontend/src/components/StackAlertSheet.tsx @@ -18,6 +18,7 @@ import { } from '@/components/ui/select'; import { Trash2 } from 'lucide-react'; import { toast } from 'sonner'; +import { apiFetch } from '@/lib/api'; interface StackAlert { id?: number; @@ -54,7 +55,7 @@ export function StackAlertSheet({ isOpen, onClose, stackName }: StackAlertSheetP const fetchAlerts = async () => { try { - const res = await fetch(`/api/alerts?stackName=${stackName}`); + const res = await apiFetch(`/alerts?stackName=${stackName}`); if (res.ok) { const data = await res.json(); setAlerts(data); @@ -81,9 +82,8 @@ export function StackAlertSheet({ isOpen, onClose, stackName }: StackAlertSheetP }; try { - const res = await fetch('/api/alerts', { + const res = await apiFetch('/alerts', { method: 'POST', - headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(newAlert) }); if (res.ok) { @@ -103,7 +103,7 @@ export function StackAlertSheet({ isOpen, onClose, stackName }: StackAlertSheetP const deleteAlert = async (id: number) => { setIsLoading(true); try { - const res = await fetch(`/api/alerts/${id}`, { method: 'DELETE' }); + const res = await apiFetch(`/alerts/${id}`, { method: 'DELETE' }); if (res.ok) { toast.success('Alert rule deleted.'); fetchAlerts();