What am I trying to achieve is passing the state from this input:
<FormControl variant="outlined" fullWidth margin="normal">
<InputLabel htmlFor="isEbitda">
EBITDA
</InputLabel>
<Select
inputProps={{
name: "isEbitda",
id: "isEbitda"}}
label="EBITDA"
fullWidth
value={this.state.isEbitda}
onChange={(e) => this.handleisEbitda(e)}
>
<MenuItem value={false}>No</MenuItem>
<MenuItem value={true}>Yes</MenuItem>
</Select>
</FormControl>
...so I can use it as a second as a second parameter in if else statement in this function:
disableImprovementCalculationCards() {
this.setState({
ebitCardDisabled: false,
ebitPlusCardDisabled: false,
oviCardDisabled: false,
EbitdaCardDisabled: false,
isEbitda: true
});
if (this.state.CreateProjectCommand.valueImprovementTypeId == "") {
this.setState({
ebitCardDisabled: true,
ebitPlusCardDisabled: true,
oviCardDisabled: true,
EbitdaCardDisabled: true,
isEbitda: true
});
}
else if (this.state.CreateProjectCommand.valueImprovementTypeId == "1" && this.state.isEbitda == true) {
this.setState({
ebitPlusCardDisabled: true,
oviCardDisabled: true,
});
}
else if (this.state.CreateProjectCommand.valueImprovementTypeId == "1" && this.state.isEbitda == false) {
this.setState({
ebitPlusCardDisabled: true,
oviCardDisabled: true,
EbitdaCardDisabled: true,
});
}
else if (this.state.CreateProjectCommand.valueImprovementTypeId == "2" && this.state.isEbitda == true) {
this.setState({
ebitCardDisabled: true,
oviCardDisabled: true,
});
}
else if (this.state.CreateProjectCommand.valueImprovementTypeId == "2" && this.state.isEbitda == false) {
this.setState({
ebitCardDisabled: true,
oviCardDisabled: true,
EbitdaCardDisabled: true,
});
}
else if (this.state.CreateProjectCommand.valueImprovementTypeId == "3") {
this.setState({
ebitCardDisabled: true,
ebitPlusCardDisabled: true,
EbitdaCardDisabled: true,
});
}
else if (this.state.CreateProjectCommand.valueImprovementTypeId == "4") {
this.setState({
oviCardDisabled: true,
});
}
else if (this.state.CreateProjectCommand.valueImprovementTypeId == "5") {
this.setState({
ebitPlusCardDisabled: true,
});
}
else if (this.state.CreateProjectCommand.valueImprovementTypeId == "6") {
this.setState({
ebitCardDisabled: true,
});
}
}
What I have tried:
The purpose of a second parameter in the if else statement to case to hide/show an input called EbitdaCard. However, no such thing happens. I am not sure whether I do not pass the state properly, or there is an error in the function I pass it into?