Added base project

This commit is contained in:
2025-12-04 20:45:22 +00:00
parent dc16a150e1
commit 2f47f69adb
148 changed files with 3289 additions and 4212 deletions
+37
View File
@@ -0,0 +1,37 @@
import { defineStore } from 'pinia'
import { ref, computed } from 'vue'
import { useAPIStore } from './api'
export const useAuthStore = defineStore('auth', () => {
const apiStore = useAPIStore()
const currentUser = ref(undefined)
const isLoggedIn = computed(() => {
return currentUser.value !== undefined
})
const currentUserID = computed(() => {
return currentUser.value?.id
})
const login = async (credentials) => {
await apiStore.postLogin(credentials)
const response = await apiStore.getAuthUser()
currentUser.value = response.data
return response.data
}
const logout = async () => {
await apiStore.postLogout()
currentUser.value = undefined
}
return {
currentUser,
isLoggedIn,
currentUserID,
login,
logout,
}
})