<template>
  <div>
    {{ person }}
  </div>
</template>

<script>
import { mapState } from "vuex";

export default {
  name: "Person",
  head() {
    return {
      titleTemplate: `%s - ${this.person.name}`
    };
  },
  validate({ params }) {
    const uuid = new RegExp(
      /^[0-9A-Za-z]{8}-[0-9A-Za-z]{4}-4[0-9A-Za-z]{3}-[89ABab][0-9A-Za-z]{3}-[0-9A-Za-z]{12}$/
    );
    return uuid.test(params.id);
  },
  async asyncData({ params, store }) {
    await store.dispatch("getPerson", params.id);
  },
  computed: {
    ...mapState(["person"])
  }
};
</script>

<style></style>
