Move banner system to store, migrate login/register API handling to own file, display Account details on accountPage
This commit is contained in:
@@ -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>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user