diff --git a/resources/views/operasi/edit_marginmutu.blade.php b/resources/views/operasi/edit_marginmutu.blade.php
index c9508ee..2af31e0 100644
--- a/resources/views/operasi/edit_marginmutu.blade.php
+++ b/resources/views/operasi/edit_marginmutu.blade.php
@@ -43,7 +43,7 @@
-
+
@@ -97,7 +97,7 @@ $(document).ready(function() {
});
} else {
Swal.fire({
- title: 'Error!',
+ title: 'Ralat!',
text: response.message,
icon: 'error',
confirmButtonText: 'OK'
@@ -105,9 +105,31 @@ $(document).ready(function() {
}
},
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({
- title: 'Error!',
- text: 'Error updating data: ' + xhr.responseText,
+ title: 'Ralat!',
+ text: errorMessage,
icon: 'error',
confirmButtonText: 'OK'
});