Skip to content

Commit 26e3cde

Browse files
author
t3jasKharat
committed
authSlice updated but has errors
1 parent d980d32 commit 26e3cde

File tree

8 files changed

+228
-227
lines changed

8 files changed

+228
-227
lines changed

blocks/eda-frontend/src/components/SchematicEditor/Header.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ SimpleSnackbar.propTypes = {
103103
function Header () {
104104
const history = useHistory()
105105
const classes = useStyles()
106-
const auth = store.getState().authReducer
106+
const auth = useSelector(state => state.auth)
107107
const schSave = useSelector(state => state.saveSchematic)
108108
const [anchorEl, setAnchorEl] = useState(null)
109109

blocks/eda-frontend/src/components/SchematicEditor/Helper/ComponentDrag.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,7 @@ export default function LoadGrid (container, sidebar, outline) {
311311

312312
store.subscribe(() => {
313313
const id = store.getState().componentProperties.id
314-
const parameterValues = store.getState().componentProperties.parameter_values
314+
const parameterValues = store.getState().componentProperties.parameterValues
315315
const displayProperties = store.getState().componentProperties.displayProperties
316316
const cellList = graph.getModel().cells
317317
const c = cellList[id]

blocks/eda-frontend/src/components/SchematicEditor/Helper/ToolbarTools.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* eslint new-cap: ["error", {"newIsCapExceptionPattern": "^mx"}] */
22
import 'mxgraph/javascript/src/css/common.css'
3-
3+
import { useSelector } from 'react-redux'
44
import mxGraphFactory from 'mxgraph'
55
import { portSize, getParameter } from './SvgParser'
66
import store from '../../../redux/store'
@@ -143,7 +143,7 @@ export function PrintPreview () {
143143
header.style.lineHeight = (this.marginTop - 10) + 'px'
144144

145145
const footer = header.cloneNode(true)
146-
const title = store.getState().saveSchematicReducer.title
146+
const title = useSelector(state => state.saveSchematic.title)
147147
mxUtils.write(header, title + ' - ' + process.env.REACT_APP_NAME + ' on Cloud')
148148
header.style.borderBottom = '1px solid blue'
149149
header.style.top = '0px'

blocks/eda-frontend/src/components/Shared/Navbar.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React, { useState } from 'react'
2-
2+
import { useSelector } from 'react-redux'
33
import { AppBar, Avatar, Button, Fade, IconButton, Link, ListItemText, Menu, MenuItem, Toolbar, Typography } from '@material-ui/core'
44
import { makeStyles } from '@material-ui/core/styles'
55
import { deepPurple } from '@material-ui/core/colors'
@@ -42,7 +42,7 @@ export function Header () {
4242
const history = useHistory()
4343
const classes = useStyles()
4444
const [anchorEl, setAnchorEl] = useState(null)
45-
const auth = store.getState().authReducer
45+
const auth = useSelector(state => state.auth)
4646

4747
const handleClick = (event) => {
4848
setAnchorEl(event.currentTarget)

blocks/eda-frontend/src/pages/Login.js

+6-6
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import Visibility from '@material-ui/icons/Visibility'
2222
import VisibilityOff from '@material-ui/icons/VisibilityOff'
2323
import { Link as RouterLink } from 'react-router-dom'
2424
import { useSelector, useDispatch } from 'react-redux'
25-
import { login, authDefault, googleLogin } from '../redux/slices/authSlice'
25+
import { login, authDefault, googleLogin, githubLogin } from '../redux/slices/authSlice'
2626
import google from '../static/google.png'
2727
import github from '../static/github-mark.png'
2828

@@ -68,15 +68,15 @@ export default function SignIn (props) {
6868
}
6969
}, [dispatch, props.location.search])
7070

71-
const [username, setUsername] = useState('')
71+
const [email, setEmail] = useState('')
7272
const [password, setPassword] = useState('')
7373
const [showPassword, setShowPassword] = useState(false)
7474
const handleClickShowPassword = () => setShowPassword(!showPassword)
7575
const handleMouseDownPassword = () => setShowPassword(!showPassword)
7676

7777
// Function call for normal user login.
7878
const handleLogin = () => {
79-
dispatch(login(username, password, url))
79+
dispatch(login({ email, password, url }))
8080
}
8181

8282
// Function call for google oAuth login.
@@ -105,7 +105,7 @@ export default function SignIn (props) {
105105

106106
{/* Display's error messages while logging in */}
107107
<Typography variant='body1' align='center' style={{ marginTop: '10px' }} color='error'>
108-
{auth.errors}
108+
{auth.errors?.detail}
109109
</Typography>
110110

111111
<form className={classes.form} noValidate>
@@ -118,8 +118,8 @@ export default function SignIn (props) {
118118
label='Email'
119119
name='email'
120120
autoComplete='email'
121-
value={username}
122-
onChange={e => setUsername(e.target.value)}
121+
value={email}
122+
onChange={e => setEmail(e.target.value)}
123123
autoFocus
124124
/>
125125
<TextField

blocks/eda-frontend/src/pages/signUp.js

+8-9
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ import { makeStyles } from '@material-ui/core/styles'
1818
import LockOutlinedIcon from '@material-ui/icons/LockOutlined'
1919
import Visibility from '@material-ui/icons/Visibility'
2020
import VisibilityOff from '@material-ui/icons/VisibilityOff'
21-
import { Link as RouterLink, useHistory } from 'react-router-dom'
21+
import { Link as RouterLink } from 'react-router-dom'
2222
import { useSelector, useDispatch } from 'react-redux'
23-
import { signUp, authDefault, googleLogin } from '../redux/slices/authSlice'
23+
import { signUp, authDefault, googleLogin, githubLogin } from '../redux/slices/authSlice'
2424
import google from '../static/google.png'
2525
import github from '../static/github-mark.png'
2626

@@ -48,7 +48,8 @@ const useStyles = makeStyles((theme) => ({
4848
export default function SignUp () {
4949
const classes = useStyles()
5050

51-
const auth = useSelector(state => state.auth)
51+
const isRegistered = useSelector(state => state.auth.isRegistered)
52+
const regErrors = useSelector(state => state.auth.regErrors)
5253

5354
const dispatch = useDispatch()
5455
const homeURL = `${window.location.protocol}\\\\${window.location.host}/`
@@ -58,8 +59,6 @@ export default function SignUp () {
5859
document.title = 'Sign Up - ' + process.env.REACT_APP_NAME
5960
}, [dispatch])
6061

61-
const history = useHistory()
62-
6362
const [email, setEmail] = useState('')
6463
const [password, setPassword] = useState('')
6564
const [reenterPassword, setReenterPassword] = useState('')
@@ -80,7 +79,7 @@ export default function SignUp () {
8079
// Function call for github sign up.
8180
const handleGithubLogin = () => {
8281
const host = window.location.origin
83-
const toUrl = '' // Add any redirect URL logic if needed
82+
const toUrl = ''
8483
dispatch(githubLogin(host, toUrl))
8584
}
8685

@@ -96,8 +95,8 @@ export default function SignUp () {
9695
</Typography>
9796

9897
{/* Display's error messages while signing in */}
99-
<Typography variant='body1' align='center' style={{ marginTop: '10px' }} color={auth.isRegistered ? 'secondary' : 'error'}>
100-
{auth.regErrors}
98+
<Typography variant='body1' align='center' style={{ marginTop: '10px' }} color={isRegistered ? 'secondary' : 'error'}>
99+
{regErrors}
101100
</Typography>
102101

103102
<form className={classes.form} noValidate>
@@ -177,7 +176,7 @@ export default function SignUp () {
177176
fullWidth
178177
variant='contained'
179178
color='primary'
180-
onClick={() => dispatch(signUp(email, password, reenterPassword, history))}
179+
onClick={() => dispatch(signUp({ email, password, reenterPassword }))}
181180
className={classes.submit}
182181
disabled={!accept}
183182
>

0 commit comments

Comments
 (0)