async function scanAntrian() {
let htmlContent = `
Arahkan kamera ke QR code.
`;
await Swal.fire({
title: 'Scan No Antrian',
html: htmlContent,
showCancelButton: true,
showConfirmButton: false,
cancelButtonText: 'Batal',
didOpen: () => {
const html5QrCode = new Html5Qrcode("reader");
Swal.getPopup()._html5QrCode = html5QrCode;
html5QrCode.start(
{ facingMode: "environment" },
{ fps: 10, qrbox: { width: 180, height: 180 } },
(decodedText) => {
html5QrCode.stop().then(() => {
prosesCariAntrian(decodedText);
}).catch(() => prosesCariAntrian(decodedText));
},
() => {}
).catch(err => {
document.getElementById('reader').innerHTML = '
Gagal mengaktifkan kamera.
';
});
},
willClose: () => {
if (Swal.getPopup()._html5QrCode) {
Swal.getPopup()._html5QrCode.stop().catch(() => {});
}
}
});
}