diff --git a/frontend/i18n/locales/fr.json b/frontend/i18n/locales/fr.json index 57c2d34..91dbc6a 100644 --- a/frontend/i18n/locales/fr.json +++ b/frontend/i18n/locales/fr.json @@ -82,7 +82,10 @@ "list": "Impossible de récupérer la liste des camions." }, "bovin": { - "list": "Impossible de récupérer la liste des races de bovins." + "list": "Impossible de récupérer la liste des races de bovins.", + "fetch": "Impossible de récupérer le type bovin.", + "create": "Impossible de créer le type bovin.", + "update": "Impossible de mettre à jour le type bovin." }, "carrier": { "list": "Impossible de récupérer la liste des transporteurs.", @@ -133,6 +136,10 @@ "update": "Transporteur mis à jour", "create": "Transporteur créé" }, + "bovin": { + "update": "Type bovin mis à jour avec succès.", + "create": "Type bovin créé avec succès." + }, "weight": { "update": "Pesée mis à jour" } diff --git a/frontend/pages/admin/bovin/[[id]].vue b/frontend/pages/admin/bovin/[[id]].vue index a9a89c3..3735eff 100644 --- a/frontend/pages/admin/bovin/[[id]].vue +++ b/frontend/pages/admin/bovin/[[id]].vue @@ -22,9 +22,9 @@ - {{ isEdit ? 'Valider' : 'Ajouter' }} + Valider @@ -37,6 +37,8 @@ const router = useRouter() const route = useRoute() const isLoading = ref(false) const isHydrating = ref(false) +const idBovin = computed(() => resolveId(route.params.id)) +const isEdit = computed(() => idBovin.value !== null) function resolveId(param: unknown) { const idStr = Array.isArray(param) ? param[0] : param @@ -45,9 +47,6 @@ function resolveId(param: unknown) { return Number.isFinite(id) ? id : null } -const idBovin = computed(() => resolveId(route.params.id)) -const isEdit = computed(() => idBovin.value !== null) - const form = reactive({ label: '', code: '' @@ -100,7 +99,6 @@ async function validate() { } else { await createBovin(basePayload) } - await navigate() } finally { isLoading.value = false } diff --git a/frontend/pages/admin/carrier/[[id]].vue b/frontend/pages/admin/carrier/[[id]].vue index 5da4420..a3978cc 100644 --- a/frontend/pages/admin/carrier/[[id]].vue +++ b/frontend/pages/admin/carrier/[[id]].vue @@ -101,11 +101,10 @@ async function validate() { if(idCarrier.value){ await updateCarrier(idCarrier.value, basePayload) - navigate() return + }else{ + await createCarrier(basePayload) } - await createCarrier(basePayload) - navigate() } function navigate(){ diff --git a/frontend/services/bovine-type.ts b/frontend/services/bovine-type.ts index 98e62c4..1ca98f1 100644 --- a/frontend/services/bovine-type.ts +++ b/frontend/services/bovine-type.ts @@ -24,19 +24,27 @@ export async function getBovineTypeList(): Promise { export async function getBovin(id: number): Promise { const api = useApi() - const response = await api.get(`bovine_types/${id}`) + const response = await api.get(`bovine_types/${id}`, {}, { + toastErrorKey: 'errors.bovin.fetch' + }) return mapToBovineTypeData(response) } export async function createBovin(payload: BovinPayload = {}): Promise { const api = useApi() - const response = await api.post('bovine_types', toBovineTypePayload(payload)) + const response = await api.post('bovine_types', toBovineTypePayload(payload), { + toastErrorKey: 'errors.bovin.create', + toastSuccessKey: 'success.bovin.create' + }) return mapToBovineTypeData(response) } export async function updateBovin(id: number, payload: BovinPayload = {}): Promise { const api = useApi() - const response = await api.patch(`bovine_types/${id}`, toBovineTypePayload(payload)) + const response = await api.patch(`bovine_types/${id}`, toBovineTypePayload(payload), { + toastErrorKey: 'errors.bovin.update', + toastSuccessKey: 'success.bovin.update' + }) return mapToBovineTypeData(response) }