update data pembading surveyor

This commit is contained in:
majid
2024-12-03 15:00:18 +07:00
parent 9502329fef
commit 280ed97a50
15 changed files with 1185 additions and 1034 deletions

View File

@@ -37,12 +37,20 @@
<span id="saveButtonText">Save</span>
<div class="spinner-border spinner-border-sm text-light" role="status" style="display: none;"
id="saveButtonSpinner">
<span class="visually-hidden">Loading...</span>
</div>
</button>
</div>
</form>
</div>
<!-- Loading Overlay -->
<div id="loadingOverlay" class="fixed inset-0 bg-black bg-opacity-50 hidden items-center justify-center z-50">
<div class="bg-white p-4 rounded-lg">
<div class="loader"></div>
<p class="mt-2 text-center">Sedang memproses...</p>
</div>
</div>
@endsection
@push('scripts')
<script type="text/javascript">
@@ -118,14 +126,14 @@
function submitData() {
const loadingOverlay = document.getElementById('loadingOverlay');
loadingOverlay.classList.remove('hidden');
loadingOverlay.classList.add('flex');
const formElement = $('#formInspeksi')[0];
const formData = new FormData(formElement);
// Disable the button and show the spinner
$('#saveButton').prop('disabled', true);
$('#saveButtonText').hide();
$('#saveButtonSpinner').show();
$.ajax({
url: '{{ route('surveyor.store') }}',
type: 'POST',
@@ -136,12 +144,26 @@
'X-CSRF-TOKEN': '{{ csrf_token() }}'
},
success: function(response) {
// if (response.success) {
// toastrSuccessBuild(response.message)
// window.location.href =
// '{{ route('surveyor.show', ['id' => $permohonan->id]) }}?form=inspeksi';
// }
if (response.success) {
Swal.fire({
title: 'Berhasil!',
text: response.message,
icon: 'success',
confirmButtonText: 'OK'
}).then((response) => {
if (response.isConfirmed) {
window.location.href =
'{{ route('surveyor.show', ['id' => $permohonan->id]) }}';
}
});
} else {
Swal.fire({
title: 'Error!',
text: response.message || 'Terjadi kesalahan',
icon: 'error',
confirmButtonText: 'OK'
});
}
console.log(response);
},
error: function(xhr, status, error) {
@@ -160,9 +182,8 @@
},
complete: function() {
// Re-enable the button and hide the spinner
$('#saveButton').prop('disabled', false);
$('#saveButtonText').show();
$('#saveButtonSpinner').hide();
loadingOverlay.classList.add('hidden');
loadingOverlay.classList.remove('flex');
}
});
}
@@ -239,10 +260,9 @@
success: function(response) {
console.log(response);
if (response.success) {
if (response.jenis_asset) {
window.location.href =
'{{ route('surveyor.show', ['id' => $permohonan->id]) }}?form=inspeksi';
}
window.location.href =
'{{ route('surveyor.show', ['id' => $permohonan->id]) }}';
toastrSuccessBuild(response.message);
}
},
@@ -260,3 +280,34 @@
}
</script>
@endpush
<style>
.loader {
border: 4px solid #f3f3f3;
border-radius: 50%;
border-top: 4px solid #3498db;
width: 40px;
height: 40px;
animation: spin 1s linear infinite;
margin: 0 auto;
}
@keyframes spin {
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(360deg);
}
}
.scrollable-x-auto {
overflow-x: auto;
max-width: 100%;
}
.table {
min-width: 100%;
}
</style>