import {useEffect, useState} from "react"; import {newsApi} from "@/api"; import type {NewsDto} from "@/api/schema.gen"; import {Card, CardHeader, CardTitle, CardContent, CardFooter} from "@/components/ui/card"; export function NewsPage() { const [news, setNews] = useState([]); const [loading, setLoading] = useState(true); const [error, setError] = useState(null); useEffect(() => { newsApi.list({published: true}) .then(setNews) .catch(() => setError("Failed to load news")) .finally(() => setLoading(false)); }, []); if (loading) return

Loading…

; if (error) return

{error}

; if (news.length === 0) return

No news yet.

; return (

News

{news.map(n => ( {n.title}

{n.body}

{n.author ?? "—"} · {new Date(n.created_at).toLocaleDateString("ru-RU")}
))}
); }