mirror of
https://github.com/elyby/accounts-frontend.git
synced 2025-05-31 14:11:58 +05:30
Extract general popups markup to its own component
Split popups controllers into separate components Implemented storybooks for all project's popups
This commit is contained in:
@@ -14,12 +14,12 @@ interface BaseProps {
|
||||
}
|
||||
|
||||
interface PropsWithoutForm extends BaseProps {
|
||||
onSubmit: (form: FormData) => Promise<void> | void;
|
||||
onSubmit?: (form: FormData) => Promise<void> | void;
|
||||
}
|
||||
|
||||
interface PropsWithForm extends BaseProps {
|
||||
form: FormModel;
|
||||
onSubmit: (form: FormModel) => Promise<void> | void;
|
||||
onSubmit?: (form: FormModel) => Promise<void> | void;
|
||||
}
|
||||
|
||||
type Props = PropsWithoutForm | PropsWithForm;
|
||||
@@ -134,8 +134,10 @@ export default class Form extends React.Component<Props, State> {
|
||||
let result: Promise<void> | void;
|
||||
|
||||
if (hasForm(this.props)) {
|
||||
// @ts-ignore this prop has default value
|
||||
result = this.props.onSubmit(this.props.form);
|
||||
} else {
|
||||
// @ts-ignore this prop has default value
|
||||
result = this.props.onSubmit(new FormData(form));
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user