Skip to content

Commit

Permalink
refactor(datetime/calendar): Update to follow conventions (#585)
Browse files Browse the repository at this point in the history
* refactor: Don't use `else` block

* refactor(datetime/calendar): Rename `selectedIndex` to `currentValue`
  • Loading branch information
TSenter authored Jun 20, 2024
1 parent f50c00d commit 7a106ed
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions addon/components/nrg-datetime/calendar.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export default class NrgDateTimeCalendarComponent extends Component {
}
}

get selectedIndex() {
get currentValue() {
if (this.args.value) {
return this.args.value;
}
Expand All @@ -44,28 +44,27 @@ export default class NrgDateTimeCalendarComponent extends Component {
return this.args.minDate;
} else if (now.isAfter(this.args.maxDate)) {
return this.args.maxDate;
} else {
return now;
}
return now;
}

get selectedDayIndex() {
const value = this.selectedIndex;
const value = this.currentValue;
return dayjs(value).date();
}

get selectedMonthIndex() {
const value = this.selectedIndex;
const value = this.currentValue;
return dayjs(value).month();
}

get selectedYearIndex() {
const value = this.selectedIndex;
const value = this.currentValue;
return dayjs(value).year();
}

get selectedHourIndex() {
const value = this.selectedIndex;
const value = this.currentValue;
const hasTime = this.args.type === 'datetime' || this.args.type === 'time';
if (!hasTime) {
return null;
Expand All @@ -74,7 +73,7 @@ export default class NrgDateTimeCalendarComponent extends Component {
}

get selectedMinuteIndex() {
const value = this.selectedIndex;
const value = this.currentValue;
const hasTime = this.args.type === 'datetime' || this.args.type === 'time';
if (!hasTime) {
return null;
Expand Down

0 comments on commit 7a106ed

Please sign in to comment.