<template>
  <div class="submission-document">
    <p
      class="submission-document__content content"
      v-if="document && document.length > 0"
    >
      <document-icon class="content__icon" /><span class="content__text">{{ filename }}</span>
    </p>
  </div>
</template>

<script>
import { defineAsyncComponent } from 'vue';
import filenameFromUrl from '@/helpers/urls';
const DocumentIcon = defineAsyncComponent(() =>
  import('@/components/icons/DocumentIcon.vue')
);

export default {
  name: 'StudentSubmissionDocument',
  props: ['document'],
  components: { DocumentIcon },

  computed: {
    filename() {
      return filenameFromUrl(this.document);
    },
  },
};
</script>

<style scoped lang="scss">
.content {
  display: flex;

  &__icon {
    width: 25px;
    align-self: center;
  }

  &__text {
    align-self: center;
    padding-left: 5px;
  }
}
</style>
