diff --git a/availabili.tf/src/router/index.ts b/availabili.tf/src/router/index.ts index a1f98f4..ddd9aab 100644 --- a/availabili.tf/src/router/index.ts +++ b/availabili.tf/src/router/index.ts @@ -11,6 +11,7 @@ import TeamSettingsView from "@/views/TeamSettingsView.vue"; import TeamSettingsGeneralView from "@/views/TeamSettings/GeneralView.vue"; import TeamSettingsIntegrationsView from "@/views/TeamSettings/IntegrationsView.vue"; import TeamSettingsInvitesView from "@/views/TeamSettings/InvitesView.vue"; +import UserSettingsView from "@/views/UserSettingsView.vue"; const router = createRouter({ history: createWebHistory(import.meta.env.BASE_URL), @@ -72,6 +73,11 @@ const router = createRouter({ }, ], }, + { + path: "/settings", + name: "user-settings", + component: UserSettingsView, + }, ] }); diff --git a/availabili.tf/src/stores/auth.ts b/availabili.tf/src/stores/auth.ts index 27d8f77..fc62b44 100644 --- a/availabili.tf/src/stores/auth.ts +++ b/availabili.tf/src/stores/auth.ts @@ -1,7 +1,7 @@ import { defineStore } from "pinia"; import { ref } from "vue"; import { useClientStore } from "./client"; -import type { LocationQuery } from "vue-router"; +import { useRouter, type LocationQuery } from "vue-router"; export const useAuthStore = defineStore("auth", () => { const clientStore = useClientStore(); @@ -13,6 +13,8 @@ export const useAuthStore = defineStore("auth", () => { const isRegistering = ref(false); const hasCheckedAuth = ref(false); + const router = useRouter(); + async function getUser() { hasCheckedAuth.value = true; return clientStore.call( @@ -48,8 +50,16 @@ export const useAuthStore = defineStore("auth", () => { }); } - async function setUsername(username: string) { - return client.default.setUsername({ username }); + async function logout() { + return client.default.deleteApiLogin() + .then(() => router.push("/")); + } + + async function setUsername(name: string) { + return client.default.setUsername({ username: name }) + .then((response) => { + username.value = response.username; + }); } return { @@ -60,6 +70,7 @@ export const useAuthStore = defineStore("auth", () => { isRegistering, getUser, login, + logout, setUsername, } }); diff --git a/availabili.tf/src/views/UserSettingsView.vue b/availabili.tf/src/views/UserSettingsView.vue new file mode 100644 index 0000000..ec16a42 --- /dev/null +++ b/availabili.tf/src/views/UserSettingsView.vue @@ -0,0 +1,43 @@ + + + + +