<template>
  <div>
    <app-navbar></app-navbar>
    <section id="app" class="section">
      <div class="container">
        <router-view v-if="!hasError"></router-view>
        <div v-else>
          <h1>Error!</h1>
          <p>{{error}}</p>
        </div>
      </div>
    </section>
  </div>
</template>

<script>

  import { mapState } from "vuex";
  import AppNavbar from "./AppNavbar";

  export default {
    computed: {
      ...mapState({
        hasError: state => state.error !== null,
        error: state => state.error
      })
    },

    components: {
      AppNavbar
    }
  }

</script>