update : fixing looping scan

main
marszayn 2025-08-05 13:57:00 +07:00
parent 9962a58df0
commit 15023967a1
1 changed files with 14 additions and 5 deletions

View File

@ -97,7 +97,6 @@
type="file" type="file"
id="file-upload" id="file-upload"
accept="image/*" accept="image/*"
capture="environment"
class="hidden" class="hidden"
/> />
<p class="text-xs text-gray-500 mt-2 text-center"> <p class="text-xs text-gray-500 mt-2 text-center">
@ -150,7 +149,8 @@
<i class="w-5 h-5 text-green-600 mr-2" data-lucide="check-circle"></i> <i class="w-5 h-5 text-green-600 mr-2" data-lucide="check-circle"></i>
<span class="text-green-800 font-medium">Data struk berhasil diisi otomatis!</span> <span class="text-green-800 font-medium">Data struk berhasil diisi otomatis!</span>
</div> </div>
<p class="text-green-700 text-sm mt-1">Periksa form di bawah dan lengkapi data jika diperlukan.</p> <p class="text-green-700 text-sm mt-1">Scanning dihentikan. Periksa form di bawah dan lengkapi data jika diperlukan.</p>
<p class="text-green-700 text-xs mt-1">💡 Untuk scan ulang, klik "Mulai Scan Struk" atau "Upload Foto Struk"</p>
</div> </div>
@ -1019,13 +1019,22 @@
// Show success message // Show success message
this.showScanSuccess(); this.showScanSuccess();
// Auto-stop scanning after successful detection
console.log('Auto-stopping scanner after successful data detection');
setTimeout(() => {
if (this.isScanning) {
console.log('Scanner stopped automatically. User can click "Mulai Scan Struk" to scan again.');
this.stopScanner();
}
}, 1000);
// Scroll to form to show filled data // Scroll to form to show filled data
setTimeout(() => { setTimeout(() => {
const formSection = document.querySelector('form'); const formSection = document.querySelector('form');
if (formSection) { if (formSection) {
formSection.scrollIntoView({ behavior: 'smooth', block: 'start' }); formSection.scrollIntoView({ behavior: 'smooth', block: 'start' });
} }
}, 500); }, 1500);
} else { } else {
console.log('No significant data found in OCR text'); console.log('No significant data found in OCR text');
} }
@ -1477,10 +1486,10 @@
showScanSuccess() { showScanSuccess() {
this.scanSuccess.classList.remove('hidden'); this.scanSuccess.classList.remove('hidden');
// Auto-hide after 3 seconds // Auto-hide after 5 seconds (longer to let user read the instructions)
setTimeout(() => { setTimeout(() => {
this.scanSuccess.classList.add('hidden'); this.scanSuccess.classList.add('hidden');
}, 3000); }, 5000);
} }
showError(message) { showError(message) {