import { router } from 'expo-router'; import { Image, Pressable, Text, View } from 'react-native'; import { Button, Card, ErrorBox, H2, Icon, Loading, P, PatternHeader, Screen, s, type IconName, } from '../../components/ui'; import { useMe, useRaffles } from '../../lib/api'; import { colors, fonts } from '../../lib/theme'; function Progress({ label, found, total, icon, onPress, }: { label: string; found: number; total: number; icon: IconName; onPress: () => void; }) { const pct = total ? Math.min(1, found / total) : 0; return ( {label} {found} / {total} ); } export default function Home() { const me = useMe(); const raffles = useRaffles(); const m = me.data; const header = (

{m?.user.name ? `Hi ${m.user.name.split(' ')[0]}` : 'Welcome to the GRV Summit'}

{m?.points ?? '–'} points router.push('/leaderboard')} style={{ alignItems: 'flex-end', marginBottom: 10 }} > Rank {m?.rank ? `#${m.rank}` : '–'}
); const refresh = () => { void me.refetch(); void raffles.refetch(); }; const eligible = raffles.data?.filter((r) => r.eligible && !r.drawnAt).length ?? 0; const nextRaffle = raffles.data ?.filter((r) => !r.eligible && !r.drawnAt) .sort((a, b) => a.minPoints - b.minPoints)[0]; return ( {me.isPending ? ( ) : me.error ? ( ) : ( m && ( <>