diff --git a/src/components/GamePage.vue b/src/components/GamePage.vue index 7c3f178..3514757 100644 --- a/src/components/GamePage.vue +++ b/src/components/GamePage.vue @@ -5,7 +5,7 @@ import { getAuthClient } from '@/api/auth_client'; import { Icon } from '@vicons/utils' import { NButton } from 'naive-ui' import type { Application, Game, Team } from '@/api/generated/crabs/evening_detective_server'; -import { NCard, NInput, NModal, NSpace, NFlex } from 'naive-ui' +import { NCard, NInput, NModal, NSpace, NFlex, NText } from 'naive-ui' import HeaderMenu from '@/components/HeaderMenu.vue' import { useMessage } from 'naive-ui'; import { ref } from 'vue'; @@ -20,6 +20,9 @@ const message = useMessage() const showSettingsModal = ref(false) const showGiveApplicationModal = ref(false) +const showAddTeamModal = ref(false) +const showDeleteTeamModal = ref(false) +const newTeamName = ref('') const game = ref({ id: undefined, @@ -70,6 +73,16 @@ const giveApplicationTeam = ref({ applications: [] }) +const deletedTeamName = ref('') +const deletedTeam = ref({ + id: 0, + name: '', + status: '', + password: '', + actionsCount: 0, + applications: [] +}) + const giveApplicationApplication = ref({ name: '', image: '' @@ -81,6 +94,19 @@ function giveApplication(team: Team, application: Application) { showGiveApplicationModal.value = true } +async function addTeam() { + const res = await client.AddTeam({ + gameId: game.value.id, + name: newTeamName.value, + }) + if (res.error != '') { + message.error(res.error!) + return + } + await getGame(game.value.id!) + showAddTeamModal.value = false +} + async function confirmGiveApplication() { const res = await client.GiveTeamApplications({ id: giveApplicationTeam.value.id, @@ -93,6 +119,23 @@ async function confirmGiveApplication() { await getGame(game.value.id!) showGiveApplicationModal.value = false } + +async function deleteTeam(team: Team) { + deletedTeam.value = team + showDeleteTeamModal.value = true +} + +async function confirmDeleteTeam() { + const res = await client.DeleteTeam({ + id: deletedTeam.value.id, + }) + if (res.error != '') { + message.error(res.error!) + return + } + await getGame(game.value.id!) + showDeleteTeamModal.value = false +}