forked from admin/zeropost-tool
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:
@@ -1,5 +1,5 @@
|
|||||||
'use client';
|
'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 { 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 Link from 'next/link';
|
||||||
import AdminBilling from './admin/AdminBilling';
|
import AdminBilling from './admin/AdminBilling';
|
||||||
@@ -128,7 +128,7 @@ function SettingsSection({ categories }) {
|
|||||||
setLoading(false);
|
setLoading(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!loaded && !loading) { load(); }
|
useEffect(() => { load(); }, []);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="space-y-6">
|
<div className="space-y-6">
|
||||||
@@ -258,7 +258,7 @@ function SpendingSection() {
|
|||||||
setLoading(false);
|
setLoading(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!data && !loading) load(period);
|
useEffect(() => { load(period); }, []);
|
||||||
|
|
||||||
const totals = data?.totals || {};
|
const totals = data?.totals || {};
|
||||||
const aiprimetech = byProv?.breakdown?.find(b => b.key === 'aiprimetech');
|
const aiprimetech = byProv?.breakdown?.find(b => b.key === 'aiprimetech');
|
||||||
@@ -412,7 +412,7 @@ function PlansSection() {
|
|||||||
setSaving(s => ({ ...s, [`cost_${cost.operation}`]: false }));
|
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' };
|
const PLAN_LABELS = { free: 'Free', starter: 'Starter', pro: 'Pro', business: 'Business' };
|
||||||
|
|
||||||
@@ -507,8 +507,7 @@ function DashboardSection() {
|
|||||||
setLoading(false);
|
setLoading(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!data && !loading) load();
|
useEffect(() => { load(); }, []);
|
||||||
if (!data && loading) { load(); }
|
|
||||||
|
|
||||||
const PLATFORM_ICONS = { telegram: '✈️', vk: '🔵', max: '🟣' };
|
const PLATFORM_ICONS = { telegram: '✈️', vk: '🔵', max: '🟣' };
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user