Feat : add game deletion
This commit is contained in:
@@ -71,6 +71,10 @@ button.yellow {
|
|||||||
background-color: rgba(255, 165, 0, 0.7);
|
background-color: rgba(255, 165, 0, 0.7);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
button.red {
|
||||||
|
background-color: rgba(255, 0, 0, 0.7);
|
||||||
|
}
|
||||||
|
|
||||||
button:hover:enabled {
|
button:hover:enabled {
|
||||||
background-color: #45a049;
|
background-color: #45a049;
|
||||||
}
|
}
|
||||||
@@ -78,6 +82,10 @@ button.yellow:hover {
|
|||||||
background-color: rgba(255, 165, 0, 0.8);
|
background-color: rgba(255, 165, 0, 0.8);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
button.red:hover {
|
||||||
|
background-color: rgba(255, 0, 0, 0.8);
|
||||||
|
}
|
||||||
|
|
||||||
#__nuxt {
|
#__nuxt {
|
||||||
height: 100%;
|
height: 100%;
|
||||||
user-select: none;
|
user-select: none;
|
||||||
|
|||||||
@@ -1,14 +1,28 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { kickPlayer } from "~/netcode";
|
import { deleteGame, kickPlayer } from "~/netcode";
|
||||||
import type { Game } from "~/netcode/interfaces";
|
import type { Game } from "~/netcode/interfaces";
|
||||||
|
|
||||||
export interface Props {
|
export interface Props {
|
||||||
game: Game;
|
game: Game;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const deletionConfirmation = ref("Delete Game");
|
||||||
|
|
||||||
const props = defineProps<Props>();
|
const props = defineProps<Props>();
|
||||||
|
|
||||||
const isVisible = ref(false);
|
const isVisible = ref(false);
|
||||||
|
|
||||||
|
watch(isVisible, () => {
|
||||||
|
deletionConfirmation.value = "Delete Game";
|
||||||
|
});
|
||||||
|
|
||||||
|
function deleteButtonClick() {
|
||||||
|
if (deletionConfirmation.value == "Delete Game") {
|
||||||
|
deletionConfirmation.value = "Are you sure?";
|
||||||
|
} else {
|
||||||
|
deleteGame(props.game._id);
|
||||||
|
}
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
@@ -50,6 +64,14 @@ const isVisible = ref(false);
|
|||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
</template>
|
</template>
|
||||||
|
<div class="dialog-header">
|
||||||
|
<h3>Danger Zone</h3>
|
||||||
|
</div>
|
||||||
|
<div class="dialog-header">
|
||||||
|
<button class="red" @click="deleteButtonClick">
|
||||||
|
{{ deletionConfirmation }}
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
|||||||
@@ -52,6 +52,10 @@ export async function startGame(game: string) {
|
|||||||
|
|
||||||
export async function deleteGame(game: string) {
|
export async function deleteGame(game: string) {
|
||||||
const config = useRuntimeConfig();
|
const config = useRuntimeConfig();
|
||||||
|
const res = await $fetch<Game>(config.public.endpoint + `/games/${game}`, {
|
||||||
|
method: "DELETE",
|
||||||
|
credentials: "include",
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function joinGame(game: string) {
|
export async function joinGame(game: string) {
|
||||||
|
|||||||
Reference in New Issue
Block a user