import { ref } from "vue"; import { defineStore } from "pinia"; import type { User } from "@/types"; export const useAuthStore = defineStore("auth", () => { const isAuthenticated = ref(false); const user = ref(null); async function getUser() { try { const response = await fetch("/api/me"); const data = await response.json(); user.value = data.profile; isAuthenticated.value = true; } catch { window.location.href = "/api/login"; } } return { isAuthenticated, user, getUser, }; });