Skip to content

Commit 988b5e2

Browse files
committed
chore: Add AI recommended change (non critical)
1 parent 5ca5b7d commit 988b5e2

1 file changed

Lines changed: 15 additions & 5 deletions

File tree

src/components/summit-dropdown/index.js

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,22 @@ export default class SummitDropdown extends React.Component {
3131
}
3232

3333
handleChange(summit) {
34-
if (typeof summit === OBJECT_TYPEOF)
35-
this.setState({summitValue: summit});
34+
const summitValue =
35+
summit !== null &&
36+
typeof summit === OBJECT_TYPEOF &&
37+
typeof summit.value !== UNDEFINED_TYPEOF
38+
? summit
39+
: null;
40+
41+
this.setState({ summitValue });
3642
}
3743

3844
handleClick(ev) {
3945
ev.preventDefault();
4046
if (
41-
typeof this.state.summitValue === OBJECT_TYPEOF &&
42-
typeof this.state.summitValue?.value !== UNDEFINED_TYPEOF
47+
this.state.summitValue !== null &&
48+
typeof this.state.summitValue === OBJECT_TYPEOF &&
49+
typeof this.state.summitValue.value !== UNDEFINED_TYPEOF
4350
)
4451
this.props.onClick(this.state.summitValue.value);
4552
}
@@ -52,7 +59,10 @@ export default class SummitDropdown extends React.Component {
5259
(a, b) => (a.start_date < b.start_date ? 1 : (a.start_date > b.start_date ? -1 : 0))
5360
).map(s => ({label: s.name, value: s.id}));
5461

55-
const isDisabled = typeof this.state.summitValue !== OBJECT_TYPEOF || this.state.summitValue === null;
62+
const isDisabled =
63+
this.state.summitValue === null ||
64+
typeof this.state.summitValue !== OBJECT_TYPEOF ||
65+
typeof this.state.summitValue.value === UNDEFINED_TYPEOF;
5666

5767
return (
5868
<div className={"summit-dropdown btn-group " + bigClass}>

0 commit comments

Comments
 (0)