add test for question delete; fix bug with delete question

This commit is contained in:
GotPPay
2018-04-05 15:40:10 +02:00
parent 275ab2e9b1
commit 83134841a2
2 changed files with 38 additions and 12 deletions

View File

@@ -72,7 +72,7 @@ class IntentDetails extends Component {
rightIcon={
<SVGIcon
onClick={() => {
this.deleteQuestion (question);
this.deleteQuestion (index);
}}
>
{' '}
@@ -146,12 +146,10 @@ class IntentDetails extends Component {
this.setState ({intent: newIntent});
}
deleteQuestion (question) {
deleteQuestion (index) {
if (this.state.intent.questions.length > 1) {
let newIntent = this.state.intent;
let removeId = newIntent.questions.indexOf (question);
if (removeId !== -1) newIntent.questions.splice (removeId, 1);
if (index >= 0 && index < newIntent.questions.length) newIntent.questions.splice (index, 1);
this.setState ({intent: newIntent});
}
}