Skip to content

Commit

Permalink
fix(governance): always show formatted text in dropdown
Browse files Browse the repository at this point in the history
if interval exist but it is not in the dropdown options
  • Loading branch information
liorfrenkel committed Feb 13, 2020
1 parent f51e184 commit 9bbc0e1
Showing 1 changed file with 18 additions and 11 deletions.
29 changes: 18 additions & 11 deletions src/pages/governance/Governance.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,10 @@ class GovernancePage extends React.Component {
<div className="col-md-8">
<PageTitle
title="Community Votes"
subtitle={!this.noIntervalsFound && `${
isContestantsPhase ? 'Contestants' : 'Candidates'
} phase`}
subtitle={
!this.noIntervalsFound &&
`${isContestantsPhase ? 'Contestants' : 'Candidates'} phase`
}
/>
</div>
<div className="col-md-4">
Expand Down Expand Up @@ -345,16 +346,16 @@ function IntervalsDropDown({ relevantInterval, intervals, onIntervalChange }) {

const options = intervals.map(item => ({
value: intervalsDDCreateValue(item),
label: `${TextUtils.getOrdinal(item.interval)} Semester, ${item.phase}s - ${
item.beginHeight
}-${item.endHeight}`
label: getDropDownSemesterText(item)
}));

let value = intervalsDDCreateValue(relevantInterval);
if (!options.find(option => option.value === value)) {
value = getDropDownSemesterText(relevantInterval);
}

return (
<Dropdown
options={options}
value={intervalsDDCreateValue(relevantInterval)}
onChange={onIntervalChange}
/>
<Dropdown options={options} value={value} onChange={onIntervalChange} />
);
}
IntervalsDropDown.propTypes = {
Expand All @@ -363,6 +364,12 @@ IntervalsDropDown.propTypes = {
onIntervalChange: PropTypes.func
};

function getDropDownSemesterText(interval) {
return `${TextUtils.getOrdinal(interval.interval)} Semester, ${
interval.phase
}s - ${interval.beginHeight}-${interval.endHeight}`;
}

function getPageUrl(interval, phase) {
return `/governance/${interval}/${phase}`;
}
Expand Down

0 comments on commit 9bbc0e1

Please sign in to comment.