<template>
  <buttonQuestion
    class="radioQuestion"
    isOverflowScrollable
    selectingInitiatesLoad
    :questionText="questionText"
    :answers="years"
    groupName="ChooseVehicleYear"
    textPosition="text-start"
    v-model="selectedValue"
    isRequired
  />
</template>

<script>
import buttonQuestion from "@/common-components/button-question/button-question";
// Supporting files
import { storeActions } from "@/constants/store-actions.js";
import baseMixin from "@/mixins/base-mixin.js";
export default {
  name: "year-question",
  data() {
    return {
      years: [],
    };
  },
  props: {
    modelValue: String,
    cmsWidgetName: String,
  },
  components: {
    buttonQuestion,
  },
  computed: {
    questionText(){
      return this.getCmsContent(this.cmsWidgetName, 'QuestionText');
    },
    selectedValue: {
      get: function() {
        return this.modelValue
      },
      set: function(newValue) {
        this.$emit("update:modelValue", newValue);
      }
    }
  },
  methods: {
    loadInitialData() {
      return baseMixin.methods.dispatchStoreAction(
        storeActions.GET_VEHICLE_YEARS,
        {}
      );
    },
    initializeComponent(initialData) {
      this.years = initialData;
    },
  },
};
</script>
