Added confirm before object removal

main
Antonio De Lucreziis 2 years ago
parent af6e835c0c
commit 81e2263a09

@ -49,14 +49,21 @@ export const Bucket = () => {
}
const deleteObject = async id => {
if (!confirm(`Cancellare l'oggetto con id ${id} da questo bucket?`)) {
showToast(<ToastMessage icon="info">Operazione annullata</ToastMessage>)
return
}
const res = await fetch(`/api/buckets/${bucket}/${id}`, { method: 'DELETE' })
if (res.ok) {
showToast('Oggetto rimosso')
showToast(<ToastMessage icon="info">Oggetto rimosso</ToastMessage>)
await updateBucketObjects()
} else {
showToast(`Errore "${await res.text()}"`)
showToast(
<ToastMessage icon="error">Errore del server "{await res.text()}"</ToastMessage>
)
}
}

Loading…
Cancel
Save