import { usePrimaryPage, useSecondaryPage } from '@/PageManager' import RelaySimpleInfo from '@/components/RelaySimpleInfo' import { Button } from '@/components/ui/button' import { RECOMMENDED_RELAYS } from '@/constants' import SecondaryPageLayout from '@/layouts/SecondaryPageLayout' import { toRelay } from '@/lib/link' import relayInfoService from '@/services/relay-info.service' import { TNip66RelayInfo } from '@/types' import { ArrowRight, Server } from 'lucide-react' import { forwardRef, useEffect, useState } from 'react' import { useTranslation } from 'react-i18next' const HomePage = forwardRef(({ index }: { index?: number }, ref) => { const { t } = useTranslation() const { navigate } = usePrimaryPage() const { push } = useSecondaryPage() const [recommendedRelayInfos, setRecommendedRelayInfos] = useState([]) useEffect(() => { const init = async () => { try { const relays = await relayInfoService.getRelayInfos(RECOMMENDED_RELAYS) setRecommendedRelayInfos(relays.filter(Boolean) as TNip66RelayInfo[]) } catch (error) { console.error('Failed to fetch recommended relays:', error) } } init() }, []) if (!recommendedRelayInfos.length) { return (
{t('Welcome! 🥳')}
) } return (
{t('Recommended relays')}
} hideBackButton >
{recommendedRelayInfos.map((relayInfo) => ( { e.stopPropagation() push(toRelay(relayInfo.url)) }} /> ))}
) }) HomePage.displayName = 'HomePage' export default HomePage