From 0f163e500b51612efc3d18030893965b9466026f Mon Sep 17 00:00:00 2001 From: iamBadgers Date: Sat, 27 Apr 2024 18:40:59 -0700 Subject: [PATCH] Add picks and apps to game details --- backend/src/app.ts | 31 ++++++++++++++++++++++---- frontend/src/vues/GameDetails.vue | 37 +++++++++++++++++++++++++++---- 2 files changed, 60 insertions(+), 8 deletions(-) diff --git a/backend/src/app.ts b/backend/src/app.ts index 93cde4d..19d7d61 100644 --- a/backend/src/app.ts +++ b/backend/src/app.ts @@ -44,7 +44,7 @@ const Pick = sequelize.define( { gameId: { type: DataTypes.INTEGER, primaryKey: true }, gameTitle: { type: DataTypes.TEXT }, - character: { type: DataTypes.INTEGER, primaryKey: true }, + characterId: { type: DataTypes.INTEGER, primaryKey: true }, characterName: { type: DataTypes.TEXT } }, { timestamps: false } @@ -79,7 +79,7 @@ app.post('/api/character', jsonParser, async (req, res) => { const count = req.body.count res.setHeader('Content-Type', 'application/json') - res.send(await Character.findAll({offset: page * count, limit: count})) + res.send(await Character.findAll({ offset: page * count, limit: count })) }) app.get('/api/game/:characterId', async (req, res) => { @@ -92,16 +92,39 @@ app.post('/api/game', jsonParser, async (req, res) => { const count = req.body.count res.setHeader('Content-Type', 'application/json') - res.send(await Game.findAll({offset: page * count, limit: count})) + res.send(await Game.findAll({ offset: page * count, limit: count })) }) app.get('/api/game/:gameId', async (req, res) => { - const game = await Game.findOne({ where: { id: req.params['gameId'] } }) console.log(game) res.send(game) }) +app.post('/api/game/:gameId/apps', async (req, res) => { + const apps = await App.findAll({ where: { gameId: req.params['gameId'] } }) + console.log(apps) + res.send(apps) +}) + +app.post('/api/character/:characterId/apps', async (req, res) => { + const apps = await App.findAll({ where: { characterId: req.params['characterId'] } }) + console.log(apps) + res.send(apps) +}) + +app.post('/api/game/:gameId/picks', async (req, res) => { + const picks = await Pick.findAll({ where: { gameId: req.params['gameId'] } }) + console.log(picks) + res.send(picks) +}) + +app.post('/api/character/:characterId/picks', async (req, res) => { + const picks = await Pick.findAll({ where: { characterId: req.params['characterId'] } }) + console.log(picks) + res.send(picks) +}) + app.listen(port, async () => { await sequelize.authenticate() return console.log(`Express is listening at http://localhost:${port}`) diff --git a/frontend/src/vues/GameDetails.vue b/frontend/src/vues/GameDetails.vue index 734318f..d588bf1 100644 --- a/frontend/src/vues/GameDetails.vue +++ b/frontend/src/vues/GameDetails.vue @@ -1,9 +1,23 @@