<template>
  <div class="signature-verify">
    <div v-if="signatureVerify === 1">
      <SignatureValid />
      <span>{{ $t('signatures.detailsDialog.validSignature') }}</span>
    </div>
    <template v-else-if="signature.length === 1">
      <div v-if="signatureVerify === 2">
        <SignatureInvalid />
        <span>{{ $t('signatures.detailsDialog.invalidSignature') }}</span>
      </div>
      <div v-else>
        <SignatureUnknown />
        <span>{{ $t('signatures.detailsDialog.unknownSignature') }}</span>
      </div>
    </template>
    <div v-else-if="signatureVerify === 2 || signatureVerify === 3">
      <SignatureInvalid />
      <span>{{ $t('signatures.detailsDialog.atLeastOneInvalid') }}</span>
    </div>
    <div class="view-button" @click="viewAll">{{ $t('signatures.detailsDialog.viewAllSignatures') }}</div>
  </div>
</template>

<script setup>
  import { computed } from 'vue'
  import { useViewerStore } from '@/stores/modules/viewer'
  import { useDocumentStore } from '@/stores/modules/document'

  const useViewer = useViewerStore()
  const useDocument = useDocumentStore()

  const signatureVerify = computed(() => useViewer.getSignatureVerify)
  const signature = computed(() => useDocument.getSignatures)

  const viewAll = () => {
    useViewer.openElement('leftPanel')
    useViewer.setActiveElementTab('leftPanel', 'SIGNATURE')
  }
</script>

<style lang="scss" scoped>
.signature-verify {
  position: relative;
  padding: 8px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  z-index: 4;
  height: 48px;
  background: #DDE9FF;
  animation: ease-out 1s;

  div:first-child {
    display: flex;
    align-items: center;
  }

  svg {
    width: 32px;
    height: 32px;
    color: var(--c-icon-blue);
  }

  span {
    margin-left: 8px;
    font-size: 14px;
    line-height: 16px;
    color: #001A4E;
  }

  .view-button {
    padding: 8px 12px;
    height: 32px;
    border: 1px solid #1460F3;
    cursor: pointer;
    font-size: 14px;
    line-height: 16px;
    color: #1460F3;
    white-space: nowrap;

    &:hover {
      background: #1460F3;
      color: white;
    }
  }
}

@keyframes ease-out {
  from { opacity: 0; }
  to { opacity: 1; }
}
</style>

