Added icon change
All checks were successful
Build and Deploy Nuxt / build (push) Successful in 39s

This commit is contained in:
2026-04-26 21:12:08 +02:00
parent 9048bb0f11
commit 475887420c
20 changed files with 668 additions and 41 deletions

View File

@@ -14,6 +14,7 @@ import WindowHandle from './partials/WindowHandle.vue';
import { DisplayToast } from '~/services/Toaster';
import Server from '~/services/Server';
import { SetUser } from '~/services/User';
import Spinner from '../partials/Spinner.vue';
const handle = ref(null);
@@ -25,6 +26,8 @@ let id = data.type;
const username = ref("");
const password = ref("");
const loading = ref(false);
onMounted(() => {
SetupHandle(id, handle);
SetSize(id, {width: 450, height: 480});
@@ -32,27 +35,28 @@ onMounted(() => {
ResetPosition(id, "center");
});
function ShowMainMenu(){
CreateWindow('main_menu');
ClearWindow('login');
}
function login() {
Server().post('/user/login', { username: username.value, password: password.value }).then((response) => {
const data = response.data;
console.log(data);
loading.value = true;
Server().post('/user/login', { usermail: username.value, password: password.value }).then((response) => {
loading.value = false;
const data = response.data;
if(data.status == "error"){
DisplayToast('red', "Wrong username or password", 3000)
} else {
SetUser(data.token);
ShowMainMenu();
}
}).catch((error) => {
console.log(error);
if(error.response.status == 429){
// errorMessage.value = error.response.data;
} else {
// errorMessage.value = "Hi ha hagut un error intern, torna'ho a provar més tard";
console.log(error);
}
});
if(data.status == "error"){
DisplayToast('red', $t(data.msg), 3000)
} else {
SetUser(data.token);
DisplayToast('green', $t('login.success'), 3000);
ShowMainMenu();
}
}).catch((error) => {
loading.value = false;
DisplayToast('red', $t("errors.internal"), 3000);
});
}
function toRegister(){
@@ -84,7 +88,14 @@ function toRegister(){
<input id="password-field" type="password" :placeholder="$t('login.password-placeholder')" name="password" v-model="password" autocomplete="off" >
</div>
<div class="form-field">
<button class="btn-primary sound-click">{{$t('login.log-in')}}</button>
<button class="btn-primary sound-click">
<span v-if="loading">
<Spinner />
</span>
<span v-else>
{{$t('login.log-in')}}
</span>
</button>
</div>
<div class="form-field center">
<p>{{$t('login.no-account')}} <a href="#" @click.prevent="toRegister">{{$t('login.register')}}</a></p>