<template>
  <div class="directories_containter">
    <div class="directory_container" v-for="(directory, index) in directories" :key="index">
      <div
        class="directory_cover_image"
        :style="{ 'background-image': `url(${directory.cover_picture})` }"
      />
      <p class="directory-title">{{ directory.title_text }}</p>
      <p class="directory-subtitle">{{ directory.summary_text }}</p>
      <button class="btn btn-link directory-btn" @click="view_link(directory)">
        {{ $t('Read More') }}
      </button>
    </div>
  </div>
</template>
<script>
import { ContentApi } from '@/utils/index'
export default {
  name: 'About',
  components: {},
  computed: {},
  mounted() {
    this.retrieve_directories()
  },
  methods: {
    retrieve_directories() {
      ContentApi.retrieve_about_directories(window.location.host)
        .then((response) => {
          this.directories = response.data
        })
        .catch((error) => {
          this.mnx_backendErrorHandler(error)
        })
    },
    view_link(directory) {
      if (directory.content_id)
        this.mnx_navToPdfContentViewer(directory.content_id)
      else if (directory.content_link)
        this.mnx_navToLinkContentViewer(btoa(directory.content_link))
    }
  },
  data() {
    return {
      directories: null
    }
  }
}
</script>

<style scoped lang="scss">
.directories_containter {
  @extend .container;
  padding: 56px 40px;
}

.directory_container {
  @extend .container;
  padding: 0;
  text-align: left;

  .btn-link {
    margin-bottom: 24px;
    text-decoration: underline;
    padding: 0;
  }
}

.directory_cover_image {
  width: 100%;
  height: 311px;
  background-repeat: no-repeat;
  background-position: center center;
  background-size: cover;
  border-radius: 16px;
  margin-bottom: 16px;
}

.directory-title {
  font-size: 48px;
  font-weight: 600;
  color: #18181a;
  margin-bottom: 0;
}

.directory-subtitle {
  font-size: 14px;
  color: #666666;
  margin-bottom: 5px;
}
.directory-btn {
  font-weight: 600;
}
</style>
