<template>
<buttonQuestion class="radioQuestion"
    :questionText="questionText"
    :answers="models"
    groupName="Choose Vehicle Model"
    v-model="modelValue"
  />
</template>

<script>
import buttonQuestion from "@/common-components/button-question/button-question";
// Supporting files
import store from "@/store";
import { storeActions } from "@/constants/store-actions.js";
import baseMixin from "@/mixins/base-mixin.js";

export default {
  name: "model-question",
  data() {
    return {
      questionText: null,
      models: Array,
    }
  },
  props: {
    modelValue: String,
  },
  components: {
    buttonQuestion,
  },
  methods: {
    loadInitialData() {
      return baseMixin.methods.dispatchNonBlockingStoreAction(storeActions.GET_VEHICLE_MODELS, {year: store.getters.vehicle.year, make: store.getters.vehicle.make});
    },
    initializeComponent(cmsContent, initialData) {
      this.questionText = cmsContent.QuestionText;
      this.models = initialData;
    }
  },
  watch: {
    modelValue(val) {
      this.$emit("update:modelValue", val);
    }
  },
};
</script>
