Move banner system to store, migrate login/register API handling to own file, display Account details on accountPage

This commit is contained in:
2024-09-19 16:20:12 +02:00
parent fbefa52e01
commit 58fcae647a
19 changed files with 250 additions and 141 deletions

View File

@@ -1,33 +1,15 @@
<script setup lang="ts">
import { BannerStateEnum } from '@/data/enums/bannerStateEnum';
import BannerModel from '@/data/models/bannerModel';
import { useUserStore } from '@/data/stores/userStore';
import axios from 'axios';
import { ref } from 'vue';
const userStore = useUserStore()
const showRegisterCard = defineModel("showRegisterCard", { type: Boolean, default: false })
const banner = defineModel("banner", { type: BannerModel })
const username = ref("")
const password = ref("")
function startLogin() {
axios.post('http://127.0.0.1:3000/accounts/login', {
username: username.value,
password: password.value
})
.then(res => {
if (res.status == 200) {
banner.value.bannerState = BannerStateEnum.LOGINSUCCESSFUL
banner.value.show = true
userStore.userAccountId = res.data.userAccountId
}
})
.catch(res => {
banner.value.bannerState = BannerStateEnum.WRONGLOGIN
banner.value.show = true
})
userStore.login(username.value, password.value)
}
</script>