diff --git a/backend/prisma/schema.prisma b/backend/prisma/schema.prisma index d8ebfb8..4ed3053 100644 --- a/backend/prisma/schema.prisma +++ b/backend/prisma/schema.prisma @@ -119,6 +119,7 @@ enum GameStatus { DRAFT LIVE ENDED + ARCHIVED } enum TeamStatus { diff --git a/backend/src/routes/games.ts b/backend/src/routes/games.ts index 97c48a7..3455f7b 100644 --- a/backend/src/routes/games.ts +++ b/backend/src/routes/games.ts @@ -251,6 +251,56 @@ router.post('/:id/end', authenticate, async (req: AuthRequest, res: Response) => } }); +router.post('/:id/archive', authenticate, async (req: AuthRequest, res: Response) => { + try { + const id = req.params.id as string; + + const game = await prisma.game.findUnique({ where: { id } }); + if (!game) { + return res.status(404).json({ error: 'Game not found' }); + } + + if (game.gameMasterId !== req.user!.id) { + return res.status(403).json({ error: 'Not authorized' }); + } + + const updated = await prisma.game.update({ + where: { id }, + data: { status: 'ARCHIVED' } + }); + + res.json(updated); + } catch (error) { + console.error('Archive game error:', error); + res.status(500).json({ error: 'Failed to archive game' }); + } +}); + +router.post('/:id/unarchive', authenticate, async (req: AuthRequest, res: Response) => { + try { + const id = req.params.id as string; + + const game = await prisma.game.findUnique({ where: { id } }); + if (!game) { + return res.status(404).json({ error: 'Game not found' }); + } + + if (game.gameMasterId !== req.user!.id) { + return res.status(403).json({ error: 'Not authorized' }); + } + + const updated = await prisma.game.update({ + where: { id }, + data: { status: 'ENDED' } + }); + + res.json(updated); + } catch (error) { + console.error('Unarchive game error:', error); + res.status(500).json({ error: 'Failed to unarchive game' }); + } +}); + router.get('/:id/invite', async (req: AuthRequest, res: Response) => { try { const id = req.params.id as string; diff --git a/frontend/index.html b/frontend/index.html index 096d706..02d3466 100644 --- a/frontend/index.html +++ b/frontend/index.html @@ -4,7 +4,8 @@ -
You haven't created any games yet.
-{{ showArchived ? 'No archived games.' : 'You haven\'t created any games yet.' }}
+Total route distance: {{ getTotalDistance().toFixed(2) }} km
+Total route distance: {{ getTotalDistance().toFixed(2) }} km
-{{ leg.description }}
- -{{ leg.description }}
+ + +No legs added yet
+Click on map to set location
+Click on map to set location
-{{ game.description }}
-{{ game.prizeDetails }}
-{{ leg.description }}
- -+ {{ game.status }} + · {{ game.visibility }} + · Starts: {{ new Date(game.startDate).toLocaleString() }} +
+ + +{{ game.description }}
+{{ game.prizeDetails }}
+| # | +Description | +Type | +Time | +
|---|---|---|---|
| {{ leg.sequenceNumber }} | +{{ leg.description }} | +{{ leg.conditionType }} | +{{ leg.timeLimit ? `${leg.timeLimit} min` : '-' }} | +
| Name | +Status | +Members | +
|---|---|---|
| {{ team.name }} | +{{ team.status }} | +{{ team.members?.length || 0 }} | +
Online scavenger hunt adventure
-Online scavenger hunt adventure
+ +No active games found. Be the first to create one!
+{{ game.description.slice(0, 100) }}...
- +{{ game.name }}
+{{ game.description }}
+ +You are on team: {{ userTeam.name }}
-Teams can have 3-5 members
+ + +{{ error }}
- Don't have an account?
Don't have an account?
{{ currentLeg.description }}
- - +{{ currentLeg.description }}
+🎉 Congratulations! You've completed the hunt!
Waiting for the game to start...
-Leg {{ currentLegIndex + 1 }} of {{ game.legs?.length || 0 }}
-- Time penalty: {{ team.totalTimeDeduction }} seconds + +
Leg {{ currentLegIndex + 1 }} of {{ game.legs?.length || 0 }}
++ Time penalty: {{ team.totalTimeDeduction }} seconds
-{{ error }}
- Already have an account?
Already have an account?