diff --git a/frontend/src/pages/PulseTestPage.tsx b/frontend/src/pages/PulseTestPage.tsx index 7903809..2884f31 100644 --- a/frontend/src/pages/PulseTestPage.tsx +++ b/frontend/src/pages/PulseTestPage.tsx @@ -1,7 +1,7 @@ import React, { useEffect, useState } from 'react'; -import { useAuth } from '../context/AuthContext'; import { Activity, Thermometer, Droplets, Wind, Sun, Wifi, WifiOff, RefreshCw, Bell } from 'lucide-react'; import { useNotifications } from '../hooks/useNotifications'; +import api from '../lib/api'; interface PulseDevice { id: string; @@ -29,7 +29,6 @@ interface PulseStatus { } export default function PulseTestPage() { - const { token } = useAuth(); const { connected: wsConnected, alerts, unreadCount } = useNotifications(); const [status, setStatus] = useState(null); @@ -40,33 +39,22 @@ export default function PulseTestPage() { const [lastUpdate, setLastUpdate] = useState(null); const fetchData = async () => { - if (!token) return; - setLoading(true); setError(null); try { // Fetch status - const statusRes = await fetch('/api/pulse/status', { - headers: { Authorization: `Bearer ${token}` } - }); - const statusData = await statusRes.json(); - setStatus(statusData); + const statusRes = await api.get('/api/pulse/status'); + setStatus(statusRes.data); - if (statusData.connected) { + if (statusRes.data.connected) { // Fetch devices - const devicesRes = await fetch('/api/pulse/devices', { - headers: { Authorization: `Bearer ${token}` } - }); - const devicesData = await devicesRes.json(); - setDevices(devicesData.devices || []); + const devicesRes = await api.get('/api/pulse/devices'); + setDevices(devicesRes.data.devices || []); // Fetch readings - const readingsRes = await fetch('/api/pulse/readings', { - headers: { Authorization: `Bearer ${token}` } - }); - const readingsData = await readingsRes.json(); - setReadings(readingsData.readings || []); + const readingsRes = await api.get('/api/pulse/readings'); + setReadings(readingsRes.data.readings || []); } setLastUpdate(new Date()); @@ -83,7 +71,7 @@ export default function PulseTestPage() { // Refresh every 30 seconds const interval = setInterval(fetchData, 30000); return () => clearInterval(interval); - }, [token]); + }, []); const getStatusColor = (connected: boolean) => connected ? 'text-green-500' : 'text-red-500';