This commit is contained in:
Veljko Tosic
2026-02-16 18:18:21 +01:00
parent c200847c17
commit 5d148db4da
17 changed files with 399 additions and 15 deletions

View File

@@ -0,0 +1,50 @@
import { defineStore } from 'pinia'
import { ref } from 'vue'
import type { Whiteboard } from '@/types'
import { whiteboardService } from '@/services/whiteboardService'
export const useWhiteboardStore = defineStore('whiteboards', () => {
const ownedWhiteboards = ref<Whiteboard[]>([])
const recentWhiteboards = ref<Whiteboard[]>([])
const isLoading = ref(false)
const error = ref<string | null>(null)
async function getWhiteboardHistory() {
isLoading.value = true
error.value = null
try {
ownedWhiteboards.value = await whiteboardService.getWhiteboardHistory()
} catch (err: any) {
error.value = err.message ?? 'Failed to load whiteboards'
} finally {
isLoading.value = false
}
}
async function getRecentWhiteboards() {
isLoading.value = true
error.value = null
try {
recentWhiteboards.value = await whiteboardService.getRecentWhiteboards()
} catch (err: any) {
error.value = err.message ?? 'Failed to load whiteboards'
} finally {
isLoading.value = false
}
}
function clearWhiteboards() {
ownedWhiteboards.value = []
recentWhiteboards.value = []
}
return {
ownedWhiteboards: ownedWhiteboards,
recentWhiteboards: recentWhiteboards,
isLoading,
error,
getWhiteboardHistory: getWhiteboardHistory,
getRecentWhiteboards: getRecentWhiteboards,
clearWhiteboards: clearWhiteboards
}
})