<template>
  <div class="importer">
    <form>
      <input
        ref="input"
        type="file"
        @change="change"
      >
    </form>
    <FAIcon
      v-if="submitting"
      class="importer-uploading"
      spin
      icon="circle-notch"
    />
    <button
      v-else
      class="btn button-default"
      @click="submit"
    >
      {{ submitButtonLabel || $t('importer.submit') }}
    </button>
    <div v-if="success">
      <FAIcon
        icon="times"
        @click="dismiss"
      />
      <p>{{ successMessage || $t('importer.success') }}</p>
    </div>
    <div v-else-if="error">
      <FAIcon
        icon="times"
        @click="dismiss"
      />
      <p>{{ errorMessage || $t('importer.error') }}</p>
    </div>
  </div>
</template>

<script src="./importer.js"></script>

<style lang="scss">
.importer {
  &-uploading {
    font-size: 1.5em;
    margin: 0.25em;
  }
}
</style>
