<template>
  <div>
    <component @click="notShowTour" :is="tour"></component>
  </div>
</template>

<script>
import SalesConsultant from "./SalesConsultant";
import ManagerSalesConsultant from "./ManagerSalesConsultant";

import UserLoggedService from "@/services/resources/UserLoggedService";
const service = UserLoggedService.build();

export default {
  components: {
    ManagerSalesConsultant,
    SalesConsultant
  },
  computed: {
    tour() {
      if (this.$store.getters.isSalesConsultant) {
        return "SalesConsultant";
      } else if (this.$store.getters.isManagerSalesConsultant) {
        return "ManagerSalesConsultant";
      }
    }
  },
  methods: {
    notShowTour() {
      var vm = this;

      service
        .create()
        .then(resp => {
          vm.$router.push("/");
        })
        .catch(err => {
          vm.$router.push("/");
        });
    }
  },
  mounted() {
    
    if (!this.$store.state.user.user.show_tour) {
      this.$router.push("/");
    }

    if(!this.$store.getters.isSalesConsultant){
            this.$router.push("/");
    }
  }
};
</script>