import * as React from 'react'; import { connect } from 'react-redux'; import { Switch, Route, Redirect, withRouter } from 'react-router'; import Paper from 'material-ui/Paper'; import JournalList from './JournalList'; import JournalView from './JournalView'; import JournalFetcher from './JournalFetcher'; import LoginForm from './LoginForm'; import { routeResolver } from './App'; import { store, StoreState, CredentialsType, CredentialsData, 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 (
Loading
); } else if (this.props.credentials.value === null) { const styles = { paper: { margin: 'auto', maxWidth: 400, padding: 20, }, }; return ( ); } let context = this.props.credentials.value as CredentialsData; return ( } /> } /> } /> ); } } const mapStateToProps = (state: StoreState) => { return { credentials: state.credentials, }; }; export default withRouter(connect( mapStateToProps )(EteSyncContext));