fix: React error #301 — load() in render body → useEffect

Причина: load() вызывался прямо в теле компонента (не в useEffect),
что триггерило setState → re-render → load() → бесконечный цикл.

Исправлено в AdminPanel.js:
  SpendingSection: if (!data && !loading) load(period) → useEffect
  DashboardSection: if (!data...) { load() } × 2 → useEffect
  SettingsSection: if (!loaded && !loading) → useEffect
  PlansSection: if (loading && !plans.length) → useEffect

Добавлен useEffect в import.
This commit is contained in:
Ник (Claude)
2026-06-13 23:31:51 +03:00
parent a3c1fa0c65
commit 836e20e57e
+5 -6
View File
@@ -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 (
<div className="space-y-6">
@@ -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: '🟣' };