"use client"; import { useEffect, useMemo, useState } from "react"; type ShamePhoto = { name: string; path: string; url: string; htmlUrl: string; }; type PhotoResponse = { photos: ShamePhoto[]; repo: string | null; path: string; branch?: string | null; message: string | null; }; export default function Home() { const [data, setData] = useState(null); const [isLoading, setIsLoading] = useState(false); const [error, setError] = useState(null); useEffect(() => { const controller = new AbortController(); async function loadPhotos() { setIsLoading(true); setError(null); try { const response = await fetch("/api/github-photos", { signal: controller.signal }); const nextData = (await response.json()) as PhotoResponse; setData(nextData); if (!response.ok) { setError(nextData.message || "Could not load photos from GitHub."); } } catch (nextError) { if (nextError instanceof DOMException && nextError.name === "AbortError") { return; } setError("Could not reach the photo source."); } finally { setIsLoading(false); } } loadPhotos(); return () => controller.abort(); }, []); const repoLabel = data?.repo ?? "GitHub source not set"; const boardStamp = useMemo(() => { const count = data?.photos.length ?? 0; if (count === 0) { return "Empty"; } return `${count} filed`; }, [data?.photos.length]); return (

Доска позора

тут только самое позорное.

{boardStamp} {repoLabel}
{isLoading ?
Загружаю фотографии с GitHub...
: null} {!isLoading && error ?
{error}
: null} {!isLoading && !error && data?.message ?
{data.message}
: null} {data?.photos.map((photo, index) => (
{photo.name}
#{String(index + 1).padStart(2, "0")} {photo.name}
))}
); }