Add LoginForm to comments
This commit is contained in:
parent
49b77403f6
commit
c2c72457db
@ -5,6 +5,7 @@ export interface IInputProps {
|
|||||||
type: 'text' | 'password' | 'hidden' | 'submit'
|
type: 'text' | 'password' | 'hidden' | 'submit'
|
||||||
value?: string
|
value?: string
|
||||||
onChange?: (name: this['name'], value: string) => void
|
onChange?: (name: this['name'], value: string) => void
|
||||||
|
placeholder?: string
|
||||||
readOnly?: boolean
|
readOnly?: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -21,6 +22,7 @@ export class Input extends React.PureComponent<IInputProps> {
|
|||||||
type={this.props.type}
|
type={this.props.type}
|
||||||
value={this.props.value}
|
value={this.props.value}
|
||||||
onChange={this.handleChange}
|
onChange={this.handleChange}
|
||||||
|
placeholder={this.props.placeholder}
|
||||||
readOnly={!!this.props.readOnly}
|
readOnly={!!this.props.readOnly}
|
||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
|
|||||||
@ -5,7 +5,7 @@ import {ICredentials} from '@rondo/common'
|
|||||||
export interface ILoginFormProps {
|
export interface ILoginFormProps {
|
||||||
error?: string
|
error?: string
|
||||||
onSubmit: (credentials: ICredentials) => Promise<void>
|
onSubmit: (credentials: ICredentials) => Promise<void>
|
||||||
onSuccess: () => void
|
onSuccess?: () => void
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ILoginFormState extends ICredentials {}
|
export interface ILoginFormState extends ICredentials {}
|
||||||
@ -23,8 +23,11 @@ export class LoginForm extends React.PureComponent<
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
handleSubmit = async () => {
|
handleSubmit = async () => {
|
||||||
|
const {onSuccess} = this.props
|
||||||
await this.props.onSubmit(this.state)
|
await this.props.onSubmit(this.state)
|
||||||
this.props.onSuccess()
|
if (onSuccess) {
|
||||||
|
onSuccess()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
handleChange = (name: string, value: string) => {
|
handleChange = (name: string, value: string) => {
|
||||||
this.setState(
|
this.setState(
|
||||||
@ -40,12 +43,14 @@ export class LoginForm extends React.PureComponent<
|
|||||||
type='text'
|
type='text'
|
||||||
onChange={this.handleChange}
|
onChange={this.handleChange}
|
||||||
value={this.state.username}
|
value={this.state.username}
|
||||||
|
placeholder='Username'
|
||||||
/>
|
/>
|
||||||
<Input
|
<Input
|
||||||
name='password'
|
name='password'
|
||||||
type='password'
|
type='password'
|
||||||
onChange={this.handleChange}
|
onChange={this.handleChange}
|
||||||
value={this.state.password}
|
value={this.state.password}
|
||||||
|
placeholder='Password'
|
||||||
/>
|
/>
|
||||||
<Input
|
<Input
|
||||||
name='submit'
|
name='submit'
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
export interface IClientConfig {
|
export interface IClientConfig {
|
||||||
readonly appName: string
|
readonly appName: string
|
||||||
readonly baseUrl: string
|
readonly baseUrl: string
|
||||||
|
readonly csrfToken: string
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user