<template>
  <div class="hello">
    <nav>
      <router-link v-for="day in days" :to="'/' + $route.params.mensa + '/' + day" :key="day">{{dayOfWeek[day]}}</router-link>
    </nav>
    <router-view></router-view>
  </div>
</template>

<script>
export default {
  name: 'mensa',
  data () {
    return {
      days: [1, 2, 3, 4, 5, 6],
      dayOfWeek: {
        1: 'Montag',
        2: 'Dienstag',
        3: 'Mittwoch',
        4: 'Donnerstag',
        5: 'Freitag',
        6: 'Samstag'
      }
    }
  },
  watch: {
    '$route': function () {
      if (!this.$route.fullPath.endsWith('/')) {
        this.$router.replace(this.$route.fullPath + '/')
      }
      if (!this.$route.params.tag) {
        this.$router.push('' + new Date().getDay())
      }
    }
  },
  mounted () {
    if (!this.$route.fullPath.endsWith('/')) {
      this.$router.replace(this.$route.fullPath + '/')
    }
    if (!this.$route.params.tag) {
      this.$router.push('' + new Date().getDay())
    }
  }
}
</script>

<style></style>
