Revert "Perbaikan API WA" dan "Perbaikan Generate Token Baru"
Mengembalikan fitur verifikasi presensi via WhatsApp ke kondisi semula sebelum perubahan mekanisme regenerasi token sesi. This reverts commit1d58c66a7a. This reverts commitdcf57bcfdc. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
@@ -124,9 +124,6 @@
|
||||
<div class="text-center py-4">
|
||||
<i id="pesanIcon" class="fas fa-info-circle fa-3x text-secondary mb-3"></i>
|
||||
<p id="pesanText" class="mb-0"></p>
|
||||
<button type="button" class="btn btn-primary mt-3 d-none" id="btnMintaTokenBaru">
|
||||
<i class="fas fa-rotate-right"></i> Minta Token Baru
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -213,7 +210,7 @@
|
||||
|
||||
<script>
|
||||
const pengajuanId = {{ (int) $id }};
|
||||
let token = new URLSearchParams(window.location.search).get('token');
|
||||
const token = new URLSearchParams(window.location.search).get('token');
|
||||
const apiBase = "{{ url('/api/v1/verifikasi-absen') }}/" + pengajuanId;
|
||||
|
||||
function showNotification(status, title, text) {
|
||||
@@ -232,16 +229,13 @@
|
||||
});
|
||||
}
|
||||
|
||||
function ambilDataError(xhr) {
|
||||
try {
|
||||
return JSON.parse(xhr.responseText);
|
||||
} catch (e) {
|
||||
return {};
|
||||
}
|
||||
}
|
||||
|
||||
function ambilPesanError(xhr) {
|
||||
return ambilDataError(xhr).message || 'Terjadi kesalahan. Silakan coba lagi.';
|
||||
try {
|
||||
const data = JSON.parse(xhr.responseText);
|
||||
return data.message || 'Terjadi kesalahan. Silakan coba lagi.';
|
||||
} catch (e) {
|
||||
return 'Terjadi kesalahan. Silakan coba lagi.';
|
||||
}
|
||||
}
|
||||
|
||||
const statusBadgeMap = {
|
||||
@@ -250,12 +244,11 @@
|
||||
'Ditolak': ['bg-danger', 'Ditolak'],
|
||||
};
|
||||
|
||||
function tampilkanPesan(icon, text, colorClass, bisaMintaTokenBaru = false) {
|
||||
function tampilkanPesan(icon, text, colorClass) {
|
||||
$('#pesanState').removeClass('d-none');
|
||||
$('#detailState').addClass('d-none');
|
||||
$('#pesanIcon').attr('class', `fas ${icon} fa-3x mb-3 ${colorClass}`);
|
||||
$('#pesanText').text(text);
|
||||
$('#btnMintaTokenBaru').toggleClass('d-none', !bisaMintaTokenBaru);
|
||||
}
|
||||
|
||||
function tampilkanDetail(data, state) {
|
||||
@@ -299,41 +292,13 @@
|
||||
selesaiLoading();
|
||||
},
|
||||
error: function (xhr) {
|
||||
const data = ambilDataError(xhr);
|
||||
tampilkanPesan('fa-exclamation-triangle', data.message || 'Terjadi kesalahan. Silakan coba lagi.', 'text-danger', data.state === 'session_expired');
|
||||
const pesan = ambilPesanError(xhr);
|
||||
tampilkanPesan('fa-exclamation-triangle', pesan, 'text-danger');
|
||||
selesaiLoading();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
$('#btnMintaTokenBaru').on('click', function () {
|
||||
const $btn = $(this);
|
||||
const originalText = $btn.html();
|
||||
$btn.prop('disabled', true).text('Memproses...');
|
||||
|
||||
$.ajax({
|
||||
url: `${apiBase}/perbarui-token?token=${encodeURIComponent(token)}`,
|
||||
method: 'POST',
|
||||
data: { token },
|
||||
success: function (res) {
|
||||
token = res.new_token;
|
||||
const url = new URL(window.location.href);
|
||||
url.searchParams.set('token', token);
|
||||
window.history.replaceState({}, '', url);
|
||||
|
||||
$('#loadingState').removeClass('d-none');
|
||||
$('#mainCard').addClass('d-none');
|
||||
muatData();
|
||||
},
|
||||
error: function (xhr) {
|
||||
showNotification('error', 'Gagal', ambilPesanError(xhr));
|
||||
},
|
||||
complete: function () {
|
||||
$btn.prop('disabled', false).html(originalText);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
function selesaiLoading() {
|
||||
$('#loadingState').addClass('d-none');
|
||||
$('#mainCard').removeClass('d-none');
|
||||
|
||||
Reference in New Issue
Block a user