2017-08-23 00:19:50 +05:30
|
|
|
import React from 'react';
|
2019-12-07 16:58:52 +05:30
|
|
|
import { MessageDescriptor } from 'react-intl';
|
2016-05-02 14:50:50 +05:30
|
|
|
|
|
|
|
import FormComponent from './FormComponent';
|
2016-07-28 09:55:02 +05:30
|
|
|
import FormError from './FormError';
|
2019-12-08 03:23:22 +05:30
|
|
|
import { ValidationError } from './FormModel';
|
2016-05-02 14:50:50 +05:30
|
|
|
|
2019-12-08 03:23:22 +05:30
|
|
|
type Error = ValidationError | MessageDescriptor;
|
2016-05-02 14:50:50 +05:30
|
|
|
|
2019-12-07 16:58:52 +05:30
|
|
|
export default class FormInputComponent<P, S = {}> extends FormComponent<
|
2020-05-24 04:38:24 +05:30
|
|
|
P & {
|
|
|
|
error?: Error;
|
|
|
|
},
|
|
|
|
S & {
|
|
|
|
error?: Error;
|
|
|
|
}
|
2019-11-27 14:33:32 +05:30
|
|
|
> {
|
2020-05-24 04:38:24 +05:30
|
|
|
renderError() {
|
2020-08-05 17:28:31 +05:30
|
|
|
return <FormError error={this.state?.error || this.props.error} />;
|
2020-05-24 04:38:24 +05:30
|
|
|
}
|
2016-05-02 14:50:50 +05:30
|
|
|
|
2020-05-24 04:38:24 +05:30
|
|
|
setError(error: Error) {
|
|
|
|
// @ts-ignore
|
|
|
|
this.setState({ error });
|
|
|
|
}
|
2016-05-02 14:50:50 +05:30
|
|
|
}
|