Implementado Unstuck y Cambio de correo
This commit is contained in:
@@ -1,34 +1,45 @@
|
||||
$(document).ready(function() {
|
||||
$('#nw-change-email-form').on('submit', function(e) {
|
||||
e.preventDefault(); // Evitar el envío por defecto del formulario
|
||||
function handleResponse(response, button, originalText) {
|
||||
$("#change-email-response").html(response.message).hide().slideDown();
|
||||
|
||||
if (response.redirect_url) {
|
||||
setTimeout(function() {
|
||||
window.location.href = response.redirect_url;
|
||||
}, 2000);
|
||||
return;
|
||||
}
|
||||
|
||||
if (response.success) {
|
||||
button.html("Proceso completado");
|
||||
} else {
|
||||
setTimeout(function() {
|
||||
$("#change-email-response").slideUp(function() {
|
||||
$("#change-email-response").empty();
|
||||
button.html(originalText);
|
||||
button.prop("disabled", false);
|
||||
});
|
||||
}, 5000);
|
||||
}
|
||||
}
|
||||
|
||||
// Manejar los enlaces de confirmación
|
||||
$('.confirm-link').on('click', function(e) {
|
||||
e.preventDefault();
|
||||
$("#change-email-response").empty();
|
||||
|
||||
var form = $(this);
|
||||
var button = $('.change-email-button');
|
||||
var button = $(this);
|
||||
var url = button.attr('href');
|
||||
var originalText = button.html();
|
||||
|
||||
button.html("Cambiando correo...");
|
||||
button.html("Verificando...");
|
||||
button.prop("disabled", true);
|
||||
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: form.attr('action'),
|
||||
data: form.serialize(), // Serializar los datos correctamente
|
||||
type: 'GET',
|
||||
url: url,
|
||||
dataType: 'json',
|
||||
success: function(response) {
|
||||
$("#change-email-response").html(response.message).hide().slideDown();
|
||||
|
||||
if (response.success) {
|
||||
button.html("Correo cambiado");
|
||||
} else {
|
||||
setTimeout(function() {
|
||||
$("#change-email-response").slideUp(function() {
|
||||
$("#change-email-response").empty();
|
||||
button.html(originalText);
|
||||
button.prop("disabled", false);
|
||||
});
|
||||
}, 5000);
|
||||
}
|
||||
handleResponse(response, button, originalText);
|
||||
},
|
||||
error: function(xhr, status, error) {
|
||||
console.error("Error:", error);
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
$(function() {
|
||||
$('.unstuck-button').on('click', function(e) {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
$("#unstuck-response").empty();
|
||||
|
||||
var button = $(this);
|
||||
var originalText = button.html();
|
||||
var data = $("#uw-unstuck-form").serialize();
|
||||
|
||||
button.html("Desbloqueando...");
|
||||
button.prop("disabled", true);
|
||||
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: '',
|
||||
data: data,
|
||||
dataType: 'json',
|
||||
success: function(data) {
|
||||
$("#unstuck-response").html(data.message).hide().slideDown();
|
||||
|
||||
if (data.success) {
|
||||
button.html("Desbloqueado");
|
||||
setTimeout(function() {
|
||||
$("#uw-unstuck-form")[0].reset();
|
||||
button.html(originalText);
|
||||
button.prop("disabled", false);
|
||||
}, 5000);
|
||||
} else {
|
||||
button.html(originalText);
|
||||
button.prop("disabled", false);
|
||||
}
|
||||
},
|
||||
error: function() {
|
||||
$("#unstuck-response").html('<span class="red-form-response">Algo ha salido mal. Inténtelo más tarde.</span>');
|
||||
button.html(originalText);
|
||||
button.prop("disabled", false);
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user