TaskSchema module

This commit is contained in:
Marek Lenczewski
2026-04-12 15:42:48 +02:00
parent 4e81cea831
commit 5198769de4
57 changed files with 3066 additions and 324 deletions

View File

@@ -0,0 +1,44 @@
import { defineStore } from 'pinia'
import { schemaApi } from '../services/api'
export const useSchemasStore = defineStore('schemas', {
state: () => ({
schemas: [],
loading: false,
error: null,
}),
actions: {
async fetchAll() {
this.loading = true
this.error = null
try {
this.schemas = await schemaApi.list()
} catch (e) {
this.error = e.message
} finally {
this.loading = false
}
},
async get(id) {
return schemaApi.get(id)
},
async create(data) {
const result = await schemaApi.create(data)
return result
},
async update(id, data) {
const updated = await schemaApi.update(id, data)
this.schemas = this.schemas.map((s) => (s.id === id ? updated : s))
return updated
},
async remove(id) {
await schemaApi.remove(id)
this.schemas = this.schemas.filter((s) => s.id !== id)
},
},
})

View File

@@ -44,12 +44,6 @@ export const useTasksStore = defineStore('tasks', {
this.availableStatuses = await taskApi.statuses()
},
async create(data) {
const task = await taskApi.create(data)
this.tasks.push(task)
return task
},
async update(id, data) {
const updated = await taskApi.update(id, data)
this.replaceLocal(updated)