feat: auto complete missing custom fields on machine page

This commit is contained in:
MatthieuTD
2025-09-22 11:12:00 +02:00
parent ae103a38be
commit 5501b3b5ef
2 changed files with 355 additions and 5 deletions

View File

@@ -97,6 +97,34 @@ export function useMachines() {
}
}
const addMissingCustomFields = async (machineId, { showToast: shouldShowToast = true } = {}) => {
if (!machineId) {
const error = 'Identifiant de machine manquant'
if (shouldShowToast) {
showError(error)
}
return { success: false, error }
}
try {
const result = await post(`/machines/${machineId}/add-custom-fields`)
if (result.success) {
if (shouldShowToast) {
showSuccess('Champs personnalisés complétés avec succès')
}
} else if (shouldShowToast && result.error) {
showError(result.error)
}
return result
} catch (error) {
console.error('Erreur lors de lajout des champs personnalisés manquants:', error)
if (shouldShowToast) {
showError('Erreur lors de la complétion des champs personnalisés')
}
return { success: false, error: error.message }
}
}
const deleteMachine = async (id) => {
loading.value = true
try {
@@ -143,6 +171,7 @@ export function useMachines() {
getMachinesBySite,
getMachinesByType,
getMachines,
isLoading
isLoading,
addMissingCustomFields
}
}
}