diff --git a/components/AdminPanel.js b/components/AdminPanel.js index cd3486b..dcd144b 100644 --- a/components/AdminPanel.js +++ b/components/AdminPanel.js @@ -1,5 +1,5 @@ 'use client'; -import { useState } from 'react'; +import { useState, useEffect } from 'react'; import { Settings2, CreditCard, TrendingUp, Users, ChevronRight, Loader2, Eye, EyeOff, Save, RefreshCw, Check, AlertCircle, BarChart3, ArrowLeft, Zap, Tag, AlertTriangle, BookOpen, Sliders, Mail } from 'lucide-react'; import Link from 'next/link'; import AdminBilling from './admin/AdminBilling'; @@ -128,7 +128,7 @@ function SettingsSection({ categories }) { setLoading(false); } - if (!loaded && !loading) { load(); } + useEffect(() => { load(); }, []); return (
@@ -258,7 +258,7 @@ function SpendingSection() { setLoading(false); } - if (!data && !loading) load(period); + useEffect(() => { load(period); }, []); const totals = data?.totals || {}; const aiprimetech = byProv?.breakdown?.find(b => b.key === 'aiprimetech'); @@ -412,7 +412,7 @@ function PlansSection() { setSaving(s => ({ ...s, [`cost_${cost.operation}`]: false })); } - if (loading && !plans.length) { load(); } + useEffect(() => { load(); }, []); const PLAN_LABELS = { free: 'Free', starter: 'Starter', pro: 'Pro', business: 'Business' }; @@ -507,8 +507,7 @@ function DashboardSection() { setLoading(false); } - if (!data && !loading) load(); - if (!data && loading) { load(); } + useEffect(() => { load(); }, []); const PLATFORM_ICONS = { telegram: '✈️', vk: '🔵', max: '🟣' };