widgets and other fixes

This commit is contained in:
IGNY8 VPS (Salman)
2026-01-11 15:24:52 +00:00
parent 747770ac58
commit e9369df151
16 changed files with 761 additions and 277 deletions

View File

@@ -28,12 +28,14 @@ import { BoltIcon, PlusIcon, DownloadIcon, ListIcon, GroupIcon, ArrowRightIcon }
import { LightBulbIcon } from '@heroicons/react/24/outline';
import { createIdeasPageConfig } from '../../config/pages/ideas.config';
import { useSectorStore } from '../../store/sectorStore';
import { useSiteStore } from '../../store/siteStore';
import { usePageSizeStore } from '../../store/pageSizeStore';
import PageHeader from '../../components/common/PageHeader';
import StandardThreeWidgetFooter from '../../components/dashboard/StandardThreeWidgetFooter';
export default function Ideas() {
const toast = useToast();
const { activeSite } = useSiteStore();
const { activeSector } = useSectorStore();
const { pageSize } = usePageSizeStore();
@@ -96,37 +98,46 @@ export default function Ideas() {
loadClusters();
}, []);
// Load total metrics for footer widget (not affected by pagination)
// Load total metrics for footer widget (site-wide totals, no sector filter)
const loadTotalMetrics = useCallback(async () => {
try {
// Get ideas with status='queued' or 'completed' (those in tasks/writer)
const queuedRes = await fetchContentIdeas({
page_size: 1,
...(activeSector?.id && { sector_id: activeSector.id }),
status: 'queued',
});
const completedRes = await fetchContentIdeas({
page_size: 1,
...(activeSector?.id && { sector_id: activeSector.id }),
status: 'completed',
});
// Batch all API calls in parallel for better performance
const [allRes, queuedRes, completedRes, newRes, imagesRes] = await Promise.all([
// Get all ideas (site-wide)
fetchContentIdeas({
page_size: 1,
site_id: activeSite?.id,
}),
// Get ideas with status='queued'
fetchContentIdeas({
page_size: 1,
site_id: activeSite?.id,
status: 'queued',
}),
// Get ideas with status='completed'
fetchContentIdeas({
page_size: 1,
site_id: activeSite?.id,
status: 'completed',
}),
// Get ideas with status='new' (those ready to become tasks)
fetchContentIdeas({
page_size: 1,
site_id: activeSite?.id,
status: 'new',
}),
// Get actual total images count
fetchImages({ page_size: 1 }),
]);
setTotalCount(allRes.count || 0);
setTotalInTasks((queuedRes.count || 0) + (completedRes.count || 0));
// Get ideas with status='new' (those ready to become tasks)
const newRes = await fetchContentIdeas({
page_size: 1,
...(activeSector?.id && { sector_id: activeSector.id }),
status: 'new',
});
setTotalPending(newRes.count || 0);
// Get actual total images count
const imagesRes = await fetchImages({ page_size: 1 });
setTotalImagesCount(imagesRes.count || 0);
} catch (error) {
console.error('Error loading total metrics:', error);
}
}, [activeSector]);
}, [activeSite]);
// Load total metrics when sector changes
useEffect(() => {