<!--
   Copyright 2018 Brigham Young University

   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.
-->
<template>
  <div class="background-summary">
    <BackgroundBadge
      label="Univ Discipline"
      unsetLabel="No Univ Discipline"
      :value="bg.universityDiscipline"
      :cleared="backgroundCleared" />
    <BackgroundBadge
      label="Sex Offender"
      unsetLabel="No Sex Offense"
      :value="bg.sexRegistry"
      :cleared="backgroundCleared" />
    <BackgroundBadge
      label="Plural Marriage"
      unsetLabel="No Plural Marriage"
      :value="bg.pluralMarriage"
      :cleared="backgroundCleared" />
    <BackgroundBadge
      label="Criminal Record"
      unsetLabel="No Criminal Record"
      :value="bg.convictionRecord"
      :cleared="backgroundCleared" />
  </div>
</template>
<script>
  import BackgroundBadge from './BackgroundBadge'
  import { mapState, mapGetters } from 'vuex'

  export default {
    name: 'DetailsBackgroundSummary',
    components: { BackgroundBadge },
    computed: {
      ...mapState({
        bg: state => state.application.background
      }),
      ...mapGetters(['flagByValue']),
      backgroundCleared () {
        const bgFlag = this.flagByValue('BI')
        return bgFlag.isSet && bgFlag.isCleared
      }
    }
  }
</script>
<style scoped>
  .background-summary {
    display: grid;
    grid-template-columns: repeat(auto-fill, 10rem);
    grid-auto-rows: auto;
    grid-gap: 0.5rem;
  }
</style>
