import { router } from 'expo-router'; import { useState } from 'react'; import { Image, Pressable, Text, View } from 'react-native'; import { OrderCard } from '../components/OrderCard'; import { BackBar, Button, Card, ErrorBox, H1, Loading, P, Screen, s } from '../components/ui'; import { api, formatMoney, invalidateAll, useMerch, type Order } from '../lib/api'; import { colors, fonts, radius } from '../lib/theme'; type Pick = { size: string | null; qty: number }; export default function Merch() { const q = useMerch(); const [picks, setPicks] = useState>({}); const [busy, setBusy] = useState(false); const [error, setError] = useState(null); const [order, setOrder] = useState(null); const items = q.data ?? []; const chosen = items.filter((i) => (picks[i.id]?.qty ?? 0) > 0); const total = chosen.reduce((sum, i) => sum + i.priceMinor * picks[i.id]!.qty, 0); const missingSize = chosen.some((i) => i.sizes.length > 0 && !picks[i.id]!.size); const set = (id: string, patch: Partial) => setPicks((p) => ({ ...p, [id]: { size: null, qty: 0, ...p[id], ...patch } })); async function place() { setBusy(true); setError(null); try { const o = await api('/merch-orders', { body: { items: chosen.map((i) => ({ merchItemId: i.id, qty: picks[i.id]!.qty, ...(picks[i.id]!.size ? { size: picks[i.id]!.size } : {}), })), }, }); setOrder(o); setPicks({}); void invalidateAll(); } catch (e) { setError((e as Error).message); } finally { setBusy(false); } } if (order) { return ( router.back()} />}>

Pay and collect at the GRV booth

Show this QR at the GRV booth. You'll pay there and pick up your merch.