update daftar pengguna
This commit is contained in:
@@ -85,9 +85,9 @@
|
||||
<div class="card">
|
||||
<div class="card-header border-bottom d-flex justify-content-between align-items-center">
|
||||
<h5 class="card-title mb-0">Daftar Pengguna</h5>
|
||||
<button class="btn btn-sm btn-primary" type="button" data-bs-toggle="offcanvas" data-bs-target="#offcanvasAddUser">
|
||||
<i class="ti tabler-plus me-1"></i> Add New User
|
||||
</button>
|
||||
<a class="btn btn-sm btn-primary" href="{{ route('users.create') }}">
|
||||
<i class="ti tabler-plus me-1"></i> Tambah User Baru
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<form method="GET" action="{{ route('users.index') }}" id="filterForm">
|
||||
@@ -204,7 +204,6 @@
|
||||
{{ $users->appends(request()->query())->links('pagination::bootstrap-5') }}
|
||||
</div>
|
||||
</div>
|
||||
@include('konfigurasi.user.add')
|
||||
@include('konfigurasi.user.edit')
|
||||
</div>
|
||||
@endsection
|
||||
@@ -369,77 +368,5 @@
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
document.addEventListener("DOMContentLoaded", function() {
|
||||
|
||||
function togglePassword(element) {
|
||||
const input = element.parentElement.querySelector('input');
|
||||
const icon = element.querySelector('i');
|
||||
if (input.type === 'password') {
|
||||
input.type = 'text';
|
||||
icon.className = 'ti ti-eye tabler-eye';
|
||||
} else {
|
||||
input.type = 'password';
|
||||
icon.className = 'ti ti-eye-off tabler-eye-off';
|
||||
}
|
||||
}
|
||||
|
||||
const formAddUser = document.getElementById('formAddUser');
|
||||
const offcanvasElement = document.getElementById('offcanvasAddUser');
|
||||
|
||||
if (formAddUser && offcanvasElement) {
|
||||
|
||||
formAddUser.addEventListener('submit', function(e) {
|
||||
e.preventDefault();
|
||||
|
||||
let formData = new FormData(this);
|
||||
let submitBtn = this.querySelector('button[type="submit"]');
|
||||
|
||||
submitBtn.disabled = true;
|
||||
let originalText = submitBtn.innerHTML;
|
||||
submitBtn.innerHTML = 'Menyimpan...';
|
||||
|
||||
fetch(this.action, {
|
||||
method: 'POST',
|
||||
body: formData,
|
||||
headers: {
|
||||
'X-Requested-With': 'XMLHttpRequest',
|
||||
'Accept': 'application/json'
|
||||
}
|
||||
})
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
submitBtn.disabled = false;
|
||||
submitBtn.innerHTML = originalText;
|
||||
|
||||
if (data.status === 'success') {
|
||||
let bsOffcanvas = bootstrap.Offcanvas.getInstance(offcanvasElement) || new bootstrap.Offcanvas(offcanvasElement);
|
||||
bsOffcanvas.hide();
|
||||
|
||||
Swal.fire({
|
||||
icon: 'success',
|
||||
title: 'Berhasil!',
|
||||
text: data.message,
|
||||
showConfirmButton: false,
|
||||
timer: 1500
|
||||
}).then(() => {
|
||||
window.location.reload();
|
||||
});
|
||||
} else {
|
||||
let errorMsg = data.message || 'Terjadi kesalahan.';
|
||||
if (data.errors) {
|
||||
errorMsg = Object.values(data.errors).map(err => err.join(', ')).join('<br>');
|
||||
}
|
||||
Swal.fire({ icon: 'error', title: 'Gagal!', html: errorMsg });
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
submitBtn.disabled = false;
|
||||
submitBtn.innerHTML = originalText;
|
||||
Swal.fire({ icon: 'error', title: 'Error', text: 'Koneksi bermasalah atau terjadi kesalahan server.' });
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
</script>
|
||||
@endpush
|
||||
@endpush
|
||||
|
||||
Reference in New Issue
Block a user