'use client'; import Link from 'next/link'; import { useRouter } from 'next/navigation'; import { useEffect, useState } from 'react'; import { Sparkles, LogOut, Settings2, CalendarDays, TrendingUp, Coins } from 'lucide-react'; import ThemeToggle from './ThemeToggle'; export default function Header({ user }) { const router = useRouter(); const [credits, setCredits] = useState(null); useEffect(() => { if (!user) return; fetch('/api/billing/balance') .then(r => r.json()) .then(d => setCredits(d.isUnlimited ? '∞' : d.credits)) .catch(() => {}); }, [user?.id]); async function logout() { await fetch('/api/auth/logout', { method: 'POST' }); router.push('/login'); } return (
ZeroPost
{/* Баланс кредитов */} {credits !== null && ( {credits} кр )} {user?.isAdmin && ( Система )} {user?.email}
); }