feat(front) : bouton Valider l'entrée avec confirmation si saisies incomplètes
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -116,7 +116,9 @@
|
||||
<UiButton
|
||||
type="button"
|
||||
class="text-md font-bold uppercase bg-primary-500 text-white h-[50px] px-8"
|
||||
disabled
|
||||
:disabled="savedBovines.length === 0 || isValidating"
|
||||
:loading="isValidating"
|
||||
@click="validateEntry"
|
||||
>
|
||||
Valider l'entrée
|
||||
</UiButton>
|
||||
@@ -144,6 +146,7 @@ const buildings = ref<BuildingData[]>([])
|
||||
const savedBovines = ref<BovineData[]>([])
|
||||
|
||||
const isAdding = ref(false)
|
||||
const isValidating = ref(false)
|
||||
const recapPage = ref(1)
|
||||
const recapPerPage = ref(50)
|
||||
|
||||
@@ -181,6 +184,25 @@ const confirmDeleteBovine = async (bovine: BovineData) => {
|
||||
await loadSavedBovines()
|
||||
}
|
||||
|
||||
const validateEntry = async () => {
|
||||
if (savedBovines.value.length === 0 || isValidating.value) return
|
||||
|
||||
if (savedBovines.value.length < declaredCount.value) {
|
||||
const confirmed = window.confirm(
|
||||
`Vous n'avez saisi que ${savedBovines.value.length}/${declaredCount.value} bovins. Confirmer la fermeture de l'entrée ?`
|
||||
)
|
||||
if (!confirmed) return
|
||||
}
|
||||
|
||||
isValidating.value = true
|
||||
try {
|
||||
await api.patch(`receptions/${receptionId.value}`, { entryCompleted: true })
|
||||
router.push('/entry-exit')
|
||||
} finally {
|
||||
isValidating.value = false
|
||||
}
|
||||
}
|
||||
|
||||
interface FormState {
|
||||
nationalNumber: string
|
||||
receivedWeight: number | null
|
||||
|
||||
Reference in New Issue
Block a user