Update Home.tsx

This commit is contained in:
Desktop
2025-11-13 01:48:09 +05:00
parent fa94b5fe7a
commit 085e9a33ce

View File

@@ -1,4 +1,4 @@
import { useEffect, useState } from "react";
import React, { useEffect, useState } from "react";
import { Link } from "react-router";
import PageMeta from "../../components/common/PageMeta";
import CreditBalanceWidget from "../../components/dashboard/CreditBalanceWidget";
@@ -134,14 +134,15 @@ export default function Home() {
try {
setLoading(true);
// Fetch all data in parallel (without site/sector filters for app-wide view)
// Fetch account-level data (all sites in account) - no site/sector filters
// This shows aggregated data across all sites for account-wide insights
const [keywordsRes, clustersRes, ideasRes, tasksRes, contentRes, imagesRes] = await Promise.all([
fetchKeywords({ page_size: 1 }), // Just get count
fetchClusters({ page_size: 1 }),
fetchContentIdeas({ page_size: 1 }),
fetchTasks({ page_size: 1 }),
fetchContent({ page_size: 1 }),
fetchContentImages({ page_size: 1 })
fetchKeywords({ page_size: 1, site_id: undefined }), // Account-level: all sites
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;
@@ -232,9 +233,14 @@ export default function Home() {
{/* App-Wide Insights */}
<div className="mb-8">
<h2 className="text-2xl font-bold text-gray-900 dark:text-white mb-6">
App-Wide Insights
</h2>
<div className="flex items-center justify-between mb-6">
<h2 className="text-2xl font-bold text-gray-900 dark:text-white">
Account-Wide Insights
</h2>
<span className="text-sm text-gray-500 dark:text-gray-400">
All sites aggregated
</span>
</div>
{loading ? (
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4">
{[1, 2, 3, 4].map((i) => (
@@ -289,8 +295,10 @@ export default function Home() {
<Card className="p-6 hover:shadow-lg transition-all duration-200 border-2 hover:border-brand-500 dark:hover:border-brand-400 h-full">
<div className="flex flex-col items-center text-center">
<div className={`w-16 h-16 rounded-xl ${stepColors[step.color as keyof typeof stepColors]} flex items-center justify-center mb-4 group-hover:scale-110 transition-transform`}>
<div className="size-8">
{step.icon}
<div className="w-8 h-8 flex items-center justify-center flex-shrink-0">
{React.cloneElement(step.icon as React.ReactElement, {
className: 'w-8 h-8 flex-shrink-0'
})}
</div>
</div>
<div className="text-sm font-semibold text-gray-500 dark:text-gray-400 mb-1">