tbaels fitlers and plnaner writer other fixes

This commit is contained in:
IGNY8 VPS (Salman)
2026-01-19 12:27:10 +00:00
parent cbb32b1c9d
commit 6c7395262f
16 changed files with 169 additions and 95 deletions

View File

@@ -47,8 +47,9 @@ export default function Ideas() {
const [loading, setLoading] = useState(true);
// Total counts for footer widget (not page-filtered)
const [totalInTasks, setTotalInTasks] = useState(0);
const [totalPending, setTotalPending] = useState(0);
const [totalNew, setTotalNew] = useState(0);
const [totalQueued, setTotalQueued] = useState(0);
const [totalCompleted, setTotalCompleted] = useState(0);
const [totalImagesCount, setTotalImagesCount] = useState(0);
// Actual total count (unfiltered) for header metrics - not affected by filters
const [actualTotalIdeas, setActualTotalIdeas] = useState(0);
@@ -182,8 +183,9 @@ export default function Ideas() {
]);
setActualTotalIdeas(allRes.count || 0); // Store actual total (unfiltered) for header metrics
setTotalInTasks((queuedRes.count || 0) + (completedRes.count || 0));
setTotalPending(newRes.count || 0);
setTotalNew(newRes.count || 0);
setTotalQueued(queuedRes.count || 0);
setTotalCompleted(completedRes.count || 0);
setTotalImagesCount(imagesRes.count || 0);
} catch (error) {
console.error('Error loading total metrics:', error);
@@ -364,7 +366,7 @@ export default function Ideas() {
});
}, [clusters, activeSector, formData, searchTerm, statusFilter, clusterFilter, structureFilter, typeFilter, statusOptions, contentTypeOptions, contentStructureOptions, clusterOptions]);
// Calculate header metrics - use actualTotalIdeas/totalInTasks/totalPending from API calls (not page data)
// Calculate header metrics - use actual counts from API calls (not page data)
// This ensures metrics show correct totals across all pages, not just current page
// Note: actualTotalIdeas is NOT affected by filters - it always shows the true total
const headerMetrics = useMemo(() => {
@@ -380,16 +382,16 @@ export default function Ideas() {
value = actualTotalIdeas || 0;
break;
case 'New':
// Use totalPending from loadTotalMetrics() (ideas with status='new')
value = totalPending;
// Use totalNew from loadTotalMetrics() (ideas with status='new')
value = totalNew;
break;
case 'Queued':
// Use totalInTasks from loadTotalMetrics() (ideas with status='queued')
value = totalInTasks;
// Use totalQueued from loadTotalMetrics() (ideas with status='queued')
value = totalQueued;
break;
case 'Completed':
// Calculate completed from totalCount - (totalPending + totalInTasks)
value = Math.max(0, totalCount - totalPending - totalInTasks);
// Use totalCompleted from loadTotalMetrics() (ideas with status='completed')
value = totalCompleted;
break;
default:
value = metric.calculate({ ideas, totalCount });
@@ -402,7 +404,7 @@ export default function Ideas() {
tooltip: (metric as any).tooltip,
};
});
}, [pageConfig?.headerMetrics, ideas, totalCount, totalPending, totalInTasks, actualTotalIdeas]);
}, [pageConfig?.headerMetrics, ideas, totalCount, totalNew, totalQueued, totalCompleted, actualTotalIdeas]);
const resetForm = useCallback(() => {
setFormData({
@@ -565,21 +567,21 @@ export default function Ideas() {
submoduleColor: 'amber',
metrics: [
{ label: 'Ideas', value: totalCount },
{ label: 'In Tasks', value: totalInTasks, percentage: `${totalCount > 0 ? Math.round((totalInTasks / totalCount) * 100) : 0}%` },
{ label: 'Pending', value: totalPending },
{ label: 'In Tasks', value: totalQueued + totalCompleted, percentage: `${totalCount > 0 ? Math.round(((totalQueued + totalCompleted) / totalCount) * 100) : 0}%` },
{ label: 'Pending', value: totalNew },
{ label: 'From Clusters', value: clusters.length },
],
progress: {
value: totalCount > 0 ? Math.round((totalInTasks / totalCount) * 100) : 0,
value: totalCount > 0 ? Math.round(((totalQueued + totalCompleted) / totalCount) * 100) : 0,
label: 'Converted',
color: 'amber',
},
hint: totalPending > 0
? `${totalPending} ideas ready to become tasks`
hint: totalNew > 0
? `${totalNew} ideas ready to become tasks`
: 'All ideas converted!',
statusInsight: totalPending > 0
statusInsight: totalNew > 0
? `Select ideas and queue them to Writer to start content generation.`
: totalInTasks > 0
: (totalQueued + totalCompleted) > 0
? `Ideas queued. Go to Writer Tasks to generate content.`
: `No ideas yet. Generate ideas from Clusters page.`,
}}