import { defineStore } from 'pinia' import { api } from '../lib/api' export const useAuthStore = defineStore('auth', { state: () => ({ user: null, status: 'idle', }), actions: { async refresh() { this.status = 'loading' try { const data = await api.me() this.user = data.user } finally { this.status = 'idle' } }, async signup(email, password) { const user = await api.signup({ email, password }) this.user = user return user }, async login(email, password) { const user = await api.login({ email, password }) this.user = user return user }, async logout() { await api.logout() this.user = null }, }, })