Enhance dashboard data fetching by adding active site checks
- Implemented checks for active site in Home, Planner, and Writer dashboards to prevent data fetching when no site is selected. - Updated API calls to include site_id in requests for better data accuracy. - Modified user messages to guide users in selecting an active site for insights.
This commit is contained in:
@@ -73,14 +73,20 @@ export default function PlannerDashboard() {
|
||||
|
||||
// Fetch real data
|
||||
const fetchDashboardData = async () => {
|
||||
if (!activeSite) {
|
||||
setStats(null);
|
||||
setLoading(false);
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
setLoading(true);
|
||||
|
||||
const [keywordsRes, clustersRes, ideasRes, tasksRes] = await Promise.all([
|
||||
fetchKeywords({ page_size: 1000, sector_id: activeSector?.id }),
|
||||
fetchClusters({ page_size: 1000, sector_id: activeSector?.id }),
|
||||
fetchContentIdeas({ page_size: 1000, sector_id: activeSector?.id }),
|
||||
fetchTasks({ page_size: 1000, sector_id: activeSector?.id })
|
||||
fetchKeywords({ page_size: 1000, site_id: activeSite.id, sector_id: activeSector?.id }),
|
||||
fetchClusters({ page_size: 1000, site_id: activeSite.id, sector_id: activeSector?.id }),
|
||||
fetchContentIdeas({ page_size: 1000, site_id: activeSite.id, sector_id: activeSector?.id }),
|
||||
fetchTasks({ page_size: 1000, site_id: activeSite.id, sector_id: activeSector?.id })
|
||||
]);
|
||||
|
||||
const keywords = keywordsRes.results || [];
|
||||
@@ -439,7 +445,11 @@ export default function PlannerDashboard() {
|
||||
<PageMeta title="Planner Dashboard - IGNY8" description="Content planning overview" />
|
||||
<div className="text-center py-12">
|
||||
<p className="text-gray-600 dark:text-gray-400">
|
||||
{activeSector ? 'No data available for the selected sector.' : 'No data available. Select a sector or wait for data to load.'}
|
||||
{!activeSite
|
||||
? 'Select an active site to view planner insights.'
|
||||
: activeSector
|
||||
? 'No data available for the selected sector.'
|
||||
: 'No data available. Select a sector or wait for data to load.'}
|
||||
</p>
|
||||
</div>
|
||||
</>
|
||||
|
||||
Reference in New Issue
Block a user