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

Merged
Janis merged 1 commits from feat/FRO-14 into main 2025-12-10 15:20:33 +01:00
2 changed files with 13 additions and 6 deletions

View File

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

View File

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