<template>
    <transition
        name="fade"
        mode="out-in">
        <div
            v-if="isAvailable"
            class="windshield-damage-type-question"
            aria-live="polite">
            <buttonQuestion
                v-model="selectedValues"
                :questionText="questionText"
                :answers="answersFromCms"
                :groupName="groupName"
                buttonTypeString="listCard"
                :suppressError="suppressError"
                :validationRules="validationRules"
                isRequired />
        </div>
    </transition>
</template>

<script>
import buttonQuestion from '@/digital-components/button-question/button-question.vue';

export default {
    name: 'windshield-damage-type-question',
    components: {
        buttonQuestion
    },
    props: {
        modelValue: String,
        groupName: String,
        isAvailable: Boolean,
        suppressError: Boolean,
        validationRules: String,
        cmsWidgetName: String
    },
    emits: ['update:modelValue'],
    computed: {
        questionText() {
            return this.getCmsContent(this.cmsWidgetName, 'QuestionText');
        },
        answersFromCms() {
            return this.getCmsContent(this.cmsWidgetName, 'Answers');
        },
        selectedValues: {
            get() {
                return this.modelValue;
            },
            set(newValue) {
                this.$emit('update:modelValue', newValue);
            }
        }
    }
};
</script>
