Creditsupdates in fotoer wdigets adn hoemapge and singe site settigns page #Run MIgration 0033 #MAJOR
This commit is contained in:
@@ -370,11 +370,12 @@ export default function Home() {
|
||||
onAddSite={canAddMoreSites ? handleAddSiteClick : undefined}
|
||||
maxSites={maxSites}
|
||||
/>
|
||||
<CreditsUsageWidget
|
||||
<CreditsUsageWidget
|
||||
balance={balance}
|
||||
aiOperations={{
|
||||
total: aiOperations.totals.count,
|
||||
period: aiOperations.period === '7d' ? 'Last 7 days' : aiOperations.period === '30d' ? 'Last 30 days' : 'Last 90 days',
|
||||
siteName: siteFilter !== 'all' ? sites.find(s => s.id === siteFilter)?.name : undefined,
|
||||
}}
|
||||
loading={loading}
|
||||
/>
|
||||
|
||||
@@ -85,6 +85,11 @@ export default function SiteDashboard() {
|
||||
});
|
||||
const [operations, setOperations] = useState<OperationStat[]>([]);
|
||||
const [loading, setLoading] = useState(true);
|
||||
const [aiPeriod, setAiPeriod] = useState<'7d' | '30d' | '90d'>('7d');
|
||||
|
||||
const handlePeriodChange = (period: '7d' | '30d' | '90d') => {
|
||||
setAiPeriod(period);
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
if (siteId) {
|
||||
@@ -100,7 +105,7 @@ export default function SiteDashboard() {
|
||||
loadSiteData(currentSiteId);
|
||||
loadBalance();
|
||||
}
|
||||
}, [siteId]);
|
||||
}, [siteId, aiPeriod]);
|
||||
|
||||
const loadSiteData = async (currentSiteId: string) => {
|
||||
try {
|
||||
@@ -175,7 +180,8 @@ export default function SiteDashboard() {
|
||||
|
||||
// Load operation stats from real API data
|
||||
try {
|
||||
const stats = await getDashboardStats({ site_id: Number(currentSiteId), days: 7 });
|
||||
const periodDays = aiPeriod === '7d' ? 7 : aiPeriod === '30d' ? 30 : 90;
|
||||
const stats = await getDashboardStats({ site_id: Number(currentSiteId), days: periodDays });
|
||||
|
||||
// Map operation types from API to display types
|
||||
const operationTypeMap: Record<string, 'clustering' | 'ideas' | 'content' | 'images'> = {
|
||||
@@ -354,7 +360,12 @@ export default function SiteDashboard() {
|
||||
authorProfilesCount={setupState.authorProfilesCount}
|
||||
/>
|
||||
|
||||
<OperationsCostsWidget operations={operations} />
|
||||
<OperationsCostsWidget
|
||||
operations={operations}
|
||||
period={aiPeriod}
|
||||
loading={loading}
|
||||
onPeriodChange={handlePeriodChange}
|
||||
/>
|
||||
|
||||
<CreditAvailabilityWidget
|
||||
availableCredits={balance?.credits_remaining ?? 0}
|
||||
|
||||
Reference in New Issue
Block a user