Add LoginForm to comments

This commit is contained in:
Jerko Steiner 2019-03-17 11:20:29 +05:00
parent 49b77403f6
commit c2c72457db
3 changed files with 10 additions and 2 deletions

View File

@ -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<IInputProps> {
type={this.props.type}
value={this.props.value}
onChange={this.handleChange}
placeholder={this.props.placeholder}
readOnly={!!this.props.readOnly}
/>
)

View File

@ -5,7 +5,7 @@ import {ICredentials} from '@rondo/common'
export interface ILoginFormProps {
error?: string
onSubmit: (credentials: ICredentials) => Promise<void>
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'
/>
<Input
name='password'
type='password'
onChange={this.handleChange}
value={this.state.password}
placeholder='Password'
/>
<Input
name='submit'

View File

@ -1,4 +1,5 @@
export interface IClientConfig {
readonly appName: string
readonly baseUrl: string
readonly csrfToken: string
}