From c2c72457dbf9ebaea7f6be1b6448298ef0573d80 Mon Sep 17 00:00:00 2001 From: Jerko Steiner Date: Sun, 17 Mar 2019 11:20:29 +0500 Subject: [PATCH] Add LoginForm to comments --- packages/client/src/components/Input.tsx | 2 ++ packages/client/src/login/LoginForm.tsx | 9 +++++++-- packages/client/src/renderer/IClientConfig.ts | 1 + 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/packages/client/src/components/Input.tsx b/packages/client/src/components/Input.tsx index cebf0fa..2413f39 100644 --- a/packages/client/src/components/Input.tsx +++ b/packages/client/src/components/Input.tsx @@ -5,6 +5,7 @@ export interface IInputProps { type: 'text' | 'password' | 'hidden' | 'submit' value?: string onChange?: (name: this['name'], value: string) => void + placeholder?: string readOnly?: boolean } @@ -21,6 +22,7 @@ export class Input extends React.PureComponent { type={this.props.type} value={this.props.value} onChange={this.handleChange} + placeholder={this.props.placeholder} readOnly={!!this.props.readOnly} /> ) diff --git a/packages/client/src/login/LoginForm.tsx b/packages/client/src/login/LoginForm.tsx index c325c8c..724f6ff 100644 --- a/packages/client/src/login/LoginForm.tsx +++ b/packages/client/src/login/LoginForm.tsx @@ -5,7 +5,7 @@ import {ICredentials} from '@rondo/common' export interface ILoginFormProps { error?: string onSubmit: (credentials: ICredentials) => Promise - onSuccess: () => void + onSuccess?: () => void } export interface ILoginFormState extends ICredentials {} @@ -23,8 +23,11 @@ export class LoginForm extends React.PureComponent< } } handleSubmit = async () => { + const {onSuccess} = this.props await this.props.onSubmit(this.state) - this.props.onSuccess() + if (onSuccess) { + onSuccess() + } } handleChange = (name: string, value: string) => { this.setState( @@ -40,12 +43,14 @@ export class LoginForm extends React.PureComponent< type='text' onChange={this.handleChange} value={this.state.username} + placeholder='Username' />