<template>
  <v-dialog v-model="dialog" transition="dialog-bottom-transition" width="40%">
    <slot></slot>
  </v-dialog>
</template>

<script>
export default {
  data () {
    return {
      show: true
    }
  },
  computed: {
    dialog: {
      get () {
        return this.$store.getters.getDialog
      },
      set (value) {
        this.$store.commit('setDialog', value)
      }
    }
  },
  updated () {
    if (this.dialog && this.show) {
      this.show = false
      if (this.$parent.$refs.login) {
        this.$parent.$refs.login.resetValidation()
      } else {
        this.$parent.$refs.register.resetValidation()
      }
    } else if (!this.dialog) {
      this.show = true
    }
  }
}
</script>

