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 };
|
||||
});
|
||||
22
frontend/src/stores/plantings.js
Normal file
22
frontend/src/stores/plantings.js
Normal file
@@ -0,0 +1,22 @@
|
||||
import { defineStore } from 'pinia';
|
||||
import { ref } from 'vue';
|
||||
import { plantingsApi } from '@/api/plantings';
|
||||
export const usePlantingsStore = defineStore('plantings', () => {
|
||||
const plantings = ref([]);
|
||||
const loading = ref(false);
|
||||
async function fetchAll() {
|
||||
loading.value = true;
|
||||
plantings.value = await plantingsApi.list();
|
||||
loading.value = false;
|
||||
}
|
||||
async function create(p) {
|
||||
const created = await plantingsApi.create(p);
|
||||
plantings.value.push(created);
|
||||
return created;
|
||||
}
|
||||
async function remove(id) {
|
||||
await plantingsApi.delete(id);
|
||||
plantings.value = plantings.value.filter(p => p.id !== id);
|
||||
}
|
||||
return { plantings, loading, fetchAll, create, remove };
|
||||
});
|
||||
29
frontend/src/stores/tasks.js
Normal file
29
frontend/src/stores/tasks.js
Normal file
@@ -0,0 +1,29 @@
|
||||
import { defineStore } from 'pinia';
|
||||
import { ref } from 'vue';
|
||||
import { tasksApi } from '@/api/tasks';
|
||||
export const useTasksStore = defineStore('tasks', () => {
|
||||
const tasks = ref([]);
|
||||
const loading = ref(false);
|
||||
async function fetchAll(params) {
|
||||
loading.value = true;
|
||||
tasks.value = await tasksApi.list(params);
|
||||
loading.value = false;
|
||||
}
|
||||
async function create(t) {
|
||||
const created = await tasksApi.create(t);
|
||||
tasks.value.push(created);
|
||||
return created;
|
||||
}
|
||||
async function updateStatut(id, statut) {
|
||||
const t = tasks.value.find(t => t.id === id);
|
||||
if (!t)
|
||||
return;
|
||||
const updated = await tasksApi.update(id, { ...t, statut });
|
||||
Object.assign(t, updated);
|
||||
}
|
||||
async function remove(id) {
|
||||
await tasksApi.delete(id);
|
||||
tasks.value = tasks.value.filter(t => t.id !== id);
|
||||
}
|
||||
return { tasks, loading, fetchAll, create, updateStatut, remove };
|
||||
});
|
||||
22
frontend/src/stores/varieties.js
Normal file
22
frontend/src/stores/varieties.js
Normal file
@@ -0,0 +1,22 @@
|
||||
import { defineStore } from 'pinia';
|
||||
import { ref } from 'vue';
|
||||
import { varietiesApi } from '@/api/varieties';
|
||||
export const useVarietiesStore = defineStore('varieties', () => {
|
||||
const varieties = ref([]);
|
||||
const loading = ref(false);
|
||||
async function fetchAll() {
|
||||
loading.value = true;
|
||||
varieties.value = await varietiesApi.list();
|
||||
loading.value = false;
|
||||
}
|
||||
async function create(v) {
|
||||
const created = await varietiesApi.create(v);
|
||||
varieties.value.push(created);
|
||||
return created;
|
||||
}
|
||||
async function remove(id) {
|
||||
await varietiesApi.delete(id);
|
||||
varieties.value = varieties.value.filter(v => v.id !== id);
|
||||
}
|
||||
return { varieties, loading, fetchAll, create, remove };
|
||||
});
|
||||
Reference in New Issue
Block a user