Files
SCM-Manager/scm-ui/src/containers/Users.js

59 lines
949 B
JavaScript
Raw Normal View History

2018-07-02 16:05:58 +02:00
// @flow
import React from 'react';
import { connect } from 'react-redux';
2018-07-04 09:55:02 +02:00
import { fetchUsersIfNeeded } from '../modules/users';
2018-07-02 16:05:58 +02:00
import Login from '../Login';
type Props = {
2018-07-02 16:22:24 +02:00
login: boolean,
2018-07-02 16:05:58 +02:00
error: any,
2018-07-04 09:55:02 +02:00
users: any,
fetchUsersIfNeeded: () => void
2018-07-02 16:05:58 +02:00
}
class Users extends React.Component<Props> {
componentDidMount() {
2018-07-04 09:55:02 +02:00
this.props.fetchUsersIfNeeded();
2018-07-02 16:05:58 +02:00
}
render() {
2018-07-04 09:55:02 +02:00
const { login, error, users } = this.props;
2018-07-02 16:05:58 +02:00
2018-07-02 16:22:24 +02:00
if(login) {
2018-07-02 16:05:58 +02:00
return (
<div>
<h1>SCM</h1>
<Login/>
</div>
);
}
2018-07-02 16:22:24 +02:00
else if(!login){
2018-07-02 16:05:58 +02:00
return (
<div>
<h1>SCM</h1>
<h2>Users</h2>
</div>
);
}
}
}
const mapStateToProps = (state) => {
return null;
};
const mapDispatchToProps = (dispatch) => {
return {
2018-07-04 09:55:02 +02:00
fetchUsersIfNeeded: () => {
dispatch(fetchUsersIfNeeded())
2018-07-02 16:05:58 +02:00
}
}
};
export default connect(mapStateToProps, mapDispatchToProps)(Users);