Skip to content

Commit c696aca

Browse files
committed
test version: holding username and password in global state
1 parent 8a70eb5 commit c696aca

File tree

3 files changed

+33
-11
lines changed

3 files changed

+33
-11
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@
145145
"react-dom": "^16.4.1",
146146
"react-draggable": "^3.0.5",
147147
"react-konva": "^16.12.0-0",
148-
"react-redux": "^5.0.7",
148+
"react-redux": "^7.2.0",
149149
"react-simple-code-editor": "^0.11.0",
150150
"react-sortable-tree": "^2.2.0",
151151
"react-syntax-highlighter": "^10.2.1",

src/components/login/SignIn.tsx

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
1-
import React from 'react';
1+
import React, { Component } from 'react';
2+
import { connect } from 'react';
3+
import { LoginInt } from '../../interfaces/Interfaces';
4+
import { setUsername, setPassword } from '../../actions/actionCreators';
5+
import { useSelector } from 'react-redux';
6+
27
import Avatar from '@material-ui/core/Avatar';
38
import Button from '@material-ui/core/Button';
49
import CssBaseline from '@material-ui/core/CssBaseline';
@@ -10,15 +15,31 @@ import Grid from '@material-ui/core/Grid';
1015
import Box from '@material-ui/core/Box';
1116
import LockOutlinedIcon from '@material-ui/icons/LockOutlined';
1217
import Typography from '@material-ui/core/Typography';
13-
import { makeStyles } from '@material-ui/core/styles';
18+
import { makeStyles, withStyles } from '@material-ui/core/styles';
1419
import Container from '@material-ui/core/Container';
20+
import { render } from 'enzyme';
21+
22+
const mapStateToProps = (store: any) => ({
23+
username: store.credentials.username,
24+
password: store.credentials.password
25+
})
26+
27+
const mapDispatchToProps = (dispatch: any) => ({
28+
setUsername: (username: string) => dispatch(setUsername(username)),
29+
setPassword: (password: string) => dispatch(setPassword(password))
30+
})
31+
32+
interface LoginProps extends LoginInt {
33+
setUsername(username: string): void,
34+
setPassword(username: string): void
35+
}
1536

1637
function Copyright() {
1738
return (
1839
<Typography variant="body2" color="textSecondary" align="center">
1940
{'Copyright © '}
2041
<Link color="inherit" href="https://material-ui.com/">
21-
Your Website
42+
ReacType
2243
</Link>{' '}
2344
{new Date().getFullYear()}
2445
{'.'}
@@ -46,8 +67,9 @@ const useStyles = makeStyles((theme) => ({
4667
},
4768
}));
4869

49-
export default function SignIn() {
70+
const SignIn: React.FC<LoginProps> = (props) => {
5071
const classes = useStyles();
72+
const count = useSelector(state => state);
5173

5274
return (
5375
<Container component="main" maxWidth="xs">
@@ -114,4 +136,6 @@ export default function SignIn() {
114136
</Box>
115137
</Container>
116138
);
117-
}
139+
}
140+
141+
export default SignIn;

src/index.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,16 @@ import store from './store';
77

88
import SignIn from './components/login/SignIn.tsx';
99

10-
10+
/*
1111
ReactDOM.render(
1212
<Provider store={store}>
1313
<App />
1414
</Provider>,
1515
document.getElementById('app'),
1616
);
17+
*/
1718

18-
19-
/*
2019
ReactDOM.render(
21-
<SignIn/>,
20+
<Provider store={store}><SignIn/></Provider>,
2221
document.getElementById('app'),
2322
);
24-
*/

0 commit comments

Comments
 (0)