WIP: Steps

This commit is contained in:
okbel
2018-04-30 16:20:09 -03:00
parent 1574dabd69
commit 35e8c005f3
4 changed files with 77 additions and 48 deletions
@@ -15,24 +15,22 @@ class ConfirmChangesDialog extends React.Component {
}));
};
saveAndContinue = async () => {
await this.props.saveChanges();
this.goToNextStep();
};
saveAndFinish = async () => {
await this.props.saveChanges();
this.clear();
this.closeDialog();
};
clear = () => {
this.setState(initialState);
};
cancel = async () => {
cancel = () => {
this.clear();
this.closeDialog();
this.props.closeDialog();
};
continue = () => {
this.goToNextStep();
};
finish = () => {
this.clear();
this.props.closeDialog();
};
render() {
@@ -45,10 +43,12 @@ class ConfirmChangesDialog extends React.Component {
const totalSteps = React.Children.count(this.props.children);
if (i !== this.state.step) return;
return React.cloneElement(child, {
...this.props,
onChange: this.props.onChange,
goToNextStep: this.goToNextStep,
clear: this.clear,
cancel: this.cancel,
saveChanges:
i === totalSteps - 1 ? this.saveAndFinish : this.saveAndContinue,
next:
this.state.step === totalSteps - 1 ? this.finish : this.continue,
});
})}
</Dialog>