From 715b036eb49901211bda64406302a493e4a545a4 Mon Sep 17 00:00:00 2001 From: Leopoldadmin Date: Tue, 9 Jun 2026 23:35:31 +0000 Subject: [PATCH] Add frontend/src/stores/workspace.js --- frontend/src/stores/workspace.js | 37 ++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 frontend/src/stores/workspace.js diff --git a/frontend/src/stores/workspace.js b/frontend/src/stores/workspace.js new file mode 100644 index 0000000..c416f8e --- /dev/null +++ b/frontend/src/stores/workspace.js @@ -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) + } + } + } +})