From fe7af3c81ca0c4c3fdd41136abe5ce3690bc8051 Mon Sep 17 00:00:00 2001 From: alorig <220087330+alorig@users.noreply.github.com> Date: Mon, 17 Nov 2025 17:28:30 +0500 Subject: [PATCH] Revert "Enhance dashboard data fetching by adding active site checks" This reverts commit 75ba407df510b297b861f2784a0c5263a1c34a5c. --- frontend/src/pages/Dashboard/Home.tsx | 20 +++++++------------- frontend/src/pages/Planner/Dashboard.tsx | 20 +++++--------------- frontend/src/pages/Writer/Dashboard.tsx | 18 ++++-------------- 3 files changed, 16 insertions(+), 42 deletions(-) diff --git a/frontend/src/pages/Dashboard/Home.tsx b/frontend/src/pages/Dashboard/Home.tsx index bfebd9e8..5903074e 100644 --- a/frontend/src/pages/Dashboard/Home.tsx +++ b/frontend/src/pages/Dashboard/Home.tsx @@ -199,22 +199,16 @@ export default function Home() { ]; const fetchAppInsights = async () => { - if (!activeSite) { - setInsights(null); - setLoading(false); - return; - } - try { setLoading(true); const [keywordsRes, clustersRes, ideasRes, tasksRes, contentRes, imagesRes] = await Promise.all([ - fetchKeywords({ page_size: 1, site_id: activeSite.id, sector_id: activeSector?.id }), - fetchClusters({ page_size: 1, site_id: activeSite.id, sector_id: activeSector?.id }), - fetchContentIdeas({ page_size: 1, site_id: activeSite.id, sector_id: activeSector?.id }), - fetchTasks({ page_size: 1, site_id: activeSite.id, sector_id: activeSector?.id }), - fetchContent({ page_size: 1, site_id: activeSite.id, sector_id: activeSector?.id }), - fetchContentImages({ site_id: activeSite.id, sector_id: activeSector?.id }) + fetchKeywords({ page_size: 1, site_id: undefined }), + fetchClusters({ page_size: 1, site_id: undefined }), + fetchContentIdeas({ page_size: 1, site_id: undefined }), + fetchTasks({ page_size: 1, site_id: undefined }), + fetchContent({ page_size: 1, site_id: undefined }), + fetchContentImages({ page_size: 1, site_id: undefined }) ]); const totalKeywords = keywordsRes.count || 0; @@ -254,7 +248,7 @@ export default function Home() { useEffect(() => { fetchAppInsights(); - }, [activeSite?.id, activeSector?.id]); + }, [activeSite, activeSector]); const chartOptions: ApexOptions = { chart: { diff --git a/frontend/src/pages/Planner/Dashboard.tsx b/frontend/src/pages/Planner/Dashboard.tsx index 50b8b517..19e26b83 100644 --- a/frontend/src/pages/Planner/Dashboard.tsx +++ b/frontend/src/pages/Planner/Dashboard.tsx @@ -73,20 +73,14 @@ 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, 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 }) + 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 }) ]); const keywords = keywordsRes.results || []; @@ -445,11 +439,7 @@ export default function PlannerDashboard() {

- {!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.'} + {activeSector ? 'No data available for the selected sector.' : 'No data available. Select a sector or wait for data to load.'}

diff --git a/frontend/src/pages/Writer/Dashboard.tsx b/frontend/src/pages/Writer/Dashboard.tsx index 36daf276..e6b6c5c6 100644 --- a/frontend/src/pages/Writer/Dashboard.tsx +++ b/frontend/src/pages/Writer/Dashboard.tsx @@ -78,19 +78,13 @@ export default function WriterDashboard() { const [lastUpdated, setLastUpdated] = useState(new Date()); const fetchDashboardData = async () => { - if (!activeSite) { - setStats(null); - setLoading(false); - return; - } - try { setLoading(true); const [tasksRes, contentRes, imagesRes] = await Promise.all([ - fetchTasks({ page_size: 1000, site_id: activeSite.id, sector_id: activeSector?.id }), - fetchContent({ page_size: 1000, site_id: activeSite.id, sector_id: activeSector?.id }), - fetchContentImages({ site_id: activeSite.id, sector_id: activeSector?.id }) + fetchTasks({ page_size: 1000, sector_id: activeSector?.id }), + fetchContent({ page_size: 1000, sector_id: activeSector?.id }), + fetchContentImages({ sector_id: activeSector?.id }) ]); const tasks = tasksRes.results || []; @@ -453,11 +447,7 @@ export default function WriterDashboard() {

- {!activeSite - ? 'Select an active site to view writer insights.' - : activeSector - ? 'No data available for the selected sector.' - : 'No data available. Select a sector or wait for data to load.'} + {activeSector ? 'No data available for the selected sector.' : 'No data available. Select a sector or wait for data to load.'}