enhance UX alerts
This commit is contained in:
@@ -826,8 +826,15 @@
|
|||||||
'Accept': 'application/json'
|
'Accept': 'application/json'
|
||||||
},
|
},
|
||||||
success: function(res) {
|
success: function(res) {
|
||||||
alert('Data lahan berhasil ditambahkan!');
|
Swal.fire({
|
||||||
|
icon: 'success',
|
||||||
|
title: 'Berhasil!',
|
||||||
|
text: 'Data lahan berhasil ditambahkan.',
|
||||||
|
showConfirmButton: false,
|
||||||
|
timer: 1500
|
||||||
|
}).then(() => {
|
||||||
window.location.href = "{{ route('petani.index') }}";
|
window.location.href = "{{ route('petani.index') }}";
|
||||||
|
});
|
||||||
},
|
},
|
||||||
error: function(xhr) {
|
error: function(xhr) {
|
||||||
submitBtn.prop('disabled', false).html(originalText);
|
submitBtn.prop('disabled', false).html(originalText);
|
||||||
@@ -838,15 +845,26 @@
|
|||||||
$.each(errors, function(key, val) {
|
$.each(errors, function(key, val) {
|
||||||
errorMsg += val[0] + "\n";
|
errorMsg += val[0] + "\n";
|
||||||
});
|
});
|
||||||
alert("Penyimpanan Gagal:\n\n" + errorMsg);
|
|
||||||
|
Swal.fire({
|
||||||
|
icon: 'warning',
|
||||||
|
title: 'Penyimpanan Gagal',
|
||||||
|
text: errorMsg,
|
||||||
|
confirmButtonColor: '#dc3545'
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
let errorDetail = xhr.responseJSON && xhr.responseJSON.message ? xhr.responseJSON.message : xhr.statusText;
|
let errorDetail = xhr.responseJSON && xhr.responseJSON.message ? xhr.responseJSON.message : xhr.statusText;
|
||||||
alert("Error " + xhr.status + ": " + errorDetail);
|
|
||||||
|
Swal.fire({
|
||||||
|
icon: 'error',
|
||||||
|
title: 'Terjadi Kesalahan',
|
||||||
|
text: "Error " + xhr.status + ": " + errorDetail,
|
||||||
|
confirmButtonColor: '#dc3545'
|
||||||
|
});
|
||||||
console.error(xhr.responseText);
|
console.error(xhr.responseText);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -836,8 +836,6 @@
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
// FORM VALIDATION & SUBMIT
|
|
||||||
$('#petani-lahan-tanaman').validate({
|
$('#petani-lahan-tanaman').validate({
|
||||||
rules: {
|
rules: {
|
||||||
luas_lahan: { required: true },
|
luas_lahan: { required: true },
|
||||||
@@ -894,8 +892,15 @@
|
|||||||
'Accept': 'application/json'
|
'Accept': 'application/json'
|
||||||
},
|
},
|
||||||
success: function(res) {
|
success: function(res) {
|
||||||
alert('Data lahan berhasil disimpan!');
|
Swal.fire({
|
||||||
|
icon: 'success',
|
||||||
|
title: 'Berhasil!',
|
||||||
|
text: 'Data lahan berhasil disimpan.',
|
||||||
|
showConfirmButton: false,
|
||||||
|
timer: 1500
|
||||||
|
}).then(() => {
|
||||||
window.location.href = "{{ route('petani.index') }}";
|
window.location.href = "{{ route('petani.index') }}";
|
||||||
|
});
|
||||||
},
|
},
|
||||||
error: function(xhr) {
|
error: function(xhr) {
|
||||||
submitBtn.prop('disabled', false).html(originalText);
|
submitBtn.prop('disabled', false).html(originalText);
|
||||||
@@ -906,10 +911,22 @@
|
|||||||
$.each(errors, function(key, val) {
|
$.each(errors, function(key, val) {
|
||||||
errorMsg += val[0] + "\n";
|
errorMsg += val[0] + "\n";
|
||||||
});
|
});
|
||||||
alert("Penyimpanan Gagal:\n\n" + errorMsg);
|
|
||||||
|
Swal.fire({
|
||||||
|
icon: 'warning',
|
||||||
|
title: 'Penyimpanan Gagal',
|
||||||
|
text: errorMsg,
|
||||||
|
confirmButtonColor: '#dc3545'
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
let errorDetail = xhr.responseJSON && xhr.responseJSON.message ? xhr.responseJSON.message : xhr.statusText;
|
let errorDetail = xhr.responseJSON && xhr.responseJSON.message ? xhr.responseJSON.message : xhr.statusText;
|
||||||
alert("Error " + xhr.status + ": " + errorDetail);
|
|
||||||
|
Swal.fire({
|
||||||
|
icon: 'error',
|
||||||
|
title: 'Terjadi Kesalahan',
|
||||||
|
text: "Error " + xhr.status + ": " + errorDetail,
|
||||||
|
confirmButtonColor: '#dc3545'
|
||||||
|
});
|
||||||
console.error(xhr.responseText);
|
console.error(xhr.responseText);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user