From 2d2ff0dac01221b887dafbef7cbfae821711358e Mon Sep 17 00:00:00 2001 From: Novy San87 Date: Fri, 7 Aug 2026 12:40:27 +0700 Subject: [PATCH] =?UTF-8?q?ui(premium):=20modal=20Reset=20Password=20Wali?= =?UTF-8?q?=20custom=20(Alpine)=20=E2=80=94=20header=20ikon=20gradien=20am?= =?UTF-8?q?ber,=20info=20card,=20input=20password=20+=20toggle=20show/hide?= =?UTF-8?q?,=20validasi=20inline,=20loading=20state;=20ganti=20SweetAlert?= =?UTF-8?q?=20polos?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- resources/views/parents/index.blade.php | 153 +++++++++++++++++++----- 1 file changed, 125 insertions(+), 28 deletions(-) diff --git a/resources/views/parents/index.blade.php b/resources/views/parents/index.blade.php index 9960dc9..ee51974 100644 --- a/resources/views/parents/index.blade.php +++ b/resources/views/parents/index.blade.php @@ -3,7 +3,7 @@ @section('title', 'Data Wali Murid') @section('content') -
+
{{-- Header premium --}}
@@ -275,7 +275,7 @@ title="Logout akun di semua perangkat"> Logout -
@endif
+ {{-- Modal Reset Password (premium) --}} + +
@push('scripts') @@ -351,43 +435,56 @@ function deleteWali(userId, userName) { }); } -function resetWaliPassword(userId, userName) { - Swal.fire({ - title: 'Reset Password — ' + userName, - html: '' + - '', - confirmButtonText: ' Simpan', - showCancelButton: true, - cancelButtonText: 'Batal', - preConfirm: () => { - const pwd = document.getElementById('new-password').value; - const confirm = document.getElementById('confirm-password').value; - if (!pwd || pwd.length < 6) { - Swal.showValidationMessage('Password minimal 6 karakter'); - return false; +function resetPasswordModal() { + return { + show: false, + loading: false, + id: null, + name: '', + password: '', + confirm: '', + showPwd: false, + error: '', + openReset(userId, userName) { + this.id = userId; + this.name = userName; + this.password = ''; + this.confirm = ''; + this.showPwd = false; + this.error = ''; + this.show = true; + }, + confirmReset() { + this.error = ''; + if (!this.password || this.password.length < 6) { + this.error = 'Password minimal 6 karakter.'; + return; } - if (pwd !== confirm) { - Swal.showValidationMessage('Password tidak cocok'); - return false; + if (this.password !== this.confirm) { + this.error = 'Konfirmasi password tidak cocok.'; + return; } - return pwd; - } - }).then((result) => { - if (result.isConfirmed) { - fetch('{{ url('users') }}/' + userId + '/reset-password', { + if (this.loading) return; + this.loading = true; + fetch('{{ url('users') }}/' + this.id + '/reset-password', { method: 'POST', headers: { 'Content-Type': 'application/json', 'X-CSRF-TOKEN': document.querySelector('meta[name="csrf-token"]').content, 'Accept': 'application/json', }, - body: JSON.stringify({ new_password: result.value }), - }).then(r => { + body: JSON.stringify({ new_password: this.password }), + }) + .then(r => { if (r.redirected) window.location.href = r.url; else location.reload(); + }) + .catch(() => { + this.loading = false; + this.error = 'Gagal menyimpan. Coba lagi.'; }); - } - }); + }, + }; } @endpush