Updating navigation and logged in checks.
This commit is contained in:
parent
9acde36f50
commit
59e15cfde8
11 changed files with 316 additions and 43 deletions
|
|
@ -14,4 +14,4 @@ COPY . .
|
|||
|
||||
EXPOSE 3001
|
||||
|
||||
CMD ["sh", "-c", "npx prisma db push && npm run dev"]
|
||||
CMD ["sh", "-c", "npx prisma db push --accept-data-loss && npm run dev"]
|
||||
|
|
|
|||
|
|
@ -30,8 +30,7 @@ model Game {
|
|||
locationLat Float?
|
||||
locationLng Float?
|
||||
searchRadius Float?
|
||||
timeLimitPerLeg Int?
|
||||
timeDeductionPenalty Int?
|
||||
rules String?
|
||||
status GameStatus @default(DRAFT)
|
||||
inviteCode String? @unique
|
||||
createdAt DateTime @default(now())
|
||||
|
|
|
|||
|
|
@ -82,7 +82,12 @@ router.get('/:id', async (req: AuthRequest, res: Response) => {
|
|||
return res.status(403).json({ error: 'Access denied' });
|
||||
}
|
||||
|
||||
res.json(game);
|
||||
const result = {
|
||||
...game,
|
||||
rules: game.rules ? JSON.parse(game.rules) : []
|
||||
};
|
||||
|
||||
res.json(result);
|
||||
} catch (error) {
|
||||
console.error('Get game error:', error);
|
||||
res.status(500).json({ error: 'Failed to get game' });
|
||||
|
|
@ -93,7 +98,7 @@ router.post('/', authenticate, async (req: AuthRequest, res: Response) => {
|
|||
try {
|
||||
const {
|
||||
name, description, prizeDetails, visibility, startDate,
|
||||
locationLat, locationLng, searchRadius, timeLimitPerLeg, timeDeductionPenalty
|
||||
locationLat, locationLng, searchRadius, rules
|
||||
} = req.body;
|
||||
|
||||
if (!name) {
|
||||
|
|
@ -116,8 +121,7 @@ router.post('/', authenticate, async (req: AuthRequest, res: Response) => {
|
|||
locationLat,
|
||||
locationLng,
|
||||
searchRadius,
|
||||
timeLimitPerLeg,
|
||||
timeDeductionPenalty,
|
||||
rules: rules ? JSON.stringify(rules) : null,
|
||||
gameMasterId: req.user!.id,
|
||||
inviteCode
|
||||
}
|
||||
|
|
@ -135,7 +139,7 @@ router.put('/:id', authenticate, async (req: AuthRequest, res: Response) => {
|
|||
const id = req.params.id as string;
|
||||
const {
|
||||
name, description, prizeDetails, visibility, startDate,
|
||||
locationLat, locationLng, searchRadius, timeLimitPerLeg, timeDeductionPenalty, status
|
||||
locationLat, locationLng, searchRadius, rules, status
|
||||
} = req.body;
|
||||
|
||||
const game = await prisma.game.findUnique({ where: { id } });
|
||||
|
|
@ -158,8 +162,7 @@ router.put('/:id', authenticate, async (req: AuthRequest, res: Response) => {
|
|||
locationLat,
|
||||
locationLng,
|
||||
searchRadius,
|
||||
timeLimitPerLeg,
|
||||
timeDeductionPenalty,
|
||||
rules: rules ? JSON.stringify(rules) : undefined,
|
||||
status
|
||||
}
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue