1
+ import React , { useState } from 'react' ;
2
+ import Avatar from '@material-ui/core/Avatar' ;
3
+ import Button from '@material-ui/core/Button' ;
4
+ import CssBaseline from '@material-ui/core/CssBaseline' ;
5
+ import TextField from '@material-ui/core/TextField' ;
6
+ import Link from '@material-ui/core/Link' ;
7
+ import Box from '@material-ui/core/Box' ;
8
+ import EmailOutlinedIcon from '@material-ui/icons/EmailOutlined' ;
9
+ import Typography from '@material-ui/core/Typography' ;
10
+ import { makeStyles } from '@material-ui/core/styles' ;
11
+ import Container from '@material-ui/core/Container' ;
12
+ import { useHistory } from "react-router-dom" ;
13
+
14
+
15
+ function Copyright ( ) {
16
+ return (
17
+ < Typography variant = "body2" color = "textSecondary" align = "center" >
18
+ { 'Copyright © ' }
19
+ < Link color = "inherit" href = "https://material-ui.com/" >
20
+ Your Website
21
+ </ Link > { ' ' }
22
+ { new Date ( ) . getFullYear ( ) }
23
+ { '.' }
24
+ </ Typography >
25
+ ) ;
26
+ }
27
+
28
+ const useStyles = makeStyles ( ( theme ) => ( {
29
+ paper : {
30
+ marginTop : theme . spacing ( 8 ) ,
31
+ display : 'flex' ,
32
+ flexDirection : 'column' ,
33
+ alignItems : 'center' ,
34
+ } ,
35
+ avatar : {
36
+ margin : theme . spacing ( 1 ) ,
37
+ backgroundColor : theme . palette . secondary . main ,
38
+ } ,
39
+ form : {
40
+ width : '100%' , // Fix IE 11 issue.
41
+ marginTop : theme . spacing ( 1 ) ,
42
+ } ,
43
+ submit : {
44
+ margin : theme . spacing ( 3 , 0 , 2 ) ,
45
+ } ,
46
+ } ) ) ;
47
+
48
+ export default function SendVerifyLink ( props ) {
49
+ const { btnName, status } = props ;
50
+ const history = useHistory ( )
51
+ const classes = useStyles ( ) ;
52
+
53
+ //handle function
54
+
55
+ function sendEmail ( ) {
56
+ history . push ( {
57
+ pathname : '/verify-email-link'
58
+ } )
59
+ } ;
60
+ function verifyEmail ( ) {
61
+ history . push ( {
62
+ pathname : '/'
63
+ } )
64
+ } ;
65
+
66
+ function handleSubmit ( ) {
67
+ ( status === true ) ? sendEmail ( ) : verifyEmail ( )
68
+
69
+ }
70
+ return (
71
+ < Container component = "main" maxWidth = "xs" >
72
+ < CssBaseline />
73
+ < div className = { classes . paper } >
74
+ < Avatar className = { classes . avatar } >
75
+ < EmailOutlinedIcon />
76
+ </ Avatar >
77
+ < Typography component = "h1" variant = "h5" >
78
+ { btnName }
79
+ </ Typography >
80
+ < form className = { classes . form } onSubmit = { handleSubmit } noValidate >
81
+ < TextField
82
+ variant = "outlined"
83
+ margin = "normal"
84
+ required
85
+ fullWidth
86
+ id = "email"
87
+ label = "Email Address"
88
+ name = "email"
89
+ autoComplete = "email"
90
+ autoFocus
91
+ />
92
+ < Button
93
+ type = "submit"
94
+ fullWidth
95
+ variant = "contained"
96
+ color = "primary"
97
+ className = { classes . submit }
98
+ >
99
+ { btnName }
100
+ </ Button >
101
+ </ form >
102
+ </ div >
103
+ < Box mt = { 8 } >
104
+ < Copyright />
105
+ </ Box >
106
+ </ Container >
107
+ ) ;
108
+ }
0 commit comments