<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";
  import { useMainStore } from '@/store';
  
  export default {
    name: "year-question",
    data() {
      return {
        years: Array,
      };
    },
    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 useMainStore().getVehicleYears();
      },
      initializeComponent(initialData) {
        this.years = initialData;
      },
    },
  };
  </script>
  