Skip to content

Commit 0a7d308

Browse files
chore: Add requested changes
1 parent 68d74ec commit 0a7d308

2 files changed

Lines changed: 8 additions & 17 deletions

File tree

src/components/summit-dropdown/index.js

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ import React from 'react';
1515
import './summit-dropdown.less';
1616
import Select from 'react-select';
1717
import T from 'i18n-react/dist/i18n-react';
18-
import { OBJECT_TYPEOF, UNDEFINED_TYPEOF } from '../../utils/constants';
1918

2019
export default class SummitDropdown extends React.Component {
2120

@@ -31,12 +30,7 @@ export default class SummitDropdown extends React.Component {
3130
}
3231

3332
handleChange(summit) {
34-
const summitValue =
35-
summit !== null &&
36-
typeof summit === OBJECT_TYPEOF &&
37-
typeof summit.value !== UNDEFINED_TYPEOF
38-
? summit
39-
: this.state.summitValue;
33+
const summitValue = summit?.value !== undefined ? summit : this.state.summitValue;
4034

4135
this.setState({ summitValue });
4236
}
@@ -53,16 +47,16 @@ export default class SummitDropdown extends React.Component {
5347

5448
render() {
5549

56-
let {summits, actionLabel, actionClass, big: bigClass = "" } = this.props;
57-
let summitOptions = summits
50+
let { summits, actionLabel, actionClass } = this.props;
51+
let summitOptions = [...summits]
5852
.sort(
5953
(a, b) => (a.start_date < b.start_date ? 1 : (a.start_date > b.start_date ? -1 : 0))
6054
).map(s => ({label: s.name, value: s.id}));
6155

62-
const isDisabled =
63-
this.state.summitValue === null ||
64-
typeof this.state.summitValue !== OBJECT_TYPEOF ||
65-
typeof this.state.summitValue.value === UNDEFINED_TYPEOF;
56+
let bigClass = this.props.hasOwnProperty('big') ? 'big' : '';
57+
const isDisabled = this.state.summitValue?.value === undefined;
58+
59+
6660

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

src/utils/constants.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,4 @@ export const RATE_FIELDS = {
5555
ONSITE: "onsite_rate"
5656
};
5757

58-
export const DECIMAL_DIGITS = 2;
59-
60-
export const OBJECT_TYPEOF = 'object';
61-
export const UNDEFINED_TYPEOF = 'undefined';
58+
export const DECIMAL_DIGITS = 2;

0 commit comments

Comments
 (0)