Add GRV Summit attendee app (Expo SDK 58)

Expo Router app for summit attendees: email OTP login, booth and investee
QR scanning (camera + manual entry, /q/<token> universal links), mystery
investee celebration, points/rank/progress home, leaderboard, raffles,
merch ordering with pickup QR, and ticket QRs. Built against the attendee,
auth and public endpoints in GRV-Backend/API.md. Theme, fonts, icon and
splash follow the GRVSummit site.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
kirukib 2026-11-17 21:33:17 +03:00
parent a03acc2ac7
commit 1ed5e9729e
39 changed files with 8506 additions and 0 deletions

6
.env.example Normal file
View File

@ -0,0 +1,6 @@
# Public runtime config (Expo inlines EXPO_PUBLIC_* at build time).
# On a physical device use your machine's LAN IP, e.g. http://192.168.1.20:4000
EXPO_PUBLIC_API_URL=http://localhost:4000
# EAS build only
EAS_PROJECT_ID=
APPLE_TEAM_ID=

43
.gitignore vendored Normal file
View File

@ -0,0 +1,43 @@
# Learn more https://docs.github.com/en/get-started/getting-started-with-git/ignoring-files
# dependencies
node_modules/
# Expo
.expo/
dist/
web-build/
expo-env.d.ts
# Native
.kotlin/
*.orig.*
*.jks
*.p8
*.p12
*.key
*.mobileprovision
# Metro
.metro-health-check*
# debug
npm-debug.*
yarn-debug.*
yarn-error.*
# macOS
.DS_Store
*.pem
# local env files
.env*.local
# typescript
*.tsbuildinfo
# generated native folders
/ios
/android
.env

1
.npmrc Normal file
View File

@ -0,0 +1 @@
node-linker=hoisted

5
.prettierrc.json Normal file
View File

@ -0,0 +1,5 @@
{
"singleQuote": true,
"trailingComma": "all",
"printWidth": 100
}

View File

@ -0,0 +1,94 @@
# GRV Summit — attendee app
Expo (SDK 58, expo-router) app for GRV Summit attendees: scan booth and investee QR codes for
points, find the mystery future investee (double points), follow the leaderboard and raffles,
order merch for pickup at the GRV booth and show ticket QRs.
Backend: `../GRV-Backend` (NestJS). Contract: `GRV-Backend/API.md`. The app uses only the auth,
attendee and public (`/merch`) endpoints.
## Setup
```sh
pnpm install
cp .env.example .env # set EXPO_PUBLIC_API_URL
pnpm start # Expo dev server
```
| Env | Default | Notes |
|---|---|---|
| `EXPO_PUBLIC_API_URL` | `http://localhost:4000` | Inlined at build time. On a phone use your machine's LAN IP (`http://192.168.x.x:4000`); `localhost` is the phone itself. |
| `EAS_PROJECT_ID` | — | EAS builds only (`eas init` prints it). |
| `APPLE_TEAM_ID` | — | Needed for iOS associated domains / signing. |
Checks: `pnpm exec tsc --noEmit`, `npx expo-doctor`, `npx expo export --platform web`.
## Running
The QR scanner needs a real device camera (the web build and simulators fall back to typing the
code under the QR).
- **Expo Go**: `pnpm start`, scan the terminal QR with Expo Go (Android) or the Camera app (iOS).
Everything works except universal/app links (`https://grv.ethiopiatrustfund.org/q/...`);
test those with the dev client.
- **Dev client**: `eas build --profile development --platform ios|android`, install it, then
`pnpm start` and open the project from the dev client.
Sign-in is email + 6-digit code. In backend dev mode the code is printed to the backend console.
Attendees should use the email they bought their ticket with so their ticket QR appears under **Me**.
## EAS builds
```sh
npm i -g eas-cli
eas init # once; put the id in EAS_PROJECT_ID
eas build --profile preview --platform android # internal APK/AAB for testing
eas build --profile production --platform all # store builds
eas submit --profile production
```
Set `EXPO_PUBLIC_API_URL` (production API) in the EAS environment for each profile.
Bundle id / package: `org.ethiopiatrustfund.grvsummit`. Scheme: `grvsummit`.
## Deep links
Printed checkpoint QRs encode `https://grv.ethiopiatrustfund.org/q/<token>`. With the app
installed, the phone's camera opens the app on `src/app/q/[token].tsx`, which calls
`POST /scan` once and shows the result (signed-out users go through login first and come back).
`grvsummit://q/<token>` works too (handy for testing: `npx uri-scheme open grvsummit://q/abc --ios`).
Configured in `app.json`:
- iOS `associatedDomains: ["applinks:grv.ethiopiatrustfund.org"]`
- Android `intentFilters` for `https://grv.ethiopiatrustfund.org/q/*` with `autoVerify`
The site must serve the verification files (not done here; belongs in the GRVSummit site):
- `https://grv.ethiopiatrustfund.org/.well-known/apple-app-site-association`
```json
{ "applinks": { "details": [{ "appIDs": ["<TEAMID>.org.ethiopiatrustfund.grvsummit"], "components": [{ "/": "/q/*" }] }] } }
```
- `https://grv.ethiopiatrustfund.org/.well-known/assetlinks.json` with the package name and the
release signing SHA-256 (`eas credentials` shows it).
Without the app, the same URL opens the website's `/q/<token>` page.
## Layout
```
src/app/_layout.tsx fonts, React Query, auth gate (→ /login?next=…)
src/app/login.tsx email → code → optional name (PATCH /me)
src/app/(tabs)/ index (home), booths, scan, investees, me
src/app/q/[token].tsx scan result (success / mystery celebration / already scanned / not a GRV code)
src/app/leaderboard.tsx, raffles.tsx, merch.tsx
src/components/ui.tsx icons, text, cards, buttons, screen shells
src/components/OrderCard.tsx merch order + pickup QR (order number)
src/lib/api.ts fetch wrapper, session (secure-store), API types, queries, money format
src/lib/theme.ts colours/fonts from GRVSummit/app/globals.css
assets/ icon/splash/pattern PNGs rendered from GRVLogo.png and mainwhite.svg
```
Fonts: Antebas (headings) and DM Sans (body). The Antebas files are the Fontspring **demo**
build — digits and punctuation are watermark glyphs, so headings with numbers or punctuation use
DM Sans. Swap in the licensed OTFs in `assets/fonts/` before the store release.

12
app.config.js Normal file
View File

@ -0,0 +1,12 @@
// Env-driven overrides on top of app.json (same shape as Yaltopia-Booking customer).
module.exports = ({ config }) => {
const projectId = process.env.EAS_PROJECT_ID || config.extra?.eas?.projectId;
return {
...config,
ios: {
...config.ios,
...(process.env.APPLE_TEAM_ID ? { appleTeamId: process.env.APPLE_TEAM_ID } : {}),
},
extra: { ...config.extra, ...(projectId ? { eas: { ...config.extra?.eas, projectId } } : {}) },
};
};

62
app.json Normal file
View File

@ -0,0 +1,62 @@
{
"expo": {
"name": "GRV Summit",
"slug": "grv-summit",
"version": "1.0.0",
"scheme": "grvsummit",
"orientation": "portrait",
"icon": "./assets/icon.png",
"userInterfaceStyle": "light",
"ios": {
"supportsTablet": false,
"bundleIdentifier": "org.ethiopiatrustfund.grvsummit",
"associatedDomains": ["applinks:grv.ethiopiatrustfund.org"],
"infoPlist": {
"ITSAppUsesNonExemptEncryption": false
}
},
"android": {
"package": "org.ethiopiatrustfund.grvsummit",
"adaptiveIcon": {
"foregroundImage": "./assets/adaptive-icon.png",
"backgroundColor": "#30614c"
},
"intentFilters": [
{
"action": "VIEW",
"autoVerify": true,
"data": [{ "scheme": "https", "host": "grv.ethiopiatrustfund.org", "pathPrefix": "/q/" }],
"category": ["BROWSABLE", "DEFAULT"]
}
]
},
"web": {
"bundler": "metro",
"output": "single",
"favicon": "./assets/favicon.png",
"themeColor": "#30614c",
"backgroundColor": "#fafafa"
},
"plugins": [
"expo-router",
"expo-secure-store",
"expo-font",
[
"expo-camera",
{
"cameraPermission": "GRV Summit uses the camera to scan booth and investee QR codes.",
"recordAudioAndroid": false
}
],
[
"expo-splash-screen",
{
"image": "./assets/splash.png",
"imageWidth": 240,
"resizeMode": "contain",
"backgroundColor": "#30614c"
}
]
]
}
}

BIN
assets/adaptive-icon.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 146 KiB

BIN
assets/favicon.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
assets/icon.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 287 KiB

BIN
assets/logo-white.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 60 KiB

BIN
assets/logo.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 70 KiB

BIN
assets/pattern.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 345 KiB

BIN
assets/splash.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 113 KiB

26
eas.json Normal file
View File

@ -0,0 +1,26 @@
{
"cli": {
"version": ">= 18.0.5",
"appVersionSource": "remote"
},
"build": {
"development": {
"developmentClient": true,
"distribution": "internal",
"ios": { "simulator": false },
"node": "22.22.2"
},
"preview": {
"distribution": "internal",
"node": "22.22.2"
},
"production": {
"distribution": "store",
"autoIncrement": true,
"node": "22.22.2"
}
},
"submit": {
"production": {}
}
}

42
package.json Normal file
View File

@ -0,0 +1,42 @@
{
"name": "grv-summit",
"version": "1.0.0",
"main": "expo-router/entry",
"private": true,
"scripts": {
"start": "expo start",
"android": "expo start --android",
"ios": "expo start --ios",
"web": "expo start --web",
"typecheck": "tsc --noEmit"
},
"dependencies": {
"@expo-google-fonts/dm-sans": "^0.4.2",
"@expo/metro-runtime": "^58.0.16",
"@tanstack/react-query": "^5.104.3",
"expo": "~58.0.22",
"expo-camera": "~58.0.14",
"expo-constants": "~58.0.14",
"expo-dev-client": "~58.0.21",
"expo-font": "~58.0.11",
"expo-haptics": "~58.0.7",
"expo-linking": "~58.0.15",
"expo-router": "~58.0.29",
"expo-secure-store": "~58.0.2",
"expo-splash-screen": "~58.0.12",
"expo-status-bar": "~58.0.4",
"expo-system-ui": "~58.0.7",
"react": "19.3.0",
"react-dom": "19.3.0",
"react-native": "0.88.1",
"react-native-qrcode-svg": "^6.3.26",
"react-native-safe-area-context": "~5.11.1",
"react-native-screens": "~4.30.1",
"react-native-svg": "15.16.0",
"react-native-web": "~0.21.0"
},
"devDependencies": {
"@types/react": "~19.3.0",
"typescript": "~6.0.3"
}
}

6091
pnpm-lock.yaml Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,30 @@
import { Tabs } from 'expo-router/js-tabs';
import { Icon, type IconName } from '../../components/ui';
import { colors, fonts } from '../../lib/theme';
const tab = (title: string, icon: IconName) => ({
title,
tabBarIcon: ({ color }: { color: unknown }) => (
<Icon name={icon} color={String(color)} size={22} />
),
});
export default function TabsLayout() {
return (
<Tabs
screenOptions={{
headerShown: false,
tabBarActiveTintColor: colors.primary,
tabBarInactiveTintColor: colors.grey2,
tabBarLabelStyle: { fontFamily: fonts.medium, fontSize: 11 },
tabBarStyle: { backgroundColor: colors.white, borderTopColor: colors.grey3 },
}}
>
<Tabs.Screen name="index" options={tab('Home', 'home')} />
<Tabs.Screen name="booths" options={tab('Booths', 'store')} />
<Tabs.Screen name="scan" options={tab('Scan', 'scan')} />
<Tabs.Screen name="investees" options={tab('Investees', 'rocket')} />
<Tabs.Screen name="me" options={tab('Me', 'user')} />
</Tabs>
);
}

68
src/app/(tabs)/booths.tsx Normal file
View File

@ -0,0 +1,68 @@
import { Text, View } from 'react-native';
import { Card, CheckDot, ErrorBox, H1, Loading, P, Row, Screen, s } from '../../components/ui';
import { useCheckpoints } from '../../lib/api';
import { colors, fonts } from '../../lib/theme';
export default function Booths() {
const q = useCheckpoints('BOOTH');
const list = q.data ?? [];
const found = list.filter((c) => c.scanned).length;
return (
<Screen onRefresh={() => void q.refetch()} refreshing={q.isRefetching}>
<H1>Booths</H1>
<P muted>Visit exhibitor and partner booths and scan their QR to check them off.</P>
{q.isPending ? (
<Loading />
) : q.error ? (
<ErrorBox error={q.error} onRetry={() => void q.refetch()} />
) : (
<>
<Text style={[s.num, { fontSize: 16 }]}>
{found} of {list.length} visited
</Text>
<Card style={{ paddingVertical: 4 }}>
{list.length === 0 && (
<P muted style={{ paddingVertical: 12 }}>
Booths will appear here soon.
</P>
)}
{list.map((c, i) => (
<Row
key={c.id}
style={
i > 0 ? { borderTopWidth: 1, borderTopColor: colors.surfaceMuted } : undefined
}
>
<CheckDot done={!!c.scanned} />
<View style={{ flex: 1 }}>
<Text style={{ fontFamily: fonts.semibold, fontSize: 16, color: colors.ink }}>
{c.organisation ?? c.label}
</Text>
{(c.boothNumber || (c.organisation && c.label !== c.organisation)) && (
<P muted style={{ fontSize: 13 }}>
{[
c.boothNumber && `Booth ${c.boothNumber}`,
c.organisation && c.label !== c.organisation && c.label,
]
.filter(Boolean)
.join(' · ')}
</P>
)}
</View>
<Text
style={{
fontFamily: fonts.semibold,
color: c.scanned ? colors.primary : colors.grey2,
}}
>
+{c.points}
</Text>
</Row>
))}
</Card>
</>
)}
</Screen>
);
}

219
src/app/(tabs)/index.tsx Normal file
View File

@ -0,0 +1,219 @@
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 (
<Pressable onPress={onPress} style={{ flex: 1 }}>
<Card style={{ gap: 10 }}>
<View
style={{
width: 40,
height: 40,
borderRadius: 12,
backgroundColor: colors.surfaceMuted,
alignItems: 'center',
justifyContent: 'center',
}}
>
<Icon name={icon} color={colors.primary} />
</View>
<Text style={s.label}>{label}</Text>
<Text style={[s.num, { fontSize: 24 }]}>
{found}
<Text style={{ color: colors.grey2, fontSize: 16 }}> / {total}</Text>
</Text>
<View style={{ height: 6, borderRadius: 3, backgroundColor: colors.surfaceMuted }}>
<View
style={{
height: 6,
borderRadius: 3,
width: `${pct * 100}%`,
backgroundColor: colors.primary,
}}
/>
</View>
</Card>
</Pressable>
);
}
export default function Home() {
const me = useMe();
const raffles = useRaffles();
const m = me.data;
const header = (
<PatternHeader>
<Image
source={require('../../../assets/logo-white.png')}
style={{ width: 150, height: 32, marginTop: 8 }}
resizeMode="contain"
/>
<P style={{ color: colors.secondary, marginTop: 20 }}>
{m?.user.name ? `Hi ${m.user.name.split(' ')[0]}` : 'Welcome to the GRV Summit'}
</P>
<View style={{ flexDirection: 'row', alignItems: 'flex-end', marginTop: 4, gap: 16 }}>
<Text style={[s.num, { fontSize: 56, color: colors.white, lineHeight: 62 }]}>
{m?.points ?? '–'}
</Text>
<Text
style={{
fontFamily: fonts.semibold,
color: colors.white,
fontSize: 16,
marginBottom: 12,
}}
>
points
</Text>
<View style={{ flex: 1 }} />
<Pressable
onPress={() => router.push('/leaderboard')}
style={{ alignItems: 'flex-end', marginBottom: 10 }}
>
<Text style={[s.label, { color: colors.secondary }]}>Rank</Text>
<Text style={[s.num, { color: colors.white, fontSize: 24 }]}>
{m?.rank ? `#${m.rank}` : '–'}
</Text>
</Pressable>
</View>
</PatternHeader>
);
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 (
<Screen header={header} onRefresh={refresh} refreshing={me.isRefetching}>
{me.isPending ? (
<Loading />
) : me.error ? (
<ErrorBox error={me.error} onRetry={refresh} />
) : (
m && (
<>
<Button title="Scan a QR code" onPress={() => router.push('/scan')} />
<View style={{ flexDirection: 'row', gap: 12 }}>
<Progress
label="Booths"
icon="store"
found={m.progress.booths.found}
total={m.progress.booths.total}
onPress={() => router.push('/booths')}
/>
<Progress
label="Investees"
icon="rocket"
found={m.progress.startups.found}
total={m.progress.startups.total}
onPress={() => router.push('/investees')}
/>
</View>
<Pressable onPress={() => router.push('/investees')}>
<Card
tone={m.progress.mysteryFound ? 'muted' : 'white'}
style={{ flexDirection: 'row', alignItems: 'center', gap: 14 }}
>
<View
style={{
width: 48,
height: 48,
borderRadius: 24,
backgroundColor: colors.primary,
alignItems: 'center',
justifyContent: 'center',
}}
>
{m.progress.mysteryFound ? (
<Icon name="check" color={colors.white} />
) : (
<Text style={[s.num, { color: colors.white, fontSize: 24 }]}>?</Text>
)}
</View>
<View style={{ flex: 1 }}>
<H2 style={{ fontSize: 17 }}>Mystery investee</H2>
<P muted style={{ fontSize: 14 }}>
{m.progress.mysteryFound
? 'Found! You earned double points.'
: 'One future investee is hiding in the crowd. Find them for double points.'}
</P>
</View>
</Card>
</Pressable>
<Pressable onPress={() => router.push('/raffles')}>
<Card style={{ flexDirection: 'row', alignItems: 'center', gap: 14 }}>
<Icon name="gift" color={colors.primary} size={28} />
<View style={{ flex: 1 }}>
<H2 style={{ fontSize: 17 }}>Raffles</H2>
<P muted style={{ fontSize: 14 }}>
{raffles.isPending
? 'Loading…'
: eligible
? `You're in ${eligible} draw${eligible > 1 ? 's' : ''}.`
: nextRaffle
? `${Math.max(0, nextRaffle.minPoints - m.points)} more points to enter "${nextRaffle.name}".`
: 'Prizes are drawn at the end of the summit.'}
{eligible && nextRaffle
? ` ${nextRaffle.minPoints - m.points} more for "${nextRaffle.name}".`
: ''}
</P>
</View>
<Icon name="chevron" color={colors.grey2} />
</Card>
</Pressable>
<Pressable onPress={() => router.push('/merch')}>
<Card style={{ flexDirection: 'row', alignItems: 'center', gap: 14 }}>
<Icon name="bag" color={colors.primary} size={28} />
<View style={{ flex: 1 }}>
<H2 style={{ fontSize: 17 }}>GRV merch</H2>
<P muted style={{ fontSize: 14 }}>
Order in the app, pay and collect at the GRV booth.
</P>
</View>
<Icon name="chevron" color={colors.grey2} />
</Card>
</Pressable>
</>
)
)}
</Screen>
);
}

View File

@ -0,0 +1,139 @@
import { Text, View } from 'react-native';
import {
Card,
CheckDot,
Icon,
ErrorBox,
H1,
H2,
Loading,
P,
Row,
Screen,
s,
} from '../../components/ui';
import { useCheckpoints, type Checkpoint } from '../../lib/api';
import { colors, fonts } from '../../lib/theme';
function groupByOrg(list: Checkpoint[]) {
const groups = new Map<string, Checkpoint[]>();
for (const c of list) {
const key = c.organisation ?? 'Other';
groups.set(key, [...(groups.get(key) ?? []), c]);
}
return [...groups.entries()];
}
export default function Investees() {
const members = useCheckpoints('STARTUP_MEMBER');
const mystery = useCheckpoints('MYSTERY_INVESTEE');
const refresh = () => {
void members.refetch();
void mystery.refetch();
};
const found = mystery.data?.find((c) => c.scanned);
return (
<Screen onRefresh={refresh} refreshing={members.isRefetching}>
<H1>Find our investees</H1>
<P muted>
Team members of startups we've invested in wear a QR on their badge or wristband. Find them
and scan it for points.
</P>
<Card
tone="muted"
style={{
flexDirection: 'row',
alignItems: 'center',
gap: 14,
borderColor: colors.secondary,
}}
>
<View
style={{
width: 56,
height: 56,
borderRadius: 16,
backgroundColor: colors.primary,
alignItems: 'center',
justifyContent: 'center',
}}
>
{found ? (
<Icon name="check" color={colors.white} size={30} />
) : (
<Text style={[s.num, { color: colors.white, fontSize: 30 }]}>?</Text>
)}
</View>
<View style={{ flex: 1 }}>
<H2 style={{ fontSize: 17 }}>Mystery future investee</H2>
<P style={{ fontSize: 14 }}>
{found
? `You found ${[found.personName, found.organisation].filter(Boolean).join(' of ') || 'them'}!`
: 'Someone here is our next investee and wears a hidden QR. Find them for double points.'}
</P>
</View>
</Card>
{members.isPending ? (
<Loading />
) : members.error ? (
<ErrorBox error={members.error} onRetry={refresh} />
) : members.data.length === 0 ? (
<P muted>Investee teams will appear here soon.</P>
) : (
groupByOrg(members.data).map(([org, people]) => {
const n = people.filter((p) => p.scanned).length;
return (
<Card key={org} style={{ paddingVertical: 8 }}>
<View
style={{
flexDirection: 'row',
justifyContent: 'space-between',
alignItems: 'center',
paddingVertical: 4,
}}
>
<Text style={{ fontFamily: fonts.bold, fontSize: 17, color: colors.ink, flex: 1 }}>
{org}
</Text>
<Text
style={{
fontFamily: fonts.semibold,
color: n === people.length ? colors.primary : colors.grey1,
}}
>
{n}/{people.length} found
</Text>
</View>
{people.map((p) => (
<Row key={p.id} style={{ paddingVertical: 8 }}>
<CheckDot done={!!p.scanned} />
<View style={{ flex: 1 }}>
<Text style={{ fontFamily: fonts.medium, color: colors.ink, fontSize: 15 }}>
{p.personName ?? p.label}
</Text>
{p.personName && (
<P muted style={{ fontSize: 13 }}>
{p.label}
</P>
)}
</View>
<Text
style={{
fontFamily: fonts.semibold,
color: p.scanned ? colors.primary : colors.grey2,
}}
>
{p.scanned ? 'Found' : `+${p.points}`}
</Text>
</Row>
))}
</Card>
);
})
)}
</Screen>
);
}

114
src/app/(tabs)/me.tsx Normal file
View File

@ -0,0 +1,114 @@
import { router } from 'expo-router';
import { Text, View } from 'react-native';
import QRCode from 'react-native-qrcode-svg';
import { OrderCard } from '../../components/OrderCard';
import {
Card,
ErrorBox,
H1,
H2,
Icon,
Loading,
P,
Row,
Screen,
type IconName,
} from '../../components/ui';
import { signOut, useMe } from '../../lib/api';
import { colors, fonts } from '../../lib/theme';
function Link({
icon,
title,
to,
}: {
icon: IconName;
title: string;
to: '/leaderboard' | '/raffles' | '/merch';
}) {
return (
<Row onPress={() => router.push(to)}>
<Icon name={icon} color={colors.primary} />
<Text style={{ flex: 1, fontFamily: fonts.semibold, fontSize: 16, color: colors.ink }}>
{title}
</Text>
<Icon name="chevron" color={colors.grey2} />
</Row>
);
}
export default function MeTab() {
const me = useMe();
const m = me.data;
return (
<Screen onRefresh={() => void me.refetch()} refreshing={me.isRefetching}>
<H1>Me</H1>
{me.isPending ? (
<Loading />
) : me.error ? (
<ErrorBox error={me.error} onRetry={() => void me.refetch()} />
) : (
m && (
<>
<P muted>
{m.user.name ? `${m.user.name} · ` : ''}
{m.user.email}
</P>
<H2 style={{ marginTop: 8 }}>My tickets</H2>
{m.tickets.length === 0 ? (
<Card>
<P muted>
No tickets found for {m.user.email}. Sign in with the email you bought your ticket
with.
</P>
</Card>
) : (
m.tickets.map((t) => (
<Card key={t.id} style={{ alignItems: 'center', gap: 8 }}>
<Text style={{ fontFamily: fonts.bold, fontSize: 18, color: colors.ink }}>
{t.tierName}
</Text>
<P muted style={{ fontSize: 14 }}>
{t.holderName ?? t.holderEmail}
</P>
<View style={{ padding: 12, backgroundColor: colors.white, borderRadius: 12 }}>
<QRCode value={t.qrUrl} size={200} color={colors.ink} />
</View>
<P style={{ fontSize: 13, color: t.checkedInAt ? colors.primary : colors.grey1 }}>
{t.checkedInAt ? 'Checked in' : 'Show this at the entrance'}
</P>
</Card>
))
)}
{m.merchOrders.length > 0 && <H2 style={{ marginTop: 8 }}>Merch orders</H2>}
{m.merchOrders.map((o) => (
<OrderCard key={o.id} order={o} />
))}
<Card style={{ paddingVertical: 4, marginTop: 8 }}>
<Link icon="trophy" title="Leaderboard" to="/leaderboard" />
<Link icon="gift" title="Raffles" to="/raffles" />
<Link icon="bag" title="Order merch" to="/merch" />
<Row onPress={() => void signOut()}>
<Icon name="logout" color={colors.destructive} />
<Text
style={{
flex: 1,
fontFamily: fonts.semibold,
fontSize: 16,
color: colors.destructive,
}}
>
Sign out
</Text>
</Row>
</Card>
</>
)
)}
</Screen>
);
}

112
src/app/(tabs)/scan.tsx Normal file
View File

@ -0,0 +1,112 @@
import { CameraView, useCameraPermissions, type BarcodeScanningResult } from 'expo-camera';
import { router, useIsFocused } from 'expo-router';
import { useRef, useState } from 'react';
import { Platform, StyleSheet, TextInput, View } from 'react-native';
import { SafeAreaView } from 'react-native-safe-area-context';
import { Button, Card, H1, P, s } from '../../components/ui';
import { colors, radius } from '../../lib/theme';
/** Hands the raw QR text (full URL or bare token) to the scan-result screen, which calls POST /scan. */
const openResult = (code: string) => router.push(`/q/${encodeURIComponent(code.trim())}`);
export default function Scan() {
const focused = useIsFocused();
const [permission, requestPermission] = useCameraPermissions();
const [manual, setManual] = useState('');
// Debounce: the camera fires many frames per QR. One code → one request; the same code is
// ignored for a few seconds after we return from the result screen.
const last = useRef<{ code: string; at: number } | null>(null);
const onScan = ({ data }: BarcodeScanningResult) => {
const now = Date.now();
if (last.current && now - last.current.at < (last.current.code === data ? 4000 : 1500)) return;
last.current = { code: data, at: now };
openResult(data);
};
const cameraAvailable = Platform.OS !== 'web';
return (
<SafeAreaView style={s.screen} edges={['top']}>
<View style={{ padding: 16, gap: 12, flex: 1 }}>
<H1>Scan</H1>
<P muted>Point at a booth sign, or the badge or wristband of an investee team member.</P>
<View style={styles.cameraBox}>
{!cameraAvailable ? (
<P style={styles.cameraMsg}>
The camera scanner works in the mobile app. Enter the code below.
</P>
) : !permission ? null : !permission.granted ? (
<View style={{ alignItems: 'center', gap: 12, padding: 20 }}>
<P style={styles.cameraMsg}>Allow camera access to scan QR codes.</P>
<Button
title={permission.canAskAgain ? 'Allow camera' : 'Camera blocked in Settings'}
variant="light"
onPress={requestPermission}
disabled={!permission.canAskAgain}
/>
</View>
) : focused ? (
<CameraView
style={StyleSheet.absoluteFill}
facing="back"
barcodeScannerSettings={{ barcodeTypes: ['qr'] }}
onBarcodeScanned={onScan}
/>
) : null}
{cameraAvailable && permission?.granted && (
<View pointerEvents="none" style={styles.frame} />
)}
</View>
<Card style={{ gap: 10 }}>
<P style={{ fontSize: 14 }} muted>
Camera not working? Type the code printed under the QR.
</P>
<View style={{ flexDirection: 'row', gap: 8 }}>
<TextInput
style={[s.input, { flex: 1, paddingVertical: 10 }]}
value={manual}
onChangeText={setManual}
placeholder="Code or link"
placeholderTextColor={colors.grey2}
autoCapitalize="none"
autoCorrect={false}
returnKeyType="go"
onSubmitEditing={() => manual.trim() && openResult(manual)}
/>
<Button
title="Go"
onPress={() => {
openResult(manual);
setManual('');
}}
disabled={!manual.trim()}
/>
</View>
</Card>
</View>
</SafeAreaView>
);
}
const styles = StyleSheet.create({
cameraBox: {
flex: 1,
minHeight: 260,
borderRadius: radius + 4,
overflow: 'hidden',
backgroundColor: colors.ink,
alignItems: 'center',
justifyContent: 'center',
},
cameraMsg: { color: colors.white, textAlign: 'center', paddingHorizontal: 20 },
frame: {
width: 220,
height: 220,
borderWidth: 3,
borderColor: colors.secondary,
borderRadius: radius + 8,
},
});

81
src/app/_layout.tsx Normal file
View File

@ -0,0 +1,81 @@
import { DMSans_400Regular } from '@expo-google-fonts/dm-sans/400Regular';
import { DMSans_500Medium } from '@expo-google-fonts/dm-sans/500Medium';
import { DMSans_600SemiBold } from '@expo-google-fonts/dm-sans/600SemiBold';
import { DMSans_700Bold } from '@expo-google-fonts/dm-sans/700Bold';
import { QueryClientProvider } from '@tanstack/react-query';
import { useFonts } from 'expo-font';
import {
SplashScreen,
Stack,
router,
usePathname,
useRootNavigationState,
useSegments,
} from 'expo-router';
import { StatusBar } from 'expo-status-bar';
import { useEffect } from 'react';
import { SafeAreaProvider } from 'react-native-safe-area-context';
import { bootSession, queryClient, useSession } from '../lib/api';
import { colors } from '../lib/theme';
void SplashScreen.preventAutoHideAsync().catch(() => undefined);
void bootSession();
const fontAssets = {
'Antebas-Regular': require('../../assets/fonts/Antebas-regular.otf'),
'Antebas-Medium': require('../../assets/fonts/Antebas-medium.otf'),
'Antebas-Bold': require('../../assets/fonts/Antebas-bold.otf'),
'Antebas-Black': require('../../assets/fonts/Antebas-black.otf'),
DMSans_400Regular,
DMSans_500Medium,
DMSans_600SemiBold,
DMSans_700Bold,
};
/** Signed out anywhere but /login → /login?next=<where they were going> (keeps /q/<token> deep links). */
function AuthGate() {
const { booted, signedIn } = useSession();
const segments = useSegments();
const pathname = usePathname();
const navReady = !!useRootNavigationState()?.key;
useEffect(() => {
if (!booted || !navReady) return;
if (!signedIn && segments[0] !== 'login') {
router.replace({
pathname: '/login',
params: pathname && pathname !== '/' ? { next: pathname } : {},
});
}
}, [booted, signedIn, navReady, segments, pathname]);
return null;
}
export default function RootLayout() {
const [fontsLoaded, fontError] = useFonts(fontAssets);
const { booted } = useSession();
const ready = booted && (fontsLoaded || !!fontError);
useEffect(() => {
if (ready) void SplashScreen.hideAsync().catch(() => undefined);
}, [ready]);
if (!ready) return null;
return (
<SafeAreaProvider>
<QueryClientProvider client={queryClient}>
<StatusBar style="dark" />
<Stack
screenOptions={{
headerShown: false,
contentStyle: { backgroundColor: colors.whiteSoft },
}}
>
<Stack.Screen
name="q/[token]"
options={{ presentation: 'fullScreenModal', animation: 'fade' }}
/>
</Stack>
<AuthGate />
</QueryClientProvider>
</SafeAreaProvider>
);
}

75
src/app/leaderboard.tsx Normal file
View File

@ -0,0 +1,75 @@
import { router } from 'expo-router';
import { Text, View } from 'react-native';
import { BackBar, Card, ErrorBox, Loading, P, Row, Screen, s } from '../components/ui';
import { useLeaderboard, useMe } from '../lib/api';
import { colors, fonts } from '../lib/theme';
export default function Leaderboard() {
const q = useLeaderboard();
const me = useMe();
const meInTop = q.data?.some((r) => r.me);
return (
<Screen
bar={<BackBar title="Leaderboard" onBack={() => router.back()} />}
onRefresh={() => void q.refetch()}
refreshing={q.isRefetching}
>
{q.isPending ? (
<Loading />
) : q.error ? (
<ErrorBox error={q.error} onRetry={() => void q.refetch()} />
) : (
<Card style={{ paddingVertical: 4 }}>
{q.data.length === 0 && (
<P muted style={{ paddingVertical: 12 }}>
No points yet. Be the first to scan.
</P>
)}
{q.data.map((r, i) => (
<Row
key={`${r.rank}-${r.name}-${i}`}
style={[
i > 0 && { borderTopWidth: 1, borderTopColor: colors.surfaceMuted },
r.me && {
backgroundColor: colors.surfaceMuted,
marginHorizontal: -16,
paddingHorizontal: 16,
},
]}
>
<Text
style={[
s.num,
{ width: 36, fontSize: 16, color: r.rank <= 3 ? colors.primary : colors.grey1 },
]}
>
#{r.rank}
</Text>
<Text
style={{
flex: 1,
fontFamily: r.me ? fonts.bold : fonts.medium,
fontSize: 16,
color: colors.ink,
}}
>
{r.name}
{r.me ? ' (you)' : ''}
</Text>
<Text style={[s.num, { fontSize: 16 }]}>{r.points}</Text>
</Row>
))}
</Card>
)}
{q.data && !meInTop && me.data && (
<Card tone="muted" style={{ flexDirection: 'row', justifyContent: 'space-between' }}>
<Text style={{ fontFamily: fonts.semibold, color: colors.ink }}>
You {me.data.rank ? `· #${me.data.rank}` : ''}
</Text>
<Text style={[s.num]}>{me.data.points} pts</Text>
</Card>
)}
</Screen>
);
}

176
src/app/login.tsx Normal file
View File

@ -0,0 +1,176 @@
import { router, useLocalSearchParams } from 'expo-router';
import { useState } from 'react';
import {
Image,
KeyboardAvoidingView,
Platform,
ScrollView,
Text,
TextInput,
View,
} from 'react-native';
import { Button, Card, H1, P, PatternHeader, s } from '../components/ui';
import { api, ApiError, signIn, type User } from '../lib/api';
import { colors, fonts } from '../lib/theme';
type Step = 'email' | 'code' | 'name';
export default function Login() {
const { next } = useLocalSearchParams<{ next?: string }>();
const [step, setStep] = useState<Step>('email');
const [email, setEmail] = useState('');
const [code, setCode] = useState('');
const [name, setName] = useState('');
const [busy, setBusy] = useState(false);
const [error, setError] = useState<string | null>(null);
const done = () => router.replace((next as never) || '/');
async function run(fn: () => Promise<void>) {
setBusy(true);
setError(null);
try {
await fn();
} catch (e) {
setError(
e instanceof ApiError && e.code === 'invalid_code'
? 'That code is wrong or expired. Try again.'
: (e as Error).message,
);
} finally {
setBusy(false);
}
}
const requestCode = () =>
run(async () => {
await api('/auth/otp/request', { body: { email: email.trim().toLowerCase() } });
setCode('');
setStep('code');
});
const verify = () =>
run(async () => {
const res = await api<{ accessToken: string; user: User }>('/auth/otp/verify', {
body: { email: email.trim().toLowerCase(), code },
});
await signIn(res.accessToken);
if (res.user.name) done();
else setStep('name');
});
const saveName = () =>
run(async () => {
await api('/me', { method: 'PATCH', body: { name: name.trim() } });
done();
});
const validEmail = /^\S+@\S+\.\S+$/.test(email.trim());
return (
<KeyboardAvoidingView
style={{ flex: 1, backgroundColor: colors.whiteSoft }}
behavior={Platform.OS === 'ios' ? 'padding' : undefined}
>
<ScrollView keyboardShouldPersistTaps="handled" contentContainerStyle={{ flexGrow: 1 }}>
<PatternHeader style={{ paddingTop: 48, paddingBottom: 40 }}>
<Image
source={require('../../assets/logo-white.png')}
style={{ width: 240, height: 51 }}
resizeMode="contain"
/>
<Text
style={{ fontFamily: fonts.display, fontSize: 34, color: colors.white, marginTop: 28 }}
>
Scan to win
</Text>
<P style={{ color: colors.secondary, marginTop: 6 }}>
Check in at booths, find our investees and collect points for the raffle.
</P>
</PatternHeader>
<View style={{ padding: 20, gap: 14 }}>
{step === 'email' && (
<Card style={{ gap: 14 }}>
<H1 style={{ fontSize: 24 }}>Sign in</H1>
<P muted>Use the email you bought your ticket with, so we can show your ticket QR.</P>
<TextInput
style={s.input}
value={email}
onChangeText={setEmail}
placeholder="you@example.com"
placeholderTextColor={colors.grey2}
autoCapitalize="none"
autoComplete="email"
keyboardType="email-address"
returnKeyType="send"
onSubmitEditing={() => validEmail && requestCode()}
/>
<Button
title="Send code"
onPress={requestCode}
disabled={!validEmail}
loading={busy}
/>
</Card>
)}
{step === 'code' && (
<Card style={{ gap: 14 }}>
<H1 style={{ fontSize: 24 }}>Check your email</H1>
<P muted>We sent a 6-digit code to {email.trim()}.</P>
<TextInput
style={[
s.input,
{ fontFamily: fonts.bold, fontSize: 28, letterSpacing: 10, textAlign: 'center' },
]}
value={code}
onChangeText={(t) => setCode(t.replace(/\D/g, '').slice(0, 6))}
placeholder="000000"
placeholderTextColor={colors.grey3}
keyboardType="number-pad"
autoComplete="one-time-code"
textContentType="oneTimeCode"
maxLength={6}
autoFocus
/>
<Button title="Verify" onPress={verify} disabled={code.length !== 6} loading={busy} />
<Button
title="Use a different email"
variant="outline"
onPress={() => setStep('email')}
disabled={busy}
/>
<Text
onPress={busy ? undefined : requestCode}
style={{ fontFamily: fonts.semibold, color: colors.primary, textAlign: 'center' }}
>
Resend code
</Text>
</Card>
)}
{step === 'name' && (
<Card style={{ gap: 14 }}>
<H1 style={{ fontSize: 24 }}>Your name</H1>
<P muted>Shown on the leaderboard as first name and last initial.</P>
<TextInput
style={s.input}
value={name}
onChangeText={setName}
placeholder="Full name"
placeholderTextColor={colors.grey2}
autoComplete="name"
autoFocus
/>
<Button title="Continue" onPress={saveName} disabled={!name.trim()} loading={busy} />
<Button title="Skip for now" variant="outline" onPress={done} disabled={busy} />
</Card>
)}
{error && <P style={{ color: colors.destructive, textAlign: 'center' }}>{error}</P>}
</View>
</ScrollView>
</KeyboardAvoidingView>
);
}

193
src/app/merch.tsx Normal file
View File

@ -0,0 +1,193 @@
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<Record<string, Pick>>({});
const [busy, setBusy] = useState(false);
const [error, setError] = useState<string | null>(null);
const [order, setOrder] = useState<Order | null>(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<Pick>) =>
setPicks((p) => ({ ...p, [id]: { size: null, qty: 0, ...p[id], ...patch } }));
async function place() {
setBusy(true);
setError(null);
try {
const o = await api<Order>('/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 (
<Screen bar={<BackBar title="Order placed" onBack={() => router.back()} />}>
<H1 style={{ fontSize: 24 }}>Pay and collect at the GRV booth</H1>
<P muted>Show this QR at the GRV booth. You'll pay there and pick up your merch.</P>
<OrderCard order={order} />
<Button title="Done" onPress={() => router.back()} />
</Screen>
);
}
return (
<Screen
bar={<BackBar title="GRV merch" onBack={() => router.back()} />}
onRefresh={() => void q.refetch()}
refreshing={q.isRefetching}
>
<P muted>Order here, then pay and collect at the GRV booth.</P>
{q.isPending ? (
<Loading />
) : q.error ? (
<ErrorBox error={q.error} onRetry={() => void q.refetch()} />
) : items.length === 0 ? (
<P muted>Merch is coming soon.</P>
) : (
items.map((i) => {
const pick = picks[i.id] ?? { size: null, qty: 0 };
const soldOut = i.stock <= 0;
return (
<Card key={i.id} style={{ gap: 10 }}>
{i.imageUrl && (
<Image
source={{ uri: i.imageUrl }}
style={{
width: '100%',
aspectRatio: 4 / 3,
borderRadius: radius,
backgroundColor: colors.surfaceMuted,
}}
/>
)}
<View style={{ flexDirection: 'row', justifyContent: 'space-between', gap: 8 }}>
<Text style={{ flex: 1, fontFamily: fonts.bold, fontSize: 17, color: colors.ink }}>
{i.name}
</Text>
<Text style={[s.num, { fontSize: 17 }]}>
{formatMoney(i.priceMinor, i.currency)}
</Text>
</View>
{i.description && (
<P muted style={{ fontSize: 14 }}>
{i.description}
</P>
)}
{soldOut ? (
<Text style={{ fontFamily: fonts.semibold, color: colors.destructive }}>
Sold out
</Text>
) : (
<>
{i.sizes.length > 0 && (
<View style={{ flexDirection: 'row', flexWrap: 'wrap', gap: 8 }}>
{i.sizes.map((sz) => (
<Pressable
key={sz}
onPress={() => set(i.id, { size: sz, qty: pick.qty || 1 })}
style={[s.chip, pick.size === sz && s.chipOn]}
>
<Text style={{ fontFamily: fonts.semibold, color: colors.ink }}>
{sz}
</Text>
</Pressable>
))}
</View>
)}
<View style={{ flexDirection: 'row', alignItems: 'center', gap: 16 }}>
<Stepper
label="−"
onPress={() => set(i.id, { qty: Math.max(0, pick.qty - 1) })}
disabled={pick.qty === 0}
/>
<Text style={[s.num, { fontSize: 18, minWidth: 24, textAlign: 'center' }]}>
{pick.qty}
</Text>
<Stepper
label="+"
onPress={() => set(i.id, { qty: Math.min(i.stock, pick.qty + 1) })}
disabled={pick.qty >= i.stock}
/>
</View>
</>
)}
</Card>
);
})
)}
{chosen.length > 0 && (
<Card tone="muted" style={{ gap: 10 }}>
<View style={{ flexDirection: 'row', justifyContent: 'space-between' }}>
<Text style={{ fontFamily: fonts.semibold, color: colors.ink }}>Total</Text>
<Text style={[s.num, { fontSize: 18 }]}>{formatMoney(total, chosen[0]!.currency)}</Text>
</View>
{missingSize && (
<P style={{ fontSize: 14, color: colors.destructive }}>Pick a size for each item.</P>
)}
<Button title="Place order" onPress={place} loading={busy} disabled={missingSize} />
<P muted style={{ fontSize: 13, textAlign: 'center' }}>
Pay & collect at the GRV booth.
</P>
</Card>
)}
{error && <P style={{ color: colors.destructive }}>{error}</P>}
</Screen>
);
}
function Stepper({
label,
onPress,
disabled,
}: {
label: string;
onPress: () => void;
disabled?: boolean;
}) {
return (
<Pressable
onPress={onPress}
disabled={disabled}
accessibilityRole="button"
accessibilityLabel={label === '+' ? 'Increase quantity' : 'Decrease quantity'}
style={{
width: 40,
height: 40,
borderRadius: 20,
borderWidth: 1.5,
borderColor: colors.primary,
alignItems: 'center',
justifyContent: 'center',
opacity: disabled ? 0.35 : 1,
}}
>
<Text style={{ fontFamily: fonts.bold, fontSize: 20, color: colors.primary }}>{label}</Text>
</Pressable>
);
}

206
src/app/q/[token].tsx Normal file
View File

@ -0,0 +1,206 @@
import * as Haptics from 'expo-haptics';
import { router, useLocalSearchParams } from 'expo-router';
import { useEffect, useRef, useState } from 'react';
import { ActivityIndicator, Animated, Image, StyleSheet, Text, View } from 'react-native';
import { SafeAreaView } from 'react-native-safe-area-context';
import { Button, Icon, P, s } from '../../components/ui';
import { api, ApiError, invalidateAll, type Checkpoint, type ScanResult } from '../../lib/api';
import { colors, fonts } from '../../lib/theme';
type State =
| { kind: 'loading' }
| { kind: 'ok'; result: ScanResult }
| { kind: 'already'; checkpoint: Checkpoint | null }
| { kind: 'unknown' }
| { kind: 'error'; message: string };
const haptic = (type: Haptics.NotificationFeedbackType) =>
void Haptics.notificationAsync(type).catch(() => undefined);
const who = (c: Checkpoint) =>
c.kind === 'BOOTH'
? [c.organisation ?? c.label, c.boothNumber && `Booth ${c.boothNumber}`]
.filter(Boolean)
.join(' · ')
: [c.personName, c.label, c.organisation].filter(Boolean).join(' · ');
/** Reached from the Scan tab and from https://grv.ethiopiatrustfund.org/q/<token> deep links. */
export default function ScanResultScreen() {
const { token } = useLocalSearchParams<{ token: string }>();
const [state, setState] = useState<State>({ kind: 'loading' });
const sent = useRef(false);
const pop = useRef(new Animated.Value(0.6)).current;
useEffect(() => {
if (sent.current || !token) return;
sent.current = true; // one QR → one request, even under StrictMode double effects
api<ScanResult>('/scan', { body: { token } })
.then((result) => {
setState({ kind: 'ok', result });
haptic(Haptics.NotificationFeedbackType.Success);
if (result.mystery)
void Haptics.impactAsync(Haptics.ImpactFeedbackStyle.Heavy).catch(() => undefined);
Animated.spring(pop, { toValue: 1, friction: 4, useNativeDriver: true }).start();
void invalidateAll();
})
.catch((e: unknown) => {
if (e instanceof ApiError && e.status === 409) {
setState({
kind: 'already',
checkpoint: (e.body?.checkpoint as Checkpoint | undefined) ?? null,
});
haptic(Haptics.NotificationFeedbackType.Warning);
} else if (e instanceof ApiError && e.status === 404) {
setState({ kind: 'unknown' });
haptic(Haptics.NotificationFeedbackType.Error);
} else {
setState({ kind: 'error', message: (e as Error).message });
haptic(Haptics.NotificationFeedbackType.Error);
}
});
}, [token, pop]);
const close = () => (router.canGoBack() ? router.back() : router.replace('/'));
const scanAgain = () => (router.canGoBack() ? router.back() : router.replace('/scan'));
if (state.kind === 'ok' && state.result.mystery) {
const { result } = state;
return (
<SafeAreaView style={[styles.fill, { backgroundColor: colors.primary }]}>
<Image
source={require('../../../assets/pattern.png')}
style={[StyleSheet.absoluteFill, { width: '100%', height: '100%', opacity: 0.25 }]}
resizeMode="cover"
/>
<View style={styles.center}>
<Text style={[styles.kicker, { color: colors.secondary }]}>Mystery investee</Text>
<Text style={[styles.title, { color: colors.white }]}>You found our next investee</Text>
{result.checkpoint.organisation && (
<P style={{ color: colors.secondary, textAlign: 'center', fontSize: 17 }}>
{who(result.checkpoint)}
</P>
)}
<Animated.View
style={[styles.badge, { backgroundColor: colors.white, transform: [{ scale: pop }] }]}
>
<Text style={[s.num, { fontSize: 56, color: colors.primary }]}>
+{result.pointsAwarded}
</Text>
<Text style={{ fontFamily: fonts.bold, color: colors.primary }}>DOUBLE POINTS</Text>
</Animated.View>
<P style={{ color: colors.white }}>New total: {result.total} points</P>
</View>
<View style={styles.actions}>
<Button title="Done" variant="light" onPress={close} />
</View>
</SafeAreaView>
);
}
return (
<SafeAreaView style={[styles.fill, { backgroundColor: colors.whiteSoft }]}>
<View style={styles.center}>
{state.kind === 'loading' && <ActivityIndicator size="large" color={colors.primary} />}
{state.kind === 'ok' && (
<>
<View style={[styles.circle, { backgroundColor: colors.primary }]}>
<Icon name="check" color={colors.white} size={44} />
</View>
<Text style={styles.kicker}>
{state.result.checkpoint.kind === 'BOOTH' ? 'Booth checked in' : 'Investee found'}
</Text>
<Text style={[styles.title, { fontFamily: fonts.bold }]}>
{state.result.checkpoint.organisation ?? state.result.checkpoint.label}
</Text>
<P muted style={{ textAlign: 'center' }}>
{who(state.result.checkpoint)}
</P>
<Animated.View
style={[
styles.badge,
{ backgroundColor: colors.surfaceMuted, transform: [{ scale: pop }] },
]}
>
<Text style={[s.num, { fontSize: 44, color: colors.primary }]}>
+{state.result.pointsAwarded}
</Text>
<Text style={{ fontFamily: fonts.semibold, color: colors.primary }}>points</Text>
</Animated.View>
<P>New total: {state.result.total} points</P>
</>
)}
{state.kind === 'already' && (
<>
<View style={[styles.circle, { backgroundColor: colors.secondary }]}>
<Icon name="check" color={colors.ink} size={44} />
</View>
<Text style={styles.title}>Already scanned</Text>
<P muted style={{ textAlign: 'center' }}>
{state.checkpoint
? `You already collected points for ${who(state.checkpoint)}.`
: 'You already collected points for this code.'}
</P>
</>
)}
{state.kind === 'unknown' && (
<>
<View style={[styles.circle, { backgroundColor: colors.grey3 }]}>
<Icon name="help" color={colors.ink} size={44} />
</View>
<Text style={styles.title}>Not a GRV code</Text>
<P muted style={{ textAlign: 'center' }}>
This QR isn't one of our booth or investee codes. Ticket QRs are scanned by staff at
the entrance.
</P>
</>
)}
{state.kind === 'error' && (
<>
<Text style={styles.title}>Something went wrong</Text>
<P style={{ color: colors.destructive, textAlign: 'center' }}>{state.message}</P>
</>
)}
</View>
{state.kind !== 'loading' && (
<View style={styles.actions}>
<Button title="Scan another" onPress={scanAgain} />
<Button title="Done" variant="outline" onPress={close} />
</View>
)}
</SafeAreaView>
);
}
const styles = StyleSheet.create({
fill: { flex: 1 },
center: { flex: 1, alignItems: 'center', justifyContent: 'center', padding: 24, gap: 12 },
actions: { padding: 20, gap: 10 },
circle: {
width: 88,
height: 88,
borderRadius: 44,
alignItems: 'center',
justifyContent: 'center',
marginBottom: 8,
},
kicker: {
fontFamily: fonts.semibold,
fontSize: 13,
letterSpacing: 1,
textTransform: 'uppercase',
color: colors.grey1,
},
title: { fontFamily: fonts.display, fontSize: 30, color: colors.ink, textAlign: 'center' },
badge: {
alignItems: 'center',
borderRadius: 24,
paddingHorizontal: 32,
paddingVertical: 16,
marginVertical: 8,
},
});

63
src/app/raffles.tsx Normal file
View File

@ -0,0 +1,63 @@
import { router } from 'expo-router';
import { Text, View } from 'react-native';
import { BackBar, Card, ErrorBox, Icon, Loading, P, Screen, s } from '../components/ui';
import { useMe, useRaffles, type Raffle } from '../lib/api';
import { colors, fonts } from '../lib/theme';
function Status({ r, points, myId }: { r: Raffle; points: number; myId?: string }) {
if (r.drawnAt) {
const mine = r.winner?.id === myId;
return (
<Text style={{ fontFamily: fonts.semibold, color: mine ? colors.primary : colors.grey1 }}>
{mine
? 'You won! Collect your prize at the GRV booth.'
: `Winner: ${r.winner?.name ?? 'drawn'}`}
</Text>
);
}
if (r.eligible)
return (
<Text style={{ fontFamily: fonts.semibold, color: colors.primary }}>You're in the draw</Text>
);
return (
<Text style={{ fontFamily: fonts.semibold, color: colors.grey1 }}>
Not yet · {Math.max(0, r.minPoints - points)} more points needed
</Text>
);
}
export default function Raffles() {
const q = useRaffles();
const me = useMe();
return (
<Screen
bar={<BackBar title="Raffles" onBack={() => router.back()} />}
onRefresh={() => void q.refetch()}
refreshing={q.isRefetching}
>
<P muted>Collect points to enter. Winners are drawn at the end of the summit.</P>
{q.isPending ? (
<Loading />
) : q.error ? (
<ErrorBox error={q.error} onRetry={() => void q.refetch()} />
) : q.data.length === 0 ? (
<P muted>Raffles will be announced soon.</P>
) : (
q.data.map((r) => (
<Card key={r.id} tone={r.eligible && !r.drawnAt ? 'muted' : 'white'} style={{ gap: 6 }}>
<View style={{ flexDirection: 'row', alignItems: 'center', gap: 10 }}>
<Icon name="gift" color={colors.primary} />
<Text style={{ flex: 1, fontFamily: fonts.bold, fontSize: 17, color: colors.ink }}>
{r.name}
</Text>
<Text style={[s.num, { color: colors.grey1 }]}>{r.minPoints} pts</Text>
</View>
<P>Prize: {r.prize}</P>
<Status r={r} points={me.data?.points ?? 0} myId={me.data?.user.id} />
</Card>
))
)}
</Screen>
);
}

View File

@ -0,0 +1,40 @@
import { Text, View } from 'react-native';
import QRCode from 'react-native-qrcode-svg';
import { formatMoney, type Order } from '../lib/api';
import { colors, fonts } from '../lib/theme';
import { Card, P } from './ui';
const STATUS: Record<Order['status'], string> = {
PENDING: 'Pay & collect at the GRV booth',
PAID: 'Paid · collect at the GRV booth',
FULFILLED: 'Collected',
CANCELLED: 'Cancelled',
};
export function OrderCard({ order }: { order: Order }) {
const open = order.status === 'PENDING' || order.status === 'PAID';
return (
<Card style={{ alignItems: 'center', gap: 8 }}>
<Text style={{ fontFamily: fonts.bold, fontSize: 18, color: colors.ink }}>
{order.number}
</Text>
<P muted style={{ fontSize: 14 }}>
{STATUS[order.status]}
</P>
{open && (
<View style={{ padding: 12, backgroundColor: colors.white, borderRadius: 12 }}>
<QRCode value={order.number} size={160} color={colors.ink} />
</View>
)}
{order.items.map((it, i) => (
<P key={i} style={{ fontSize: 14 }}>
{it.qty} × {it.name}
{it.size ? ` (${it.size})` : ''}
</P>
))}
<Text style={{ fontFamily: fonts.bold, color: colors.ink }}>
{formatMoney(order.totalMinor, order.currency)}
</Text>
</Card>
);
}

355
src/components/ui.tsx Normal file
View File

@ -0,0 +1,355 @@
import type { ReactNode } from 'react';
import {
ActivityIndicator,
Image,
Pressable,
RefreshControl,
ScrollView,
StyleSheet,
Text,
View,
type StyleProp,
type TextStyle,
type ViewStyle,
} from 'react-native';
import { SafeAreaView } from 'react-native-safe-area-context';
import Svg, { Circle, Path } from 'react-native-svg';
import { colors, fonts, radius } from '../lib/theme';
// ---------- Icons (Lucide paths, 24x24) ----------
const ICONS = {
home: ['M3 10.5 12 3l9 7.5V20a1 1 0 0 1-1 1h-5v-6H9v6H4a1 1 0 0 1-1-1z'],
scan: [
'M3 7V5a2 2 0 0 1 2-2h2',
'M17 3h2a2 2 0 0 1 2 2v2',
'M21 17v2a2 2 0 0 1-2 2h-2',
'M7 21H5a2 2 0 0 1-2-2v-2',
'M7 12h10',
],
store: [
'M3 9l1.5-5h15L21 9',
'M3 9h18v2a3 3 0 0 1-6 0 3 3 0 0 1-6 0 3 3 0 0 1-6 0z',
'M5 12v8h14v-8',
],
rocket: [
'M4.5 16.5c-1.5 1.26-2 5-2 5s3.74-.5 5-2c.71-.84.7-2.13-.09-2.91a2.18 2.18 0 0 0-2.91-.09z',
'M12 15l-3-3a22 22 0 0 1 2-3.95A12.88 12.88 0 0 1 22 2c0 2.72-.78 7.5-6 11a22.35 22.35 0 0 1-4 2z',
'M9 12H4s.55-3.03 2-4c1.62-1.08 5 0 5 0',
'M12 15v5s3.03-.55 4-2c1.08-1.62 0-5 0-5',
],
user: ['M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2', 'M12 3a4 4 0 1 0 0 8 4 4 0 0 0 0-8z'],
check: ['M20 6 9 17l-5-5'],
chevron: ['M9 18l6-6-6-6'],
back: ['M15 18l-6-6 6-6'],
trophy: [
'M6 9H4.5a2.5 2.5 0 0 1 0-5H6',
'M18 9h1.5a2.5 2.5 0 0 0 0-5H18',
'M4 22h16',
'M10 14.66V17c0 .55-.47.98-.97 1.21C7.85 18.75 7 20.24 7 22',
'M14 14.66V17c0 .55.47.98.97 1.21C16.15 18.75 17 20.24 17 22',
'M18 2H6v7a6 6 0 0 0 12 0V2z',
],
gift: [
'M20 12v10H4V12',
'M2 7h20v5H2z',
'M12 22V7',
'M12 7H7.5a2.5 2.5 0 0 1 0-5C11 2 12 7 12 7z',
'M12 7h4.5a2.5 2.5 0 0 0 0-5C13 2 12 7 12 7z',
],
bag: ['M6 2 3 6v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2V6l-3-4z', 'M3 6h18', 'M16 10a4 4 0 0 1-8 0'],
logout: ['M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4', 'M16 17l5-5-5-5', 'M21 12H9'],
} as const;
export type IconName = keyof typeof ICONS | 'help';
export function Icon({
name,
size = 22,
color = colors.ink,
}: {
name: IconName;
size?: number;
color?: string;
}) {
return (
<Svg
width={size}
height={size}
viewBox="0 0 24 24"
fill="none"
stroke={color}
strokeWidth={2}
strokeLinecap="round"
strokeLinejoin="round"
>
{name === 'help' ? (
<>
<Circle cx={12} cy={12} r={10} />
<Path d="M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3" />
<Path d="M12 17h.01" />
</>
) : (
ICONS[name].map((d) => <Path key={d} d={d} />)
)}
</Svg>
);
}
// ---------- Text ----------
export const H1 = ({ children, style }: { children: ReactNode; style?: StyleProp<TextStyle> }) => (
<Text style={[s.h1, style]}>{children}</Text>
);
export const H2 = ({ children, style }: { children: ReactNode; style?: StyleProp<TextStyle> }) => (
<Text style={[s.h2, style]}>{children}</Text>
);
export const P = ({
children,
style,
muted,
}: {
children: ReactNode;
style?: StyleProp<TextStyle>;
muted?: boolean;
}) => <Text style={[s.p, muted && { color: colors.grey1 }, style]}>{children}</Text>;
// ---------- Layout ----------
export function Screen({
children,
onRefresh,
refreshing = false,
header,
bar,
}: {
children: ReactNode;
onRefresh?: () => void;
refreshing?: boolean;
/** Scrolls with content and handles its own top inset (PatternHeader). */
header?: ReactNode;
/** Fixed above the scroll view (BackBar). */
bar?: ReactNode;
}) {
return (
<SafeAreaView style={s.screen} edges={header ? [] : ['top']}>
{bar}
<ScrollView
contentContainerStyle={{ paddingBottom: 32 }}
refreshControl={
onRefresh ? (
<RefreshControl
refreshing={refreshing}
onRefresh={onRefresh}
tintColor={colors.primary}
/>
) : undefined
}
>
{header}
<View style={s.body}>{children}</View>
</ScrollView>
</SafeAreaView>
);
}
/** Green hero band with the site's topographic pattern (mainwhite.svg rendered to PNG). */
export function PatternHeader({
children,
style,
}: {
children: ReactNode;
style?: StyleProp<ViewStyle>;
}) {
return (
<SafeAreaView edges={['top']} style={[s.hero, style]}>
<Image source={require('../../assets/pattern.png')} style={s.pattern} resizeMode="cover" />
{children}
</SafeAreaView>
);
}
export function BackBar({ title, onBack }: { title: string; onBack: () => void }) {
return (
<View style={s.backBar}>
<Pressable onPress={onBack} hitSlop={12} accessibilityRole="button" accessibilityLabel="Back">
<Icon name="back" />
</Pressable>
<H2 style={{ marginLeft: 8 }}>{title}</H2>
</View>
);
}
export function Card({
children,
style,
tone = 'white',
}: {
children: ReactNode;
style?: StyleProp<ViewStyle>;
tone?: 'white' | 'muted';
}) {
return (
<View style={[s.card, tone === 'muted' && { backgroundColor: colors.surfaceMuted }, style]}>
{children}
</View>
);
}
export function Button({
title,
onPress,
disabled,
loading,
variant = 'primary',
style,
}: {
title: string;
onPress: () => void;
disabled?: boolean;
loading?: boolean;
variant?: 'primary' | 'outline' | 'light';
style?: StyleProp<ViewStyle>;
}) {
const fg = variant === 'primary' ? colors.white : colors.primary;
return (
<Pressable
accessibilityRole="button"
onPress={onPress}
disabled={disabled || loading}
style={({ pressed }) => [
s.btn,
variant === 'primary' && { backgroundColor: pressed ? colors.ink : colors.primary },
variant === 'outline' && { borderWidth: 1.5, borderColor: colors.primary },
variant === 'light' && { backgroundColor: colors.white },
(disabled || loading) && { opacity: 0.5 },
style,
]}
>
{loading ? (
<ActivityIndicator color={fg} />
) : (
<Text style={[s.btnText, { color: fg }]}>{title}</Text>
)}
</Pressable>
);
}
export function Row({
children,
onPress,
style,
}: {
children: ReactNode;
onPress?: () => void;
style?: StyleProp<ViewStyle>;
}) {
return (
<Pressable onPress={onPress} disabled={!onPress} style={[s.row, style]}>
{children}
</Pressable>
);
}
export function CheckDot({ done }: { done: boolean }) {
return (
<View
style={[
s.dot,
done ? { backgroundColor: colors.primary, borderColor: colors.primary } : null,
]}
>
{done && <Icon name="check" size={14} color={colors.white} />}
</View>
);
}
export function Loading() {
return <ActivityIndicator style={{ marginTop: 48 }} color={colors.primary} />;
}
export function ErrorBox({ error, onRetry }: { error: Error; onRetry?: () => void }) {
return (
<Card style={{ alignItems: 'center', gap: 12 }}>
<P style={{ color: colors.destructive, textAlign: 'center' }}>{error.message}</P>
{onRetry && <Button title="Try again" variant="outline" onPress={onRetry} />}
</Card>
);
}
export const s = StyleSheet.create({
screen: { flex: 1, backgroundColor: colors.whiteSoft },
body: { padding: 16, gap: 12 },
hero: {
backgroundColor: colors.primary,
overflow: 'hidden',
paddingHorizontal: 20,
paddingBottom: 24,
},
pattern: { ...StyleSheet.absoluteFill, width: '100%', height: '100%', opacity: 0.18 },
h1: { fontFamily: fonts.display, fontSize: 30, color: colors.ink, letterSpacing: 0.2 },
h2: { fontFamily: fonts.display, fontSize: 20, color: colors.ink },
p: { fontFamily: fonts.regular, fontSize: 15, lineHeight: 22, color: colors.ink },
num: { fontFamily: fonts.bold, color: colors.ink, fontVariant: ['tabular-nums'] },
label: {
fontFamily: fonts.semibold,
fontSize: 12,
color: colors.grey1,
textTransform: 'uppercase',
letterSpacing: 0.8,
},
card: {
backgroundColor: colors.white,
borderRadius: radius + 4,
padding: 16,
borderWidth: 1,
borderColor: 'rgba(48,97,76,0.12)',
shadowColor: '#000',
shadowOpacity: 0.05,
shadowRadius: 8,
shadowOffset: { width: 0, height: 2 },
elevation: 1,
},
btn: {
minHeight: 50,
borderRadius: 999,
paddingHorizontal: 22,
alignItems: 'center',
justifyContent: 'center',
},
btnText: { fontFamily: fonts.semibold, fontSize: 16 },
row: { flexDirection: 'row', alignItems: 'center', gap: 12, paddingVertical: 12 },
dot: {
width: 24,
height: 24,
borderRadius: 12,
borderWidth: 2,
borderColor: colors.grey3,
alignItems: 'center',
justifyContent: 'center',
},
backBar: {
flexDirection: 'row',
alignItems: 'center',
paddingHorizontal: 16,
paddingVertical: 12,
},
input: {
fontFamily: fonts.regular,
fontSize: 17,
color: colors.ink,
backgroundColor: colors.white,
borderWidth: 1,
borderColor: colors.grey3,
borderRadius: radius,
paddingHorizontal: 16,
paddingVertical: 14,
},
chip: {
paddingHorizontal: 14,
paddingVertical: 8,
borderRadius: 999,
borderWidth: 1.5,
borderColor: colors.grey3,
},
chipOn: { borderColor: colors.primary, backgroundColor: colors.surfaceMuted },
});

1
src/expo-types.d.ts vendored Normal file
View File

@ -0,0 +1 @@
/// <reference types="expo/types" />

215
src/lib/api.ts Normal file
View File

@ -0,0 +1,215 @@
import { QueryClient, useQuery } from '@tanstack/react-query';
import * as SecureStore from 'expo-secure-store';
import { useSyncExternalStore } from 'react';
import { Platform } from 'react-native';
// ---------- Types (hand-written from GRV-Backend/API.md) ----------
export type Role = 'ATTENDEE' | 'STAFF' | 'ADMIN';
export type User = { id: string; email: string; name: string | null; role: Role };
export type CheckpointKind = 'BOOTH' | 'STARTUP_MEMBER' | 'MYSTERY_INVESTEE';
export type Checkpoint = {
id: string;
kind: CheckpointKind;
label: string;
organisation: string | null;
boothNumber: string | null;
personName: string | null;
points: number;
scanned?: boolean;
};
export type Ticket = {
id: string;
qrToken: string;
qrUrl: string;
tierName: string;
holderEmail: string;
holderName: string | null;
checkedInAt: string | null;
};
export type OrderStatus = 'PENDING' | 'PAID' | 'CANCELLED' | 'FULFILLED';
export type Order = {
id: string;
number: string;
kind: 'TICKET' | 'MERCH';
status: OrderStatus;
totalMinor: number;
currency: string;
items: { name: string; qty: number; size: string | null; unitPriceMinor: number }[];
createdAt: string;
paidAt: string | null;
fulfilledAt: string | null;
};
export type MerchItem = {
id: string;
name: string;
description: string | null;
priceMinor: number;
currency: string;
sizes: string[];
stock: number;
imageUrl: string | null;
};
export type Raffle = {
id: string;
name: string;
prize: string;
minPoints: number;
drawnAt: string | null;
winner: { id: string; name: string | null } | null;
eligible?: boolean;
};
export type Me = {
user: User;
points: number;
rank: number | null;
progress: {
booths: { found: number; total: number };
startups: { found: number; total: number };
mysteryFound: boolean;
};
tickets: Ticket[];
merchOrders: Order[];
};
export type LeaderRow = { rank: number; name: string; points: number; me: boolean };
export type ScanResult = {
checkpoint: Checkpoint;
pointsAwarded: number;
total: number;
mystery: boolean;
};
// ---------- Session (token in secure-store; localStorage on web) ----------
const TOKEN_KEY = 'grv.accessToken';
const web = Platform.OS === 'web';
let token: string | null = null;
let booted = false;
const listeners = new Set<() => void>();
const emit = () => listeners.forEach((l) => l());
export async function bootSession() {
try {
token = web ? localStorage.getItem(TOKEN_KEY) : await SecureStore.getItemAsync(TOKEN_KEY);
} catch {
token = null;
}
booted = true;
emit();
}
async function setToken(next: string | null) {
token = next;
emit();
try {
if (web) next ? localStorage.setItem(TOKEN_KEY, next) : localStorage.removeItem(TOKEN_KEY);
else if (next) await SecureStore.setItemAsync(TOKEN_KEY, next);
else await SecureStore.deleteItemAsync(TOKEN_KEY);
} catch {
/* storage unavailable: session lives in memory */
}
}
export const signIn = (accessToken: string) => setToken(accessToken);
export async function signOut() {
await setToken(null);
queryClient.clear();
}
/** `{ booted, signedIn }` — re-renders on sign-in/out. */
export function useSession() {
const signedIn = useSyncExternalStore(
(l) => (listeners.add(l), () => listeners.delete(l)),
() => (booted ? (token ? 1 : 0) : -1),
);
return { booted: signedIn !== -1, signedIn: signedIn === 1 };
}
// ---------- Fetch wrapper ----------
const API_URL = (process.env.EXPO_PUBLIC_API_URL ?? 'http://localhost:4000').replace(/\/+$/, '');
export class ApiError extends Error {
constructor(
message: string,
public status: number,
public code?: string,
/** Full error body, e.g. 409 already_scanned carries `checkpoint`. */
public body?: Record<string, unknown>,
) {
super(message);
}
}
export async function api<T>(
path: string,
init: { method?: string; body?: unknown } = {},
): Promise<T> {
let res: Response;
try {
res = await fetch(`${API_URL}${path}`, {
method: init.method ?? (init.body === undefined ? 'GET' : 'POST'),
headers: {
Accept: 'application/json',
...(init.body !== undefined ? { 'Content-Type': 'application/json' } : {}),
...(token ? { Authorization: `Bearer ${token}` } : {}),
},
body: init.body === undefined ? undefined : JSON.stringify(init.body),
});
} catch {
throw new ApiError('Network error. Check your connection and try again.', 0);
}
const data = await res.json().catch(() => null);
if (!res.ok) {
if (res.status === 401 && token) void signOut();
const body = (data ?? {}) as Record<string, unknown>;
throw new ApiError(
typeof body.error === 'string' ? body.error : `Request failed (${res.status})`,
res.status,
typeof body.code === 'string' ? body.code : undefined,
body,
);
}
return data as T;
}
// ---------- Queries ----------
export const queryClient = new QueryClient({
defaultOptions: {
queries: {
staleTime: 30_000,
// 4xx won't fix itself; retry network/5xx once.
retry: (n, err) =>
n < 1 && !(err instanceof ApiError && err.status >= 400 && err.status < 500),
},
},
});
export const useMe = () => useQuery({ queryKey: ['me'], queryFn: () => api<Me>('/me') });
export const useCheckpoints = (kind: CheckpointKind) =>
useQuery({
queryKey: ['checkpoints', kind],
queryFn: () => api<Checkpoint[]>(`/checkpoints?kind=${kind}`),
});
export const useLeaderboard = () =>
useQuery({ queryKey: ['leaderboard'], queryFn: () => api<LeaderRow[]>('/leaderboard') });
export const useRaffles = () =>
useQuery({ queryKey: ['raffles'], queryFn: () => api<Raffle[]>('/raffles') });
export const useMerch = () =>
useQuery({ queryKey: ['merch'], queryFn: () => api<MerchItem[]>('/merch') });
/** After a scan or order: points, progress, lists and raffle eligibility all move. */
export const invalidateAll = () => queryClient.invalidateQueries();
// ---------- Formatting ----------
export const formatMoney = (minor: number, currency = 'USD') =>
new Intl.NumberFormat('en-US', { style: 'currency', currency }).format(minor / 100);

27
src/lib/theme.ts Normal file
View File

@ -0,0 +1,27 @@
// Tokens from GRVSummit/app/globals.css (the public site is the source of truth).
export const colors = {
primary: '#30614c',
secondary: '#b9d8c9',
ink: '#1a4034',
surfaceMuted: '#e8f2ec',
whiteSoft: '#fafafa',
white: '#ffffff',
grey1: '#5b5b5b',
grey2: '#a0a0a0',
grey3: '#dbdbdb',
destructive: '#dc2626',
} as const;
export const radius = 12;
// Antebas is a Fontspring DEMO build: letters only, numerals/punctuation are watermark glyphs
// (see GRVSummit/app/antebas.css). Use `display` only for text without digits; numbers use DM Sans.
export const fonts = {
display: 'Antebas-Bold',
displayBlack: 'Antebas-Black',
displayMedium: 'Antebas-Medium',
regular: 'DMSans_400Regular',
medium: 'DMSans_500Medium',
semibold: 'DMSans_600SemiBold',
bold: 'DMSans_700Bold',
} as const;

10
tsconfig.json Normal file
View File

@ -0,0 +1,10 @@
{
"extends": "expo/tsconfig.base.json",
"compilerOptions": {
"strict": true,
"noUncheckedIndexedAccess": true,
"types": []
},
"include": ["src/**/*.ts", "src/**/*.tsx", "*.d.ts", "expo-env.d.ts"],
"exclude": ["node_modules", "dist"]
}