Selaa lähdekoodia

pantallas base terminadas

master
dieg 3 vuotta sitten
vanhempi
commit
7c8165fa72
5 muutettua tiedostoa jossa 107 lisäystä ja 17 poistoa
  1. 1
    1
      public/index.html
  2. 8
    0
      src/App.js
  3. 42
    15
      src/Screens/Confirmacion.js
  4. 55
    0
      src/Screens/Finalizado.js
  5. 1
    1
      src/Screens/Inicio.js

+ 1
- 1
public/index.html Näytä tiedosto

@@ -24,7 +24,7 @@
24 24
       work correctly both with client-side routing and a non-root public URL.
25 25
       Learn how to configure a non-root public URL by running `npm run build`.
26 26
     -->
27
-    <title>GOAHEAD</title>
27
+    <title>Registro escolar</title>
28 28
   </head>
29 29
   <body>
30 30
     <noscript>You need to enable JavaScript to run this app.</noscript>

+ 8
- 0
src/App.js Näytä tiedosto

@@ -6,6 +6,8 @@ import { red, teal } from '@material-ui/core/colors'
6 6
 
7 7
 import Inicio from './Screens/Inicio'
8 8
 import Formulario from './Screens/Formulario'
9
+import Finalizado from './Screens/Finalizado'
10
+import Confirmacion from './Screens/Confirmacion'
9 11
 
10 12
 function App() {
11 13
 	const history = useHistory()
@@ -48,6 +50,12 @@ function App() {
48 50
 	return (
49 51
 		<ThemeProvider theme={theme}>
50 52
 			<Switch>
53
+                <Route path='/pendiente'>
54
+                    <Confirmacion/>
55
+                </Route>
56
+                <Route path='/finalizado'>
57
+                    <Finalizado/>
58
+                </Route>
51 59
                 <Route path='/formulario'>
52 60
                     <Formulario/>
53 61
                 </Route>

+ 42
- 15
src/Screens/Confirmacion.js Näytä tiedosto

@@ -1,4 +1,4 @@
1
-import React, { useState } from 'react'
1
+import React, { useEffect, useState } from 'react'
2 2
 import {
3 3
 	Box,
4 4
 	Button,
@@ -8,7 +8,8 @@ import {
8 8
 	Typography,
9 9
 	CardHeader,
10 10
 	CardActions,
11
-	CardContent
11
+	CardContent,
12
+	TextField
12 13
 } from '@material-ui/core'
13 14
 import { useHistory } from 'react-router-dom'
14 15
 
@@ -37,25 +38,38 @@ const useStyles = makeStyles(theme => ({
37 38
 export default function Confirmacion() {
38 39
 	const classes = useStyles()
39 40
 	const [ intervalId, setIntervalId ] = useState(-1)
40
-	const [ min, seg, setRestante ] = useState({min: 0, seg:0})
41
-	const enviado = localStorage.getItem('enviado') || new Date()
41
+	const [ codigo, setCodigo ] = useState('')
42
+	const [ { min, seg }, setRestante ] = useState({ min: 0, seg: 0 })
42 43
 
43 44
 	const history = useHistory()
44 45
 
45
-	const calcularRestante = () => {
46
-		const res = enviado.getTime() - new Date().getTime()
47
-		setRestante({min: 0, seg: Math.round(res / (1000 * 60 * 60))})
46
+	const calcularRestante = limite => {
47
+		const res = limite.getTime() - new Date().getTime()
48
+		setRestante({ min: Math.floor(res / 1000 / 60), seg: Math.round((res / 1000) % 60) })
48 49
 	}
49 50
 
51
+	useEffect(
52
+		() => {
53
+			reenviar()
54
+		},
55
+		// eslint-disable-next-line react-hooks/exhaustive-deps
56
+		[]
57
+	)
58
+
59
+	if (seg <= 0 && min <= 0) clearInterval(intervalId)
60
+
50 61
 	const validar = () => {
51
-		history.push('/finalizado')
62
+        if (codigo) history.push('/finalizado')
52 63
 	}
53 64
 
54 65
 	const reenviar = () => {
55
-        setIntervalId(setInterval(calcularRestante, 1000))
56
-    }
57
-
58
-    if (seg < 0 && min <0) clearInterval(intervalId)
66
+		clearInterval(intervalId)
67
+		const ahora = new Date()
68
+		ahora.setMinutes(new Date().getMinutes() + 5)
69
+		console.log(ahora)
70
+		calcularRestante(ahora)
71
+		setIntervalId(setInterval(() => calcularRestante(ahora), 1000))
72
+	}
59 73
 
60 74
 	return (
61 75
 		<Box className={classes.root}>
@@ -73,13 +87,26 @@ export default function Confirmacion() {
73 87
 					<Typography paragraph variant='h6'>
74 88
 						Para finalizar con el registro, ingrese el codigo que recibió en su casilla de correo
75 89
 					</Typography>
90
+					<TextField
91
+						name='codigo'
92
+						value={codigo}
93
+						onChange={({ target: { value } }) => setCodigo(value)}
94
+                        variant='outlined'
95
+                        fullWidth
96
+                        label='Codigo de confirmacion'
97
+                        margin='normal'
98
+					/>
76 99
 				</CardContent>
77 100
 				<Divider />
78 101
 				<CardActions className={classes.actions}>
79
-					<Button variant='contained' color='primary' onClick={reenviar} disabled={true}>
80
-						Reenviar ({min}:{seg})
102
+					<Button variant='contained' color='primary' onClick={reenviar} disabled={seg > 0 || min > 0}>
103
+						{seg > 0 || min > 0 ? (
104
+							`Reenviar (${min < 10 ? '0' : ''}${min}:${seg < 10 ? '0' : ''}${seg})`
105
+						) : (
106
+							'Reenviar'
107
+						)}
81 108
 					</Button>
82
-					<Button variant='contained' color='primary' onClick={validar}>
109
+					<Button variant='contained' color='primary' onClick={validar} disabled={!codigo}>
83 110
 						Validar
84 111
 					</Button>
85 112
 				</CardActions>

+ 55
- 0
src/Screens/Finalizado.js Näytä tiedosto

@@ -0,0 +1,55 @@
1
+import React from 'react'
2
+import {
3
+	Box,
4
+	Divider,
5
+	makeStyles,
6
+	Card,
7
+	Typography,
8
+	CardHeader,
9
+    CardContent
10
+} from '@material-ui/core'
11
+
12
+const useStyles = makeStyles(theme => ({
13
+	root: {
14
+		display: 'flex',
15
+		flexDirection: 'column',
16
+		alignItems: 'center',
17
+		justifyContent: 'center',
18
+		height: '100vh',
19
+		backgroundColor: theme.palette.background.default
20
+	},
21
+	card: {
22
+		display: 'flex',
23
+		flexDirection: 'column',
24
+		alignItems: 'center',
25
+		justifyContent: 'center',
26
+        padding: '0px 30px',
27
+        minHeight: '20vh'
28
+    },
29
+    actions: {
30
+        justifyContent: 'center'
31
+    }
32
+}))
33
+
34
+export default function Finalizado() {
35
+	const classes = useStyles()
36
+
37
+	return (
38
+		<Box className={classes.root}>
39
+			<Card>
40
+				<CardHeader
41
+					disableTypography
42
+					title={
43
+						<Typography variant='h5' align='center'>
44
+							Finalizado
45
+						</Typography>
46
+					}
47
+				/>
48
+				<Divider />
49
+				<CardContent>
50
+					<Typography variant='h6'>Registro completado exitosamente</Typography>
51
+				</CardContent>
52
+			</Card>
53
+		</Box>
54
+	)
55
+}

+ 1
- 1
src/Screens/Inicio.js Näytä tiedosto

@@ -65,4 +65,4 @@ export default function Inicio() {
65 65
 			</Card>
66 66
 		</Box>
67 67
 	)
68
-}
68
+}

Loading…
Peruuta
Tallenna