qr
This commit is contained in:
@@ -5,6 +5,7 @@ import dynamic from 'next/dynamic';
|
||||
import { Scanner } from '@yudiel/react-qr-scanner';
|
||||
import Button from '@/components/button';
|
||||
import axiosInstance from '@/utils/api-config';
|
||||
import toast from 'react-hot-toast';
|
||||
|
||||
const Modal = dynamic(() => import('@/components/modal'), { ssr: false });
|
||||
|
||||
@@ -21,6 +22,7 @@ export default function Page() {
|
||||
const [participante, setParticipante] = useState('');
|
||||
|
||||
const handleScan = async (rawValue: string) => {
|
||||
console.log('QR Escaneado:', rawValue);
|
||||
if (!enableScan) return;
|
||||
|
||||
try {
|
||||
@@ -31,7 +33,13 @@ export default function Page() {
|
||||
`/participante-evento/${data.id_participante}/${data.id_evento}`
|
||||
);
|
||||
|
||||
console.log(response.data);
|
||||
setParticipante(response.data.participante.correo);
|
||||
setScannedData({
|
||||
id_participante: data.id_participante,
|
||||
id_evento: data.id_evento,
|
||||
});
|
||||
setShowModal(true);
|
||||
setEnableScan(false);
|
||||
} catch (err) {
|
||||
console.warn('Participante no registrado en el evento:', err);
|
||||
setStatusMessage(
|
||||
@@ -56,6 +64,7 @@ export default function Page() {
|
||||
);
|
||||
|
||||
console.log('Asistencia registrada:', response.data);
|
||||
toast.success('✅ Asistencia registrada correctamente');
|
||||
} catch (err) {
|
||||
console.error('Error en la petición:', err);
|
||||
setStatusMessage('❌ Error de red al registrar asistencia');
|
||||
@@ -120,10 +129,7 @@ export default function Page() {
|
||||
{scannedData ? (
|
||||
<>
|
||||
<p>
|
||||
<strong>ID Participante:</strong> {scannedData.id_participante}
|
||||
</p>
|
||||
<p>
|
||||
<strong>ID Evento:</strong> {scannedData.id_evento}
|
||||
<strong>Participante:</strong> {participante}
|
||||
</p>
|
||||
<Button variant="success" onClick={handleConfirm}>
|
||||
Confirmar lectura
|
||||
|
||||
Reference in New Issue
Block a user