feat(api): FRO-14 Create Game (#14)

Added functionality to create Game so that it creates a game in the Backend

Co-authored-by: LQ63 <lkhermann@web.de>
Reviewed-on: #14
Reviewed-by: Janis <janis-e@gmx.de>
Co-authored-by: lq64 <lq@blackhole.local>
Co-committed-by: lq64 <lq@blackhole.local>
This commit is contained in:
2025-12-10 15:20:33 +01:00
committed by Janis
parent 8758f95fcd
commit df61db2730
2 changed files with 13 additions and 6 deletions

View File

@@ -2,7 +2,9 @@
import { ref } from 'vue';
import { useQuasar } from 'quasar';
import { useRouter } from 'vue-router';
import axios from "axios";
const api = window?.__RUNTIME_CONFIG__?.API_URL;
const lobbyName = ref('');
const isPublic = ref(false);
const playerAmount = ref(2);
@@ -16,16 +18,21 @@ const createGameQuasar = async () => {
return;
}
isLoading.value = true;
//TODO: Implement Logic to Create the Game and Redirect to Lobby
await delay(3000)
isLoading.value = false;
axios.post(`${api}/createGame`, {lobbyname: lobbyName.value, playeramount: playerAmount.value.toString()}, {withCredentials: true}).then((response) => {
const responseData = response.data
console.log("Response" + responseData.status)
$q.notify({
message: `Lobby "${lobbyName.value}" erfolgreich erstellt!`,
message: `Lobby "${lobbyName.value}" erfolgreich erstellt mit gameId ${responseData.gameId}!`,
color: 'green-6',
icon: 'check_circle',
position: 'top'
});
router.push({ name: 'mainmenu'});
router.push("/lobby")
}).catch((err) => {
console.log("ERROR:" + err)
}).finally(() =>
isLoading.value = false
)
}
</script>

View File

@@ -80,7 +80,7 @@ const onSubmit = () => {
loginError.value = ''
axios.post(`${api}/login`, {username: username.value, password: password.value}, {withCredentials: true}).then((response) => {
uInfo.setUserInfo(response.data.user.username, response.data.user.id)
router.push("/")
router.push("/mainmenu")
}).catch(() => {
loginError.value = 'Invalid username or password'
}).finally(() =>