You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
35 lines
830 B
35 lines
830 B
/**
|
|
* useDXPaths Hook
|
|
* Fetches DX spots with coordinates for map visualization
|
|
*/
|
|
import { useState, useEffect } from 'react';
|
|
|
|
export const useDXPaths = () => {
|
|
const [data, setData] = useState([]);
|
|
const [loading, setLoading] = useState(true);
|
|
|
|
useEffect(() => {
|
|
const fetchData = async () => {
|
|
try {
|
|
const response = await fetch('/api/dxcluster/paths');
|
|
if (response.ok) {
|
|
const paths = await response.json();
|
|
setData(paths);
|
|
}
|
|
} catch (err) {
|
|
console.error('DX paths error:', err);
|
|
} finally {
|
|
setLoading(false);
|
|
}
|
|
};
|
|
|
|
fetchData();
|
|
const interval = setInterval(fetchData, 30000); // 30 seconds (was 10s)
|
|
return () => clearInterval(interval);
|
|
}, []);
|
|
|
|
return { data, loading };
|
|
};
|
|
|
|
export default useDXPaths;
|