<!--
   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="applicant" slot="applicantInfo">
    <em>{{ applicantType }}</em>
    <div v-if="compact">
      {{ netId }}
    </div>
    <div v-else>
      {{ netId }}
      |
      {{ byuId }}
      |
      {{ dateOfBirth | dateFormat }}
      |
      {{ age }}
      |
      {{ sex }}
      |
      {{ religion }}
    </div>
    <div v-if="compact">
      {{ admitPeriod | yearTerm }}
      |
      {{ applicationStatus }}
    </div>
    <div v-else>
      {{ admitPeriod | yearTerm }}
      |
      {{ applicantMajor }}
      |
      {{ applicationStatus }}
    </div>
  </div>
</template>
<script>
import { dateFormat } from './dateTimeFormat'
import { mapState } from 'vuex'

export default {
  name: 'ApplicantInfo',
  filters: { dateFormat },
  props: {
    compact: {
      type: Boolean,
      default: false
    }
  },
  computed: {
    ...mapState({
      applicantType: state => state.packet.applicantType ? state.packet.applicantType : state.application.applicantType,
      admitPeriod: state => state.application.admitPeriod,
      applicantMajor: state => state.application.applicantMajor,
      netId: state => state.application.netId,
      byuId: state => state.application.applicantId,
      dateOfBirth: state => state.application.personalRecords.dateOfBirth,
      age: state => state.application.personalRecords.age,
      sex: state => state.application.personalRecords.sex,
      applicationStatus: state => state.application.applicationStatus,
      religion: state => state.application.mission.religion
    })
  }
}
</script>
<style scoped>
.applicant {
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-rows: auto auto;
  grid-column-gap: 0.5rem;
}
.applicant > em {
  grid-column: 1 / 2;
  grid-row: 1 / -1;
  font-size: 1.5rem;
  font-style: normal;
  align-self: center;
  background-color: var(--light, #fafafa);
  color: var(--dark, #333333);
  border-radius: 50%;
  width: 2.5rem;
  height: 2.5rem;
  text-align: center;
  vertical-align: middle;
  line-height: 1.55em;
}
</style>
