import Head from 'next/head' import type { Article } from '@/types/nostr' import { ArticleFiltersComponent, type ArticleFilters } from '@/components/ArticleFilters' import { CategoryTabs } from '@/components/CategoryTabs' import { SearchBar } from '@/components/SearchBar' import { ArticlesList } from '@/components/ArticlesList' import { AuthorsList } from '@/components/AuthorsList' import { PageHeader } from '@/components/PageHeader' import { Footer } from '@/components/Footer' import { SkipLinks } from '@/components/SkipLinks' import type { Dispatch, SetStateAction } from 'react' import { t } from '@/lib/i18n' interface HomeViewProps { searchQuery: string setSearchQuery: Dispatch> selectedCategory: ArticleFilters['category'] setSelectedCategory: Dispatch> filters: ArticleFilters setFilters: Dispatch> articles: Article[] allArticles: Article[] authors: Article[] allAuthors: Article[] loading: boolean error: string | null onUnlock: (article: Article) => void unlockedArticles: Set } function HomeHead(): React.ReactElement { return ( zapwall.fr ) } function ArticlesHero({ searchQuery, setSearchQuery, selectedCategory, setSelectedCategory, }: Pick): React.ReactElement { return (
) } function HomeContent(props: HomeViewProps): React.ReactElement { const shouldShowFilters = !props.loading && props.allArticles.length > 0 const shouldShowAuthors = props.selectedCategory !== null && props.selectedCategory !== 'all' // At startup, we don't know yet if we're loading articles or authors // Use a generic loading message until we have content const isInitialLoad = props.loading && props.allArticles.length === 0 && props.allAuthors.length === 0 return (
{shouldShowFilters && !shouldShowAuthors && (
)}
) } function HomeMainList(params: { isInitialLoad: boolean shouldShowAuthors: boolean articlesListProps: Parameters[0] authorsListProps: Parameters[0] }): React.ReactElement { if (params.isInitialLoad) { return (

{t('common.loading')}

) } if (params.shouldShowAuthors) { return } return } function buildArticlesListProps(params: { articles: Article[] allArticles: Article[] loading: boolean isInitialLoad: boolean error: string | null onUnlock: (article: Article) => void unlockedArticles: Set }): Parameters[0] { return { articles: params.articles, allArticles: params.allArticles, loading: params.loading && !params.isInitialLoad, error: params.error, onUnlock: params.onUnlock, unlockedArticles: params.unlockedArticles, } } function buildAuthorsListProps(params: { authors: Article[] allAuthors: Article[] loading: boolean isInitialLoad: boolean error: string | null }): Parameters[0] { return { authors: params.authors, allAuthors: params.allAuthors, loading: params.loading && !params.isInitialLoad, error: params.error, } } export function HomeView(props: HomeViewProps): React.ReactElement { return ( <>
) }