feat(frontend): layout header + drawer + router (9 routes)
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
22
frontend/src/stores/gardens.js
Normal file
22
frontend/src/stores/gardens.js
Normal file
@@ -0,0 +1,22 @@
|
||||
import { defineStore } from 'pinia';
|
||||
import { ref } from 'vue';
|
||||
import { gardensApi } from '@/api/gardens';
|
||||
export const useGardensStore = defineStore('gardens', () => {
|
||||
const gardens = ref([]);
|
||||
const loading = ref(false);
|
||||
async function fetchAll() {
|
||||
loading.value = true;
|
||||
gardens.value = await gardensApi.list();
|
||||
loading.value = false;
|
||||
}
|
||||
async function create(g) {
|
||||
const created = await gardensApi.create(g);
|
||||
gardens.value.push(created);
|
||||
return created;
|
||||
}
|
||||
async function remove(id) {
|
||||
await gardensApi.delete(id);
|
||||
gardens.value = gardens.value.filter(g => g.id !== id);
|
||||
}
|
||||
return { gardens, loading, fetchAll, create, remove };
|
||||
});
|
||||
Reference in New Issue
Block a user