diff --git a/Views/Admin/Transport/SpjAdmin/Scan/Index.cshtml b/Views/Admin/Transport/SpjAdmin/Scan/Index.cshtml index 846c16b..90db7b3 100644 --- a/Views/Admin/Transport/SpjAdmin/Scan/Index.cshtml +++ b/Views/Admin/Transport/SpjAdmin/Scan/Index.cshtml @@ -680,19 +680,19 @@ const resp = await this.postGuid(guid); console.debug('process response', resp); - if (resp && resp.success) { - const now = new Date(); - const tanggal = now.toLocaleDateString('id-ID', { weekday: 'long', year: 'numeric', month: 'long', day: 'numeric' }); - const waktu = now.toLocaleTimeString('id-ID', { hour: '2-digit', minute: '2-digit' }); - this.showSuccessModal(this.originalSpjCode, tanggal, waktu); - } else { - const errorMessage = (resp && resp.message) ? resp.message : 'Kode SPJ tidak ditemukan dalam database.'; - if (errorMessage.toLowerCase().includes('sudah pernah di scan')) { - this.showAlreadyScannedModal(this.originalSpjCode); - } else { - this.showModal('error', 'SPJ Tidak Ditemukan', errorMessage, true); - } - } + if (resp.data.status === "valid") { + console.log(); + const now = new Date(); + const tanggal = now.toLocaleDateString('id-ID', { weekday: 'long', year: 'numeric', month: 'long', day: 'numeric' }); + const waktu = now.toLocaleTimeString('id-ID', { hour: '2-digit', minute: '2-digit' }); + this.showSuccessModal(trimmed, tanggal, waktu); + } + else if (resp.data.status === "exits") { + this.showModal('error', 'SPJ sudah di Scan', (resp && resp.message) ? resp.message : 'Kode SPJ sudah digunakan.', true); + }else + { + this.showModal('error', 'SPJ Tidak Ditemukan', (resp && resp.message) ? resp.message : 'Kode SPJ tidak ditemukan dalam database.', true); + } } catch (xhrOrErr) { let message = ''; if (xhrOrErr && xhrOrErr.responseJSON) {