From e710e89200333a4c55c5a061407380ab1c03a96e Mon Sep 17 00:00:00 2001 From: Tom Hacohen Date: Sat, 16 Dec 2017 17:53:08 +0000 Subject: [PATCH] Remove server url awareness from LoginForm making it a cleaner component. --- src/LoginForm.tsx | 4 ++-- src/LoginGate.tsx | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/LoginForm.tsx b/src/LoginForm.tsx index ae1e426..7a07291 100644 --- a/src/LoginForm.tsx +++ b/src/LoginForm.tsx @@ -26,7 +26,7 @@ class LoginForm extends React.PureComponent { }; props: { - onSubmit: (username: string, password: string, encryptionPassword: string, serviceApiUrl: string) => void; + onSubmit: (username: string, password: string, encryptionPassword: string, serviceApiUrl?: string) => void; loading?: boolean; error?: Error; }; @@ -55,7 +55,7 @@ class LoginForm extends React.PureComponent { generateEncryption(e: any) { e.preventDefault(); - const server = this.state.showAdvanced ? this.state.server : C.serviceApiBase; + const server = this.state.showAdvanced ? this.state.server : undefined; const username = this.state.username; const password = this.state.password; diff --git a/src/LoginGate.tsx b/src/LoginGate.tsx index e7facd9..6ac165b 100644 --- a/src/LoginGate.tsx +++ b/src/LoginGate.tsx @@ -21,7 +21,8 @@ class Root extends React.PureComponent { this.onFormSubmit = this.onFormSubmit.bind(this); } - onFormSubmit(username: string, password: string, encryptionPassword: string, serviceApiUrl: string) { + onFormSubmit(username: string, password: string, encryptionPassword: string, serviceApiUrl?: string) { + serviceApiUrl = serviceApiUrl ? serviceApiUrl : C.serviceApiBase; store.dispatch(fetchCredentials(username, password, encryptionPassword, serviceApiUrl)); }