fix(plantes): deleteVariety/submitVariety — try/catch + refresh detailPlantObj
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -868,6 +868,7 @@ function closeFormVariety() {
|
|||||||
async function submitVariety() {
|
async function submitVariety() {
|
||||||
if (!detailPlantObj.value?.id) return
|
if (!detailPlantObj.value?.id) return
|
||||||
const payload = { ...formVariety, prix_achat: formVariety.prix_achat ?? undefined }
|
const payload = { ...formVariety, prix_achat: formVariety.prix_achat ?? undefined }
|
||||||
|
try {
|
||||||
if (editVariety.value?.id) {
|
if (editVariety.value?.id) {
|
||||||
await plantsStore.updateVariety(detailPlantObj.value.id, editVariety.value.id, payload)
|
await plantsStore.updateVariety(detailPlantObj.value.id, editVariety.value.id, payload)
|
||||||
toast.success('Variété modifiée')
|
toast.success('Variété modifiée')
|
||||||
@@ -880,13 +881,23 @@ async function submitVariety() {
|
|||||||
const updatedPlant = plantsStore.plants.find(p => p.id === detailPlantObj.value?.id)
|
const updatedPlant = plantsStore.plants.find(p => p.id === detailPlantObj.value?.id)
|
||||||
if (updatedPlant) detailPlantObj.value = updatedPlant
|
if (updatedPlant) detailPlantObj.value = updatedPlant
|
||||||
closeFormVariety()
|
closeFormVariety()
|
||||||
|
} catch {
|
||||||
|
// L'intercepteur Axios affiche le message d'erreur
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function deleteVariety(vid: number) {
|
async function deleteVariety(vid: number) {
|
||||||
if (!detailPlantObj.value?.id) return
|
if (!detailPlantObj.value?.id) return
|
||||||
if (!confirm('Supprimer cette variété ?')) return
|
if (!confirm('Supprimer cette variété ?')) return
|
||||||
|
try {
|
||||||
await plantsStore.removeVariety(detailPlantObj.value.id, vid)
|
await plantsStore.removeVariety(detailPlantObj.value.id, vid)
|
||||||
|
await plantsStore.fetchAll()
|
||||||
|
const updatedPlant = plantsStore.plants.find(p => p.id === detailPlantObj.value?.id)
|
||||||
|
if (updatedPlant) detailPlantObj.value = updatedPlant
|
||||||
toast.success('Variété supprimée')
|
toast.success('Variété supprimée')
|
||||||
|
} catch {
|
||||||
|
// L'intercepteur Axios affiche le message d'erreur
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function submitPlant() {
|
async function submitPlant() {
|
||||||
|
|||||||
Reference in New Issue
Block a user