import Link from 'next/link' import { Trophy, ShieldCheck, Accessibility, Users, Award } from 'lucide-react' import { Navigation } from '@/components/navigation' import { Footer } from '@/components/footer' import { getPublicEvent, getPublicPrizes } from '@/lib/lukenya-api' import { findPrize, formatMoney, ordinal, type PrizeCategory, type PrizeRow } from '@/lib/event-types' export const revalidate = 60 type PrizeLine = { place: string; amount: string; highlight?: boolean } const PLACE = (n: number) => ordinal(n) || String(n) // Men and women side by side, one row per finishing position. function rowsFor(category: PrizeCategory, currency: string): { men: PrizeLine[]; women: PrizeLine[] } { const men = category.divisions.find((d) => d.division === 'Men')?.places || [] const women = category.divisions.find((d) => d.division === 'Women')?.places || [] const positions = Array.from(new Set([...men, ...women].map((p) => p.position))).sort((x, y) => x - y) const fmt = (rows: PrizeRow[], pos: number) => { const row = rows.find((r) => r.position === pos) return row ? (formatMoney(row.amount, currency)?.replace(`${currency} `, '') || '—') : '—' } return { men: positions.map((pos) => ({ place: PLACE(pos), amount: fmt(men, pos), highlight: pos === 1 })), women: positions.map((pos) => ({ place: PLACE(pos), amount: fmt(women, pos), highlight: pos === 1 })), } } const SPECIAL = [ { division: 'Wheelchair', icon: Accessibility, title: 'Wheelchair Category', description: 'Top finishers in the wheelchair division' }, { division: 'Corporate Relay', icon: Users, title: 'Corporate Relay', description: 'Fastest corporate relay teams' }, { division: 'Age Group', icon: Award, title: 'Age Category Awards', description: 'Top finishers in each age group' }, ] function PrizeTable({ title, men, women }: { title: string men: { place: string; amount: string; highlight?: boolean }[] women: { place: string; amount: string; highlight?: boolean }[] }) { return (

{title}

{men.map((prize, index) => ( ))}
Place Men Women
{prize.place} {prize.amount} {women[index]?.amount}
) } function CompactPrizeTable({ title, men, women }: { title: string men: { place: string; amount: string }[] women: { place: string; amount: string }[] }) { return (

{title}

{men.map((prize, index) => ( ))}
Place Men Women
{prize.place} {prize.amount} {women[index]?.amount}
) } export default async function PrizeMoneyPage() { const [event, prizes] = await Promise.all([getPublicEvent(), getPublicPrizes()]) const currency = prizes?.currency || event.currency // Races with Men/Women prize rules, in the order the backend sends them (featured first). const raceTables = (prizes?.categories || []).filter((c) => c.divisions.some((d) => d.division === 'Men' || d.division === 'Women'), ) const [mainRace, ...otherRaces] = raceTables const specials = SPECIAL.map((s) => ({ ...s, amount: findPrize(prizes, s.division, 1) })) return (
{/* Page Hero */}
Compete for Real Rewards

Prize Money

{raceTables.length ? `Structured prize money across ${raceTables.length} ${raceTables.length === 1 ? 'race' : 'races'}, paid on race day.` : 'Structured prize money, paid on race day.'}

{/* Main race */}
Top Prize Category

{mainRace ? `${mainRace.category_name}, ${mainRace.distance_label}` : 'Prize structure'}

{mainRace ? ( ) : (

Prize amounts for each race are published here before entries open.

)}
{otherRaces.length > 0 && (

Other races

{otherRaces.map((race) => ( ))}
)} {/* Special Categories */}
Special Categories

Additional Prize Categories

{specials.map((category, index) => (

{category.title}

{formatMoney(category.amount, currency) || 'To be announced'}

{category.description}

))}
{/* Prize Payment Info */}
Sporthive Certified Results
|

Prize money paid on race day. Winners must present valid ID. All prizes subject to race rules.

{/* CTA Section */}

Ready to Compete?

Register now and compete for prize money at Kenya's environmental marathon.

REGISTER NOW
) }