<!--
   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>
    <div v-if="institute" class="grid">
      <template v-if="institute.attendance">
        <h6 class="full-width">Years Attended</h6>
        <p class="full-width"> {{ institute.attendance }} </p>
      </template>
      <template v-if="institute.explanation">
        <h6 class="full-width">Explanation</h6>
        <p class="full-width"> {{ institute.explanation }} </p>
      </template>
      <template v-if="!hideClasses">
        <div v-for="(c, i) of institute.classes" :key="i" class="card">
          <h6 class="card-header">{{c.className}}</h6>
          <div class="card-body">
            <h6>{{c.academicYear}}</h6>
            <div>
              Grade: <strong>{{ c.grade }}</strong>
              <br>
              For Credit: <strong>{{ c.forCredit }}</strong>
            </div>
          </div>
        </div>
      </template>
    </div>
    <div v-else>
      No institute information reported.
    </div>
  </div>
</template>
<script>
import { mapState } from 'vuex'

export default {
  name: 'DetailsInstitute',
  props: {
    hideClasses: Boolean
  },
  computed: {
    ...mapState({
      institute: state => state.application.institute
    })
  }
}
</script>
<style scoped>
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(12rem, 1fr));
  grid-auto-rows: auto;
  grid-gap: 0.5rem;
  /* grid-auto-flow: dense; */
}
.full-width {
  grid-column: 1 / -1;
}
h6 {
  font-weight: bold;
}
th.selection-cell {
  min-width: 5rem;
}
td.selection-cell {
  text-align: center;
}
td.selected {
  color: var(--primary, blue);
}
.alt-text {
  font-size: 0;
}
@media only speech {
  .alt-text { font-size: 1rem; }
}
</style>
