Skip to content

Commit

Permalink
Merge pull request #149 from kbss-cvut/fix-complete
Browse files Browse the repository at this point in the history
Fixed complete button not saving and completing invalid forms
  • Loading branch information
blcham authored Apr 19, 2024
2 parents 57de6ea + eec70f4 commit 1b4b971
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/components/record/Record.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from "react";
import { Button, Modal } from "react-bootstrap";
import { Button } from "react-bootstrap";
import PropTypes from "prop-types";
import { FormattedMessage, injectIntl } from "react-intl";
import withI18n from "../../i18n/withI18n";
Expand Down Expand Up @@ -94,10 +94,12 @@ class Record extends React.Component {
if (form) {
this.validateForm();
const incompleteQuestions = this._filterQuestionsBySeverity("warning");
this.setState({ incompleteQuestions }, () => {
if (incompleteQuestions.length > 0) {
const invalidQuestions = this._filterQuestionsBySeverity("error");
this.setState({ incompleteQuestions, invalidQuestions }, () => {
if (incompleteQuestions.length > 0 || invalidQuestions.length > 0) {
this.setState({ showModal: true });
} else {
this.props.handlers.onSave();
this.props.handlers.onComplete();
}
});
Expand Down

0 comments on commit 1b4b971

Please sign in to comment.