maj via codex
This commit is contained in:
@@ -14,9 +14,16 @@ export const usePlantingsStore = defineStore('plantings', () => {
|
||||
plantings.value.push(created);
|
||||
return created;
|
||||
}
|
||||
async function update(id, p) {
|
||||
const updated = await plantingsApi.update(id, p);
|
||||
const idx = plantings.value.findIndex(x => x.id === id);
|
||||
if (idx !== -1)
|
||||
plantings.value[idx] = updated;
|
||||
return updated;
|
||||
}
|
||||
async function remove(id) {
|
||||
await plantingsApi.delete(id);
|
||||
plantings.value = plantings.value.filter(p => p.id !== id);
|
||||
}
|
||||
return { plantings, loading, fetchAll, create, remove };
|
||||
return { plantings, loading, fetchAll, create, update, remove };
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user