add test for question delete; fix bug with delete question
This commit is contained in:
@@ -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});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user