<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 DocumentIcon from '@/components/icons/DocumentIcon';
  import filenameFromUrl from '@/helpers/urls';

  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>
