Spaces:
Running on CPU Upgrade
Running on CPU Upgrade
Update frontend/src/pages/OrganizationPage.jsx
Browse files
frontend/src/pages/OrganizationPage.jsx
CHANGED
|
@@ -24,7 +24,7 @@ const CustomChartTooltip = ({ active, payload, label }) => {
|
|
| 24 |
};
|
| 25 |
|
| 26 |
export const OrganizationPage = () => {
|
| 27 |
-
const { user, token } = useAuth();
|
| 28 |
const navigate = useNavigate();
|
| 29 |
const [loading, setLoading] = useState(true);
|
| 30 |
|
|
@@ -38,6 +38,10 @@ export const OrganizationPage = () => {
|
|
| 38 |
const fetchData = useCallback(async () => {
|
| 39 |
try {
|
| 40 |
const activeToken = getToken();
|
|
|
|
|
|
|
|
|
|
|
|
|
| 41 |
const [summaryRes, historyRes] = await Promise.all([
|
| 42 |
fetch('/api/vulnerabilities/summary?global=true', { headers: { 'Authorization': `Bearer ${activeToken}` } }),
|
| 43 |
fetch('/api/scans/history?global=true&limit=100', { headers: { 'Authorization': `Bearer ${activeToken}` } })
|
|
@@ -63,7 +67,7 @@ export const OrganizationPage = () => {
|
|
| 63 |
return () => clearInterval(interval);
|
| 64 |
}, [fetchData]);
|
| 65 |
|
| 66 |
-
if (loading) {
|
| 67 |
return (
|
| 68 |
<div className="flex h-[80vh] items-center justify-center">
|
| 69 |
<div className="animate-spin rounded-full h-12 w-12 border-b-2 border-primary"></div>
|
|
|
|
| 24 |
};
|
| 25 |
|
| 26 |
export const OrganizationPage = () => {
|
| 27 |
+
const { user, token, loading: authLoading } = useAuth();
|
| 28 |
const navigate = useNavigate();
|
| 29 |
const [loading, setLoading] = useState(true);
|
| 30 |
|
|
|
|
| 38 |
const fetchData = useCallback(async () => {
|
| 39 |
try {
|
| 40 |
const activeToken = getToken();
|
| 41 |
+
if (!activeToken) {
|
| 42 |
+
setLoading(false);
|
| 43 |
+
return;
|
| 44 |
+
}
|
| 45 |
const [summaryRes, historyRes] = await Promise.all([
|
| 46 |
fetch('/api/vulnerabilities/summary?global=true', { headers: { 'Authorization': `Bearer ${activeToken}` } }),
|
| 47 |
fetch('/api/scans/history?global=true&limit=100', { headers: { 'Authorization': `Bearer ${activeToken}` } })
|
|
|
|
| 67 |
return () => clearInterval(interval);
|
| 68 |
}, [fetchData]);
|
| 69 |
|
| 70 |
+
if (loading || authLoading) {
|
| 71 |
return (
|
| 72 |
<div className="flex h-[80vh] items-center justify-center">
|
| 73 |
<div className="animate-spin rounded-full h-12 w-12 border-b-2 border-primary"></div>
|