1
1
import React , { useState } from 'react' ;
2
- import { LoginInt } from '../../interfaces/Interfaces' ;
3
2
import {
3
+ RouteComponentProps ,
4
4
Link as RouteLink ,
5
- withRouter ,
6
- RouteComponentProps
5
+ withRouter
7
6
} from 'react-router-dom' ;
8
- import { newUserIsCreated } from '../../helperFunctions/auth' ;
7
+ import {
8
+ SigninDark ,
9
+ SigninLight
10
+ } from '../../../../app/src/public/styles/theme' ;
11
+ import {
12
+ StyledEngineProvider ,
13
+ Theme ,
14
+ ThemeProvider
15
+ } from '@mui/material/styles' ;
16
+ import { useDispatch , useSelector } from 'react-redux' ;
17
+
18
+ import AssignmentIcon from '@mui/icons-material/Assignment' ;
9
19
import Avatar from '@mui/material/Avatar' ;
20
+ import Box from '@mui/material/Box' ;
10
21
import Button from '@mui/material/Button' ;
22
+ import Container from '@mui/material/Container' ;
11
23
import CssBaseline from '@mui/material/CssBaseline' ;
12
- import TextField from '@mui/material/TextField' ;
13
24
import Grid from '@mui/material/Grid' ;
14
- import Box from '@mui/material/Box' ;
25
+ import { LoginInt } from '../../interfaces/Interfaces' ;
26
+ import { RootState } from '../../redux/store' ;
27
+ import TextField from '@mui/material/TextField' ;
15
28
import Typography from '@mui/material/Typography' ;
16
29
import makeStyles from '@mui/styles/makeStyles' ;
17
- import Container from '@mui/material/Container' ;
18
- import AssignmentIcon from '@mui/icons-material/Assignment' ;
30
+ import { newUserIsCreated } from '../../helperFunctions/auth' ;
19
31
import { toggleDarkMode } from '../../redux/reducers/slice/darkModeSlice' ;
20
- import { useSelector , useDispatch } from 'react-redux' ;
21
- import { ThemeProvider , Theme , StyledEngineProvider } from '@mui/material/styles' ;
22
- import { SigninDark , SigninLight } from '../../../../app/src/public/styles/theme' ;
23
- import { RootState } from '../../redux/store' ;
24
32
25
33
declare module '@mui/styles/defaultTheme' {
26
34
// eslint-disable-next-line @typescript-eslint/no-empty-interface
@@ -37,7 +45,7 @@ function Copyright() {
37
45
) ;
38
46
}
39
47
40
- const useStyles = makeStyles ( theme => ( {
48
+ const useStyles = makeStyles ( ( theme ) => ( {
41
49
paper : {
42
50
display : 'flex' ,
43
51
flexDirection : 'column' ,
@@ -47,18 +55,17 @@ const useStyles = makeStyles(theme => ({
47
55
backgroundColor : '#3EC1AC'
48
56
} ,
49
57
form : {
50
- width : '100%' , // Fix IE 11 issue.
51
- } ,
52
- submit : {
58
+ width : '100%' // Fix IE 11 issue.
53
59
} ,
60
+ submit : { } ,
54
61
root : {
55
62
'& .MuiOutlinedInput-root.Mui-focused .MuiOutlinedInput-notchedOutline' : {
56
63
borderColor : '#3EC1AC'
57
64
}
58
65
}
59
66
} ) ) ;
60
67
61
- const SignUp : React . FC < LoginInt & RouteComponentProps > = props => {
68
+ const SignUp : React . FC < LoginInt & RouteComponentProps > = ( props ) => {
62
69
const classes = useStyles ( ) ;
63
70
const dispatch = useDispatch ( ) ;
64
71
const [ email , setEmail ] = useState ( '' ) ;
@@ -73,7 +80,9 @@ const SignUp: React.FC<LoginInt & RouteComponentProps> = props => {
73
80
const [ invalidUsername , setInvalidUsername ] = useState ( false ) ;
74
81
const [ invalidPassword , setInvalidPassword ] = useState ( false ) ;
75
82
const [ invalidVerifyPassword , setInvalidVerifyPassword ] = useState ( false ) ;
76
- const isDarkMode = useSelector ( ( store :RootState ) => store . darkMode . isDarkMode ) ;
83
+ const isDarkMode = useSelector (
84
+ ( store : RootState ) => store . darkMode . isDarkMode
85
+ ) ;
77
86
78
87
const handleChange = ( e : React . ChangeEvent < HTMLInputElement > ) => {
79
88
let inputVal = e . target . value ;
@@ -172,7 +181,7 @@ const SignUp: React.FC<LoginInt & RouteComponentProps> = props => {
172
181
setInvalidVerifyPassword ( false ) ;
173
182
}
174
183
175
- newUserIsCreated ( username , email , password ) . then ( userCreated => {
184
+ newUserIsCreated ( username , email , password ) . then ( ( userCreated ) => {
176
185
if ( userCreated === 'Success' ) {
177
186
props . history . push ( '/' ) ;
178
187
} else {
@@ -190,11 +199,10 @@ const SignUp: React.FC<LoginInt & RouteComponentProps> = props => {
190
199
} ) ;
191
200
} ;
192
201
193
- //NEW DARK MODE
194
- const handleDarkModeToggle = ( ) => {
195
- dispatch ( toggleDarkMode ( ) ) ;
196
-
197
- } ;
202
+ //NEW DARK MODE
203
+ const handleDarkModeToggle = ( ) => {
204
+ dispatch ( toggleDarkMode ( ) ) ;
205
+ } ;
198
206
199
207
return (
200
208
< StyledEngineProvider injectFirst >
@@ -204,20 +212,25 @@ const SignUp: React.FC<LoginInt & RouteComponentProps> = props => {
204
212
< div className = { classes . paper } >
205
213
< Button
206
214
color = "primary"
207
- style = { {
215
+ style = { {
208
216
minWidth : '113.97px' ,
209
217
top : 10 ,
210
218
right : 20 ,
211
- position : " absolute"
219
+ position : ' absolute'
212
220
} }
213
221
onClick = { handleDarkModeToggle }
214
222
>
215
223
{ `Dark Mode: ${ isDarkMode } ` }
216
224
</ Button >
217
- < Avatar className = { classes . avatar } sx = { { marginTop : '10vh' } } >
225
+ < Avatar className = { classes . avatar } sx = { { marginTop : '10vh' } } >
218
226
< AssignmentIcon />
219
227
</ Avatar >
220
- < Typography component = "h1" variant = "h5" color = "textPrimary" sx = { { marginBottom : '10px' } } >
228
+ < Typography
229
+ component = "h1"
230
+ variant = "h5"
231
+ color = "textPrimary"
232
+ sx = { { marginBottom : '10px' } }
233
+ >
221
234
Sign up
222
235
</ Typography >
223
236
< form className = { classes . form } noValidate >
@@ -296,21 +309,33 @@ const SignUp: React.FC<LoginInt & RouteComponentProps> = props => {
296
309
variant = "contained"
297
310
color = "primary"
298
311
className = { classes . submit }
299
- onClick = { e => handleSignUp ( e ) }
312
+ onClick = { ( e ) => handleSignUp ( e ) }
300
313
sx = { {
301
314
marginTop : '15px' ,
302
315
marginBottom : '5px'
303
316
} }
304
317
>
305
318
Sign Up
306
- < svg xmlns = "http://www.w3.org/2000/svg" width = "16" height = "16" fill = "currentColor" class = "bi bi-person-add" viewBox = "0 0 16 16" style = { { marginLeft : '5px' } } >
307
- < path d = "M12.5 16a3.5 3.5 0 1 0 0-7 3.5 3.5 0 0 0 0 7Zm.5-5v1h1a.5.5 0 0 1 0 1h-1v1a.5.5 0 0 1-1 0v-1h-1a.5.5 0 0 1 0-1h1v-1a.5.5 0 0 1 1 0Zm-2-6a3 3 0 1 1-6 0 3 3 0 0 1 6 0ZM8 7a2 2 0 1 0 0-4 2 2 0 0 0 0 4Z" />
308
- < path d = "M8.256 14a4.474 4.474 0 0 1-.229-1.004H3c.001-.246.154-.986.832-1.664C4.484 10.68 5.711 10 8 10c.26 0 .507.009.74.025.226-.341.496-.65.804-.918C9.077 9.038 8.564 9 8 9c-5 0-6 3-6 4s1 1 1 1h5.256Z" />
319
+ < svg
320
+ xmlns = "http://www.w3.org/2000/svg"
321
+ width = "16"
322
+ height = "16"
323
+ fill = "currentColor"
324
+ className = "bi bi-person-add"
325
+ viewBox = "0 0 16 16"
326
+ style = { { marginLeft : '5px' } }
327
+ >
328
+ < path d = "M12.5 16a3.5 3.5 0 1 0 0-7 3.5 3.5 0 0 0 0 7Zm.5-5v1h1a.5.5 0 0 1 0 1h-1v1a.5.5 0 0 1-1 0v-1h-1a.5.5 0 0 1 0-1h1v-1a.5.5 0 0 1 1 0Zm-2-6a3 3 0 1 1-6 0 3 3 0 0 1 6 0ZM8 7a2 2 0 1 0 0-4 2 2 0 0 0 0 4Z" />
329
+ < path d = "M8.256 14a4.474 4.474 0 0 1-.229-1.004H3c.001-.246.154-.986.832-1.664C4.484 10.68 5.711 10 8 10c.26 0 .507.009.74.025.226-.341.496-.65.804-.918C9.077 9.038 8.564 9 8 9c-5 0-6 3-6 4s1 1 1 1h5.256Z" />
309
330
</ svg >
310
331
</ Button >
311
332
< Grid container justifyContent = "flex-end" >
312
333
< Grid item >
313
- < RouteLink style = { { color : isDarkMode ? '#aaaaaa' : 'black' } } to = { `/login` } className = "nav_link" >
334
+ < RouteLink
335
+ style = { { color : isDarkMode ? '#aaaaaa' : 'black' } }
336
+ to = { `/login` }
337
+ className = "nav_link"
338
+ >
314
339
Already have an account? Sign In
315
340
</ RouteLink >
316
341
</ Grid >
@@ -326,4 +351,4 @@ const SignUp: React.FC<LoginInt & RouteComponentProps> = props => {
326
351
) ;
327
352
} ;
328
353
329
- export default withRouter ( SignUp ) ;
354
+ export default withRouter ( SignUp ) ;
0 commit comments