LoginGate: move to be a function component.

master
Tom Hacohen 5 years ago
parent 5f78657e51
commit 5301b546df

@ -81,24 +81,18 @@ function EncryptionPart(props: { credentials: CredentialsType }) {
); );
} }
interface PropsType {
class LoginGate extends React.Component {
public props: {
credentials: CredentialsType; credentials: CredentialsType;
}; }
constructor(props: any) { export default function LoginGate(props: PropsType) {
super(props);
this.onFormSubmit = this.onFormSubmit.bind(this);
}
public onFormSubmit(username: string, password: string, serviceApiUrl?: string) { function onFormSubmit(username: string, password: string, serviceApiUrl?: string) {
serviceApiUrl = serviceApiUrl ? serviceApiUrl : C.serviceApiBase; serviceApiUrl = serviceApiUrl ? serviceApiUrl : C.serviceApiBase;
store.dispatch<any>(fetchCredentials(username, password, serviceApiUrl)); store.dispatch<any>(fetchCredentials(username, password, serviceApiUrl));
} }
public render() { if (props.credentials.value === null) {
if (this.props.credentials.value === null) {
const style = { const style = {
isSafe: { isSafe: {
textDecoration: 'none', textDecoration: 'none',
@ -114,9 +108,9 @@ class LoginGate extends React.Component {
<Container style={{ maxWidth: '30rem' }}> <Container style={{ maxWidth: '30rem' }}>
<h2>Please Log In</h2> <h2>Please Log In</h2>
<LoginForm <LoginForm
onSubmit={this.onFormSubmit} onSubmit={onFormSubmit}
error={this.props.credentials.error} error={props.credentials.error}
loading={this.props.credentials.fetching} loading={props.credentials.fetching}
/> />
<hr style={style.divider} /> <hr style={style.divider} />
<ExternalLink style={style.isSafe} href="https://www.etesync.com/faq/#signed-pages"> <ExternalLink style={style.isSafe} href="https://www.etesync.com/faq/#signed-pages">
@ -133,16 +127,13 @@ class LoginGate extends React.Component {
</ul> </ul>
</Container> </Container>
); );
} else if (this.props.credentials.value.encryptionKey === null) { } else if (props.credentials.value.encryptionKey === null) {
return ( return (
<EncryptionPart credentials={this.props.credentials} /> <EncryptionPart credentials={props.credentials} />
); );
} }
return ( return (
<SyncGate etesync={this.props.credentials.value} /> <SyncGate etesync={props.credentials.value} />
); );
}
} }
export default LoginGate;

Loading…
Cancel
Save