<template>
    <v-dialog v-model="modal" :width="properties.properties &&  properties.properties.width ? properties.properties.width : '60%'" transition="slide-x-transition">
        <v-card class="RTL">
            <v-card-title :class="[properties.properties &&  properties.properties.color ? properties.properties.color : 'blue', 'lighten-5']" primary-title>
                <WM-PartTitle
                    :TitleFa="properties.name || 'بیشتر بدانید'"
                    :TitleEn="properties.name_en || 'Know More'"
                    :color="properties.properties &&  properties.properties.color ? properties.properties.color : 'blue'"
                ></WM-PartTitle>
            </v-card-title>
            <v-card-text>
                <div class="mt-3 text-right" v-html="properties.description || 'پیام'">

                </div>
            </v-card-text>

            <v-divider></v-divider>
            <v-card-actions>
                <v-spacer></v-spacer>
                <v-btn
                    :color="properties.properties &&  properties.properties.color ? properties.properties.color : 'blue'"
                    depressed
                    dark
                    @click="$_closeModal()"
                >
                    <v-icon dark right>WMi-ok</v-icon>
                    متوجه شدم
                </v-btn>
            </v-card-actions>
        </v-card>
    </v-dialog>
</template>

<script>
import { mapActions, mapGetters } from "vuex";
import axios from 'axios';
import { url } from '@Common/mixins/urls';
export default {
    name: "modal_modal_helper",
    data: () => ({
        properties: {}
    }),
    computed: {
        ...mapGetters("modal", ["isModal", "getModal"]),
        modal: {
			get() {
                return this.isModal(this.$options.name);
			},
			set(value) {
				if (!value) {
					this.$_closeModal();
				}
			}
		},
    },
    methods: {
        async getDate() {
            if (this.modal) {
                let response = await axios.get(url('help', {help: this.getModal(this.$options.name).slug}));
                if (response && response.status == 200) {
                    this.properties = response.data.data;
                    this.properties.properties = (response.data.data.properties) ? JSON.parse(response.data.data.properties) : null;
                }
            }
        }
    },
    created() {
        this.getDate();
    },
};
</script>
