Add frontend/src/stores/workspace.js

This commit is contained in:
2026-06-09 23:35:31 +00:00
parent 2aeb288d80
commit 715b036eb4
+37
View File
@@ -0,0 +1,37 @@
import { defineStore } from 'pinia'
import axios from 'axios'
export const useWorkspaceStore = defineStore('workspace', {
state: () => ({
workspaces: [],
currentWorkspace: null
}),
actions: {
async fetchWorkspaces() {
try {
const response = await axios.get('/api/v1/workspaces')
this.workspaces = response.data
} catch (error) {
console.error('Failed to fetch workspaces:', error)
}
},
async createWorkspace(name, description) {
try {
const response = await axios.post('/api/v1/workspaces', { name, description })
this.workspaces.push(response.data)
return response.data
} catch (error) {
console.error('Failed to create workspace:', error)
return null
}
},
async deleteWorkspace(id) {
try {
await axios.delete(`/api/v1/workspaces/${id}`)
this.workspaces = this.workspaces.filter(w => w.id !== id)
} catch (error) {
console.error('Failed to delete workspace:', error)
}
}
}
})