Block Margin Mutu for operasi edit.
2. popup error for each error logs
This commit is contained in:
@@ -43,7 +43,7 @@
|
|||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="operasi">Operasi (%)</label>
|
<label for="operasi">Operasi (%)</label>
|
||||||
<input type="number" step="0.01" class="form-control" id="operasi" name="operasi" required>
|
<input readonly type="number" step="0.01" class="form-control" id="operasi" name="operasi" required>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="text-center">
|
<div class="text-center">
|
||||||
@@ -97,7 +97,7 @@ $(document).ready(function() {
|
|||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
Swal.fire({
|
Swal.fire({
|
||||||
title: 'Error!',
|
title: 'Ralat!',
|
||||||
text: response.message,
|
text: response.message,
|
||||||
icon: 'error',
|
icon: 'error',
|
||||||
confirmButtonText: 'OK'
|
confirmButtonText: 'OK'
|
||||||
@@ -105,9 +105,31 @@ $(document).ready(function() {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
error: function(xhr) {
|
error: function(xhr) {
|
||||||
|
let errorMessage = 'Error updating data';
|
||||||
|
|
||||||
|
try {
|
||||||
|
let response = JSON.parse(xhr.responseText);
|
||||||
|
|
||||||
|
// If validation errors exist, show them
|
||||||
|
if (response.errors) {
|
||||||
|
let errorMessages = [];
|
||||||
|
Object.keys(response.errors).forEach(function(key) {
|
||||||
|
response.errors[key].forEach(function(error) {
|
||||||
|
errorMessages.push(error);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
errorMessage = errorMessages.join('\n');
|
||||||
|
} else if (response.message) {
|
||||||
|
errorMessage = response.message;
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
// If JSON parsing fails, use the raw responseText
|
||||||
|
errorMessage = xhr.responseText || 'Unknown error occurred';
|
||||||
|
}
|
||||||
|
|
||||||
Swal.fire({
|
Swal.fire({
|
||||||
title: 'Error!',
|
title: 'Ralat!',
|
||||||
text: 'Error updating data: ' + xhr.responseText,
|
text: errorMessage,
|
||||||
icon: 'error',
|
icon: 'error',
|
||||||
confirmButtonText: 'OK'
|
confirmButtonText: 'OK'
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user