Skip to content

Commit

Permalink
(frontend): Create teams modal
Browse files Browse the repository at this point in the history
  • Loading branch information
renanstn committed Dec 13, 2023
1 parent e432a35 commit 319a576
Showing 1 changed file with 41 additions and 1 deletion.
42 changes: 41 additions & 1 deletion frontend/src/views/MainView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,12 @@
<el-button type="success" round @click="open_join_game_modal(scope.row.id)">
Join
</el-button>
<el-button type="warning" round>Generate teams</el-button>
<el-button type="primary" round @click="show_teams(scope.row.id)">
Show teams
</el-button>
<el-button type="warning" round @click="generate_team(scope.row.id)">
Generate teams
</el-button>
</template>
</el-table-column>
</el-table>
Expand Down Expand Up @@ -115,6 +120,17 @@
</template>
</el-dialog>

<!-- Teams modal ---------------------------------------------------- -->
<el-dialog title="Teams" v-model="teams_visible">
<div v-for="(team, index) in teams" :key="index">
<h4>{{ team.name }}</h4>
<el-table :data="team.players" border>
<el-table-column prop="name" label="Player" />
</el-table>
<el-divider />
</div>
</el-dialog>

</el-main>
</el-container>
</template>
Expand Down Expand Up @@ -143,12 +159,14 @@ export default {
return {
game_id: null,
games: [],
teams: [],
player: {
name: null,
},
create_game_visible: false,
join_game_visible: false,
login_visible: false,
teams_visible: false,
login_form: {
user: null,
pass: null,
Expand Down Expand Up @@ -238,6 +256,13 @@ export default {
method: "POST",
headers: { 'Content-Type': 'application/json' },
})
.then(response => {
if (!response.ok) { throw new Error('Error sendind request') }
return response.json()
})
.then(() => {
ElMessage({message: 'Teams generated!', type: 'success'})
})
},
create_game() {
Expand All @@ -258,6 +283,21 @@ export default {
this.load_games()
})
},
show_teams(game_id) {
const url = `http://localhost:8000/teams/${game_id}`
fetch(url, {method: "GET"})
.then(response => {
if (!response.ok) { throw new Error('Error sendind request') }
return response.json()
})
.then(data => {
console.log(data)
this.teams = data
this.teams_visible = true
})
},
},
}
</script>

0 comments on commit 319a576

Please sign in to comment.