import Ember from 'ember';

export default Ember.Component.extend({
  userSettings: Ember.inject.service(),

  init () {
    this._super();
    this.get('userSettings').timePeriods().then(response => {
      // Sort by latest on top
      this.set('timePeriods', response.sortBy('begins').reverse());

      // Create array of years
      this.set('years', response.uniqBy('year'));
    });
  }
});

import Ember from 'ember';

export default Ember.Component.extend({
  btnActive: false,
  didReceiveAttrs () {
    this.set('timePeriodChanged', this.get('currentDate'));
  },

  init () {
    this._super();
    this.get('userSettings').timePeriods().then(response => {
      // Sort by latest on top
      this.set('timePeriods', response.sortBy('begins').reverse());

      // Create array of years
      this.set('years', response.uniqBy('year'));
    });
  }
});

Set variable for time period base on value passed to component
refactor: Set variable for time period base on value passed to component

