'use client'; import { useState, useEffect, useCallback } from 'react'; import { motion } from 'framer-motion'; import { RefreshCw, ExternalLink, Loader2, Sparkles, Globe, Cpu, DollarSign, Dumbbell } from 'lucide-react'; import * as Tabs from '@radix-ui/react-tabs'; import { fetchDiscover } from '@/lib/api'; import type { DiscoverItem } from '@/lib/types'; const topics = [ { id: 'tech', label: 'Технологии', icon: Cpu }, { id: 'finance', label: 'Финансы', icon: DollarSign }, { id: 'sports', label: 'Спорт', icon: Dumbbell }, ] as const; export default function DiscoverPage() { const [items, setItems] = useState([]); const [isLoading, setIsLoading] = useState(true); const [topic, setTopic] = useState('tech'); const load = useCallback(async () => { setIsLoading(true); try { const data = await fetchDiscover(topic, 'russia'); setItems(data); } catch { setItems([]); } finally { setIsLoading(false); } }, [topic]); useEffect(() => { load(); }, [load]); return (
{/* Header */}

Discover

Актуальные новости и события

{/* Topic Tabs */} {topics.map((t) => ( {t.label} ))} {/* Content */} {isLoading ? (

Загрузка новостей...

) : items.length === 0 ? (

Нет новостей по выбранной теме

) : (
{items.map((item, i) => ( {/* Thumbnail */} {item.thumbnail && (
{ (e.target as HTMLImageElement).style.display = 'none'; }} />
)} {/* Content */}
{item.title}

{item.content}

{/* Actions */}
Читать {item.sourcesCount && item.sourcesCount > 1 && ( {item.sourcesCount} источников )}
))}
)}
); }