widgets and other fixes

This commit is contained in:
IGNY8 VPS (Salman)
2026-01-11 15:24:52 +00:00
parent 747770ac58
commit e9369df151
16 changed files with 761 additions and 277 deletions

View File

@@ -48,6 +48,7 @@ export default function Home() {
const [sites, setSites] = useState<Site[]>([]);
const [sitesLoading, setSitesLoading] = useState(true);
const [siteFilter, setSiteFilter] = useState<'all' | number>('all');
const [aiPeriod, setAIPeriod] = useState<'7d' | '30d' | '90d'>('7d');
const [showAddSite, setShowAddSite] = useState(false);
const [loading, setLoading] = useState(true);
const [subscription, setSubscription] = useState<Subscription | null>(null);
@@ -170,11 +171,12 @@ export default function Home() {
setLoading(true);
const siteId = siteFilter === 'all' ? undefined : siteFilter;
const periodDays = aiPeriod === '7d' ? 7 : aiPeriod === '30d' ? 30 : 90;
// Fetch real dashboard stats from API
const stats = await getDashboardStats({
site_id: siteId,
days: 7
days: periodDays
});
// Update pipeline data from real API data
@@ -274,7 +276,7 @@ export default function Home() {
}
setAIOperations({
period: stats.ai_operations.period,
period: aiPeriod,
operations: mappedOperations,
totals: stats.ai_operations.totals,
});
@@ -304,14 +306,14 @@ export default function Home() {
} finally {
setLoading(false);
}
}, [siteFilter, sites, toast]);
}, [siteFilter, sites, aiPeriod, toast]);
// Fetch dashboard data when filter changes
useEffect(() => {
if (!sitesLoading) {
fetchDashboardData();
}
}, [siteFilter, sitesLoading, fetchDashboardData]);
}, [siteFilter, aiPeriod, sitesLoading, fetchDashboardData]);
const handleAddSiteClick = () => {
setShowAddSite(true);
@@ -329,8 +331,7 @@ export default function Home() {
};
const handlePeriodChange = (period: '7d' | '30d' | '90d') => {
setAIOperations(prev => ({ ...prev, period }));
// In real implementation, would refetch data for new period
setAIPeriod(period);
};
const handleRunAutomation = () => {