From 5301b546df3b39efb522d1fbb358777b84498bc5 Mon Sep 17 00:00:00 2001 From: Tom Hacohen Date: Fri, 21 Feb 2020 15:21:23 +0200 Subject: [PATCH] LoginGate: move to be a function component. --- src/LoginGate.tsx | 99 +++++++++++++++++++++-------------------------- 1 file changed, 45 insertions(+), 54 deletions(-) diff --git a/src/LoginGate.tsx b/src/LoginGate.tsx index 3a8e780..4751603 100644 --- a/src/LoginGate.tsx +++ b/src/LoginGate.tsx @@ -81,68 +81,59 @@ function EncryptionPart(props: { credentials: CredentialsType }) { ); } +interface PropsType { + credentials: CredentialsType; +} -class LoginGate extends React.Component { - public props: { - credentials: CredentialsType; - }; - - constructor(props: any) { - super(props); - this.onFormSubmit = this.onFormSubmit.bind(this); - } +export default function LoginGate(props: PropsType) { - public onFormSubmit(username: string, password: string, serviceApiUrl?: string) { + function onFormSubmit(username: string, password: string, serviceApiUrl?: string) { serviceApiUrl = serviceApiUrl ? serviceApiUrl : C.serviceApiBase; store.dispatch(fetchCredentials(username, password, serviceApiUrl)); } - public render() { - if (this.props.credentials.value === null) { - const style = { - isSafe: { - textDecoration: 'none', - display: 'block', - }, - divider: { - margin: '30px 0', - color: '#00000025', - }, - }; - - return ( - -

Please Log In

- -
- - SignedPgaes badge - -
    -
  • - The EteSync Website -
  • -
  • - Is the web client safe to use? -
  • -
  • Source code
  • -
-
- ); - } else if (this.props.credentials.value.encryptionKey === null) { - return ( - - ); - } + if (props.credentials.value === null) { + const style = { + isSafe: { + textDecoration: 'none', + display: 'block', + }, + divider: { + margin: '30px 0', + color: '#00000025', + }, + }; return ( - + +

Please Log In

+ +
+ + SignedPgaes badge + +
    +
  • + The EteSync Website +
  • +
  • + Is the web client safe to use? +
  • +
  • Source code
  • +
+
+ ); + } else if (props.credentials.value.encryptionKey === null) { + return ( + ); } -} -export default LoginGate; + return ( + + ); +}