-
-
Save parzibyte/d22dd743378c7dd0291affca86f5cbd4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
async eliminar() { | |
const resultado = await Swal.fire({ | |
title: 'Confirmación', | |
text: `¿Eliminar "${this.props.videojuego.nombre}"?`, | |
icon: 'question', | |
showCancelButton: true, | |
confirmButtonColor: '#3298dc', | |
cancelButtonColor: '#f14668', | |
cancelButtonText: 'No', | |
confirmButtonText: 'Sí, eliminar' | |
}); | |
// Si no confirma, detenemos la función | |
if (!resultado.value) { | |
return; | |
} | |
const respuesta = await fetch(`${Constantes.RUTA_API}/eliminar_videojuego.php?id=${this.props.videojuego.id}`, { | |
method: "DELETE", | |
}); | |
const exitoso = await respuesta.json(); | |
if (exitoso) { | |
toast('Videojuego eliminado ', { | |
position: "top-left", | |
autoClose: 2000, | |
hideProgressBar: false, | |
closeOnClick: true, | |
pauseOnHover: true, | |
draggable: true, | |
progress: undefined, | |
}); | |
this.setState({ | |
eliminado: true, | |
}); | |
} else { | |
toast.error("Error eliminando. Intenta de nuevo"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment