import * as React from 'react';
import { connect } from 'react-redux';
import { withRouter } from 'react-router';
import Paper from 'material-ui/Paper';
import JournalFetcher from './JournalFetcher';
import LoginForm from './LoginForm';
import LoadingIndicator from './LoadingIndicator';
import { store, StoreState, CredentialsType, fetchCredentials } from './store';
class EteSyncContext extends React.Component {
props: {
credentials: CredentialsType;
};
constructor(props: any) {
super(props);
this.onFormSubmit = this.onFormSubmit.bind(this);
}
onFormSubmit(username: string, password: string, encryptionPassword: string, serviceApiUrl: string) {
store.dispatch(fetchCredentials(username, password, encryptionPassword, serviceApiUrl));
}
render() {
if (this.props.credentials.fetching) {
return ();
} else if (this.props.credentials.value === null) {
const style = {
holder: {
margin: 'auto',
maxWidth: 400,
padding: 20,
},
};
return (
);
}
return (
);
}
}
const mapStateToProps = (state: StoreState) => {
return {
credentials: state.credentials,
};
};
export default withRouter(connect(
mapStateToProps
)(EteSyncContext));