From 0bd6809aa1aab0ca2e81aac85474aa3d2f45ef6d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gabriela=20G=C3=B3mez=20Hern=C3=A1ndez?= Date: Fri, 29 Apr 2022 18:08:41 -0500 Subject: [PATCH] =?UTF-8?q?Alerta=20c=C3=B3digo=20QR?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/operador/qr.js | 21 +++- components/profesores_registro/invitado.js | 83 +++++++++++++-- components/profesores_registro/profesores.js | 12 ++- components/profesores_registro/useInvitado.js | 29 +++++ package-lock.json | 100 +++++++++++++++++- package.json | 5 +- pages/admin.js | 7 +- pages/operador.js | 2 +- styles/admin.module.css | 15 ++- styles/default.module.css | 2 +- styles/exito.module.css | 4 +- styles/globals.css | 4 +- styles/invitado.module.css | 3 + styles/login.module.css | 4 +- styles/profesores.module.css | 11 +- 15 files changed, 267 insertions(+), 35 deletions(-) create mode 100644 components/profesores_registro/useInvitado.js diff --git a/components/operador/qr.js b/components/operador/qr.js index 0e8a395..8f5e25b 100644 --- a/components/operador/qr.js +++ b/components/operador/qr.js @@ -1,23 +1,40 @@ import React, { useState } from 'react'; import { QrReader } from 'react-qr-reader'; +import swal from 'sweetalert'; function Qr(props){ const [data, setData] = useState('No result'); + const alerta = () =>{ + swal({ + title: "Invitado registrado", + button: "Aceptar", + timer:10000 + }).then(() => { + window.location.reload(false); + }); + } + return ( <> { if (!!result) { setData(result?.text); + data; } - if (!!error) { console.info(error); } + }} style={{ width: '100%' }} /> + {(() => { + if(data!='No result'){ + return alerta(); + } + })()} ); -} +}; export default Qr; \ No newline at end of file diff --git a/components/profesores_registro/invitado.js b/components/profesores_registro/invitado.js index 5872d38..570ea2a 100644 --- a/components/profesores_registro/invitado.js +++ b/components/profesores_registro/invitado.js @@ -1,12 +1,47 @@ import styles from "../../styles/invitado.module.css"; -import { Container, Row, Col,InputGroup,FormControl} from "react-bootstrap"; +import { Container, Row, Col,InputGroup,FormControl,Button} from "react-bootstrap"; +import { useInvitado } from "./useInvitado"; + +const initialForm= { + nombre:"", + apellidos:"", + edad:18 +} +const validationsForm=(form) =>{ + let errors={}; + + if(!form.nombre.trim()){ + errors.nombre="El campo 'Nombre' es requerido" + } + if(!form.apellidos.trim()){ + errors.apellidos="El campo 'Apellidos' es requerido" + } + + return errors +} + + function Invitado(props){ + + const { + form, + errors, + loading, + response, + handleChange, + handleBlur, + handleSubmit} + = useInvitado (initialForm,validationsForm); + + return( +
- -

INVITADO {props.numero}

-
+ + +

INVITADO {props.numero}

+

Nombre(s):

@@ -14,12 +49,16 @@ function Invitado(props){

Edad:

- @@ -27,16 +66,26 @@ function Invitado(props){ placeholder="Apellidos" aria-label="apellidos" aria-describedby="basic-addon2" + name="apellidos" + onChange={handleChange} + onBlur={handleBlur} + value={form.apellidos} + required /> - +