Revert "Enhance dashboard data fetching by adding active site checks"
This reverts commit 75ba407df5.
This commit is contained in:
@@ -199,22 +199,16 @@ export default function Home() {
|
|||||||
];
|
];
|
||||||
|
|
||||||
const fetchAppInsights = async () => {
|
const fetchAppInsights = async () => {
|
||||||
if (!activeSite) {
|
|
||||||
setInsights(null);
|
|
||||||
setLoading(false);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
|
|
||||||
const [keywordsRes, clustersRes, ideasRes, tasksRes, contentRes, imagesRes] = await Promise.all([
|
const [keywordsRes, clustersRes, ideasRes, tasksRes, contentRes, imagesRes] = await Promise.all([
|
||||||
fetchKeywords({ page_size: 1, site_id: activeSite.id, sector_id: activeSector?.id }),
|
fetchKeywords({ page_size: 1, site_id: undefined }),
|
||||||
fetchClusters({ page_size: 1, site_id: activeSite.id, sector_id: activeSector?.id }),
|
fetchClusters({ page_size: 1, site_id: undefined }),
|
||||||
fetchContentIdeas({ page_size: 1, site_id: activeSite.id, sector_id: activeSector?.id }),
|
fetchContentIdeas({ page_size: 1, site_id: undefined }),
|
||||||
fetchTasks({ page_size: 1, site_id: activeSite.id, sector_id: activeSector?.id }),
|
fetchTasks({ page_size: 1, site_id: undefined }),
|
||||||
fetchContent({ page_size: 1, site_id: activeSite.id, sector_id: activeSector?.id }),
|
fetchContent({ page_size: 1, site_id: undefined }),
|
||||||
fetchContentImages({ site_id: activeSite.id, sector_id: activeSector?.id })
|
fetchContentImages({ page_size: 1, site_id: undefined })
|
||||||
]);
|
]);
|
||||||
|
|
||||||
const totalKeywords = keywordsRes.count || 0;
|
const totalKeywords = keywordsRes.count || 0;
|
||||||
@@ -254,7 +248,7 @@ export default function Home() {
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
fetchAppInsights();
|
fetchAppInsights();
|
||||||
}, [activeSite?.id, activeSector?.id]);
|
}, [activeSite, activeSector]);
|
||||||
|
|
||||||
const chartOptions: ApexOptions = {
|
const chartOptions: ApexOptions = {
|
||||||
chart: {
|
chart: {
|
||||||
|
|||||||
@@ -73,20 +73,14 @@ export default function PlannerDashboard() {
|
|||||||
|
|
||||||
// Fetch real data
|
// Fetch real data
|
||||||
const fetchDashboardData = async () => {
|
const fetchDashboardData = async () => {
|
||||||
if (!activeSite) {
|
|
||||||
setStats(null);
|
|
||||||
setLoading(false);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
|
|
||||||
const [keywordsRes, clustersRes, ideasRes, tasksRes] = await Promise.all([
|
const [keywordsRes, clustersRes, ideasRes, tasksRes] = await Promise.all([
|
||||||
fetchKeywords({ page_size: 1000, site_id: activeSite.id, sector_id: activeSector?.id }),
|
fetchKeywords({ page_size: 1000, sector_id: activeSector?.id }),
|
||||||
fetchClusters({ page_size: 1000, site_id: activeSite.id, sector_id: activeSector?.id }),
|
fetchClusters({ page_size: 1000, sector_id: activeSector?.id }),
|
||||||
fetchContentIdeas({ page_size: 1000, site_id: activeSite.id, sector_id: activeSector?.id }),
|
fetchContentIdeas({ page_size: 1000, sector_id: activeSector?.id }),
|
||||||
fetchTasks({ page_size: 1000, site_id: activeSite.id, sector_id: activeSector?.id })
|
fetchTasks({ page_size: 1000, sector_id: activeSector?.id })
|
||||||
]);
|
]);
|
||||||
|
|
||||||
const keywords = keywordsRes.results || [];
|
const keywords = keywordsRes.results || [];
|
||||||
@@ -445,11 +439,7 @@ export default function PlannerDashboard() {
|
|||||||
<PageMeta title="Planner Dashboard - IGNY8" description="Content planning overview" />
|
<PageMeta title="Planner Dashboard - IGNY8" description="Content planning overview" />
|
||||||
<div className="text-center py-12">
|
<div className="text-center py-12">
|
||||||
<p className="text-gray-600 dark:text-gray-400">
|
<p className="text-gray-600 dark:text-gray-400">
|
||||||
{!activeSite
|
{activeSector ? 'No data available for the selected sector.' : 'No data available. Select a sector or wait for data to load.'}
|
||||||
? '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>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</>
|
</>
|
||||||
|
|||||||
@@ -78,19 +78,13 @@ export default function WriterDashboard() {
|
|||||||
const [lastUpdated, setLastUpdated] = useState<Date>(new Date());
|
const [lastUpdated, setLastUpdated] = useState<Date>(new Date());
|
||||||
|
|
||||||
const fetchDashboardData = async () => {
|
const fetchDashboardData = async () => {
|
||||||
if (!activeSite) {
|
|
||||||
setStats(null);
|
|
||||||
setLoading(false);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
|
|
||||||
const [tasksRes, contentRes, imagesRes] = await Promise.all([
|
const [tasksRes, contentRes, imagesRes] = await Promise.all([
|
||||||
fetchTasks({ page_size: 1000, site_id: activeSite.id, sector_id: activeSector?.id }),
|
fetchTasks({ page_size: 1000, sector_id: activeSector?.id }),
|
||||||
fetchContent({ page_size: 1000, site_id: activeSite.id, sector_id: activeSector?.id }),
|
fetchContent({ page_size: 1000, sector_id: activeSector?.id }),
|
||||||
fetchContentImages({ site_id: activeSite.id, sector_id: activeSector?.id })
|
fetchContentImages({ sector_id: activeSector?.id })
|
||||||
]);
|
]);
|
||||||
|
|
||||||
const tasks = tasksRes.results || [];
|
const tasks = tasksRes.results || [];
|
||||||
@@ -453,11 +447,7 @@ export default function WriterDashboard() {
|
|||||||
<PageMeta title="Writer Dashboard - IGNY8" description="Content creation overview" />
|
<PageMeta title="Writer Dashboard - IGNY8" description="Content creation overview" />
|
||||||
<div className="text-center py-12">
|
<div className="text-center py-12">
|
||||||
<p className="text-gray-600 dark:text-gray-400">
|
<p className="text-gray-600 dark:text-gray-400">
|
||||||
{!activeSite
|
{activeSector ? 'No data available for the selected sector.' : 'No data available. Select a sector or wait for data to load.'}
|
||||||
? '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.'}
|
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</>
|
</>
|
||||||
|
|||||||
Reference in New Issue
Block a user