master - part 2

This commit is contained in:
IGNY8 VPS (Salman)
2025-12-30 09:47:58 +00:00
parent 2af7bb725f
commit 885158e152
13 changed files with 538 additions and 63 deletions

View File

@@ -34,6 +34,11 @@ export default function Review() {
const [loading, setLoading] = useState(true);
const [totalImagesCount, setTotalImagesCount] = useState(0);
// Total metrics for footer widget (not page-filtered)
const [totalDrafts, setTotalDrafts] = useState(0);
const [totalApproved, setTotalApproved] = useState(0);
const [totalTasks, setTotalTasks] = useState(0);
// Filter state - default to review status
const [searchTerm, setSearchTerm] = useState('');
const [statusFilter, setStatusFilter] = useState('review'); // Default to review
@@ -85,19 +90,30 @@ export default function Review() {
loadContent();
}, [loadContent]);
// Load total images count
useEffect(() => {
const loadImageCount = async () => {
try {
const imagesRes = await fetchImages({ page_size: 1 });
setTotalImagesCount(imagesRes.count || 0);
} catch (error) {
console.error('Error loading image count:', error);
}
};
loadImageCount();
// Load total images count and other metrics for footer widget
const loadTotalMetrics = useCallback(async () => {
try {
// Fetch counts in parallel for performance
const [imagesRes, draftsRes, approvedRes, tasksRes] = await Promise.all([
fetchImages({ page_size: 1 }),
fetchContent({ page_size: 1, status: 'draft' }),
fetchContent({ page_size: 1, status: 'approved' }),
fetchAPI<{ count: number }>('/writer/tasks/?page_size=1'),
]);
setTotalImagesCount(imagesRes.count || 0);
setTotalDrafts(draftsRes.count || 0);
setTotalApproved(approvedRes.count || 0);
setTotalTasks(tasksRes.count || 0);
} catch (error) {
console.error('Error loading metrics:', error);
}
}, []);
useEffect(() => {
loadTotalMetrics();
}, [loadTotalMetrics]);
// Listen for site and sector changes and refresh data
useEffect(() => {
const handleSiteChange = () => {
@@ -494,24 +510,24 @@ export default function Review() {
pipeline: [
{
fromLabel: 'Tasks',
fromValue: 0,
fromValue: totalTasks,
fromHref: '/writer/tasks',
actionLabel: 'Generate Content',
toLabel: 'Drafts',
toValue: 0,
toValue: totalDrafts,
toHref: '/writer/content',
progress: 0,
progress: totalTasks > 0 ? Math.round((totalDrafts / totalTasks) * 100) : 0,
color: 'blue',
},
{
fromLabel: 'Drafts',
fromValue: 0,
fromValue: totalDrafts,
fromHref: '/writer/content',
actionLabel: 'Generate Images',
toLabel: 'Images',
toValue: totalImagesCount,
toHref: '/writer/images',
progress: 0,
progress: totalDrafts > 0 ? Math.round((totalImagesCount / totalDrafts) * 100) : 0,
color: 'purple',
},
{
@@ -520,9 +536,9 @@ export default function Review() {
fromHref: '/writer/review',
actionLabel: 'Review & Publish',
toLabel: 'Published',
toValue: 0,
toHref: '/writer/published',
progress: 0,
toValue: totalApproved,
toHref: '/writer/approved',
progress: totalCount > 0 ? Math.round((totalApproved / (totalCount + totalApproved)) * 100) : 0,
color: 'green',
},
],
@@ -530,7 +546,7 @@ export default function Review() {
{ label: 'Tasks', href: '/writer/tasks' },
{ label: 'Content', href: '/writer/content' },
{ label: 'Images', href: '/writer/images' },
{ label: 'Published', href: '/writer/published' },
{ label: 'Published', href: '/writer/approved' },
],
}}
completion={{
@@ -541,9 +557,9 @@ export default function Review() {
{ label: 'Ideas Generated', value: 0, color: 'amber' },
],
writerItems: [
{ label: 'Content Generated', value: 0, color: 'blue' },
{ label: 'Content Generated', value: totalDrafts + totalCount + totalApproved, color: 'blue' },
{ label: 'Images Created', value: totalImagesCount, color: 'purple' },
{ label: 'Articles Published', value: 0, color: 'green' },
{ label: 'Articles Published', value: totalApproved, color: 'green' },
],
analyticsHref: '/account/usage',
}}