<template>
  <div>
    <q-dialog
      v-model="showDialog"
      class="ImportDialogRequest"
      no-backdrop-dismiss
    >
      <q-card class="full-width no-shadow" style="max-width: 800px">
        <q-card-section class="ImportDialog-AttentionContent">
          <q-icon
            class="ImportDialog-AttentionContent__Icon"
            name="pgs-import"
          />
          <p class="ImportDialog-AttentionContent__Header">
            {{ get(result, 'descName') || 'Загрузка файла завершена' }}
          </p>
          <div class="ImportDialog-AttentionContent__Noty">
            <div>
              Подтверждено состояние граждан на воинском учете:
              {{ get(result, 'description.confirmed') || '0' }}
            </div>
            <div>
              Записей с ошибками: {{ get(result, 'description.errors') || '0' }}
            </div>
          </div>
        </q-card-section>
        <q-card-actions class="ImportDialog-AttentionButtons">
          <r-btn label="Закрыть" @click="closeDialog()" />
        </q-card-actions>
      </q-card>
    </q-dialog>
  </div>
</template>

<style lang="scss" scoped>
.ImportDialogRequest {
  &-Header {
    color: rgba(2, 12, 18, 0.9);
    font-size: 20px;
    font-family: 'Golos Text', sans-serif;
    font-weight: 500;
    line-height: 24px;
    letter-spacing: -0.3px;
  }

  &-Content {
    &__Info {
      margin-bottom: 20px;
    }

    &__Message {
      font-size: 16px;
      font-family: 'Golos Text', sans-serif;
    }
  }

  &-Total,
  &-New,
  &-Update {
    color: rgba(2, 12, 18, 0.8);
    font-size: 18px;
    font-family: 'Golos Text', sans-serif;
    font-weight: 500;
    line-height: 24px;
    letter-spacing: -0.3px;

    &:not(:last-child) {
      margin-right: 15px;
    }
  }

  &-FileInfo {
    &__File,
    &__Time {
      color: rgba(2, 12, 18, 0.8);
      font-size: 16px;
      font-family: 'Golos Text', sans-serif;
      line-height: 24px;
      letter-spacing: -0.3px;

      & > span {
        font-weight: 500;
      }
    }
  }

  &-Dialog {
    min-width: 1000px;
    background-color: rgb(245 248 251);
  }

  &-TableHeader {
    padding: 6px 0;
    color: rgba(2, 12, 18, 0.58);
    overflow: hidden;
    font-family: 'Golos Text', sans-serif;
    font-style: normal;
    font-weight: 600;
    font-size: 10px;
    line-height: 12px;
    letter-spacing: 0.05em;
    text-transform: uppercase;
  }

  &-TableRow {
    display: grid;
    grid-template-columns: 2fr 2fr 2fr 3fr;
    border-bottom: 1px solid rgba(1, 72, 116, 0.11);
    padding: 4px 0;
  }

  &-TableCell {
    color: rgba(2, 12, 18, 0.58);
    font-size: 12px;
    font-family: 'Golos UI', sans-serif;
    line-height: 14px;
    font-weight: 500;
  }

  &-ErrorString {
    &:not(:first-child) {
      padding: 2px;
    }
  }

  &-Actions {
    background-color: rgb(245 245 245);
    display: flex;
    justify-content: flex-end;
  }
}

.ImportDialog {
  &-AttentionContent {
    * {
      margin: 0;
      padding: 0;
    }

    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 30px 40px;

    &__SysInfo {
      color: #6c7276;
    }

    &__Icon {
      color: #1491cf;
      font-size: 40px;
      margin-bottom: 10px;
    }

    &__Header {
      font-family: 'Golos Text', sans-serif;
      font-style: normal;
      font-weight: 500;
      font-size: 20px;
      line-height: 24px;
      text-align: center;
      letter-spacing: -0.015em;
      color: #015e98;
      margin-bottom: 24px;
    }

    &__Noty {
      background: #e2f0ff;
      border-left: 2px solid #015e98;
      padding: 8px;

      font-family: 'Golos UI', sans-serif;
      font-style: normal;
      font-weight: 400;
      font-size: 14px;
      line-height: 16px;
      text-align: left;
      width: 100%;
      color: #015e98;
      margin-bottom: 20px;
    }
  }

  &-AttentionButtons {
    display: flex;
    justify-content: flex-end;
    padding: 12px 20px;
  }

  &-AttentionButton {
    padding: 0 10px;
  }
}
</style>

<script lang="ts">
import { Component, ModelSync, Prop, Vue } from 'vue-property-decorator';
import { RegisteredImportResult } from '@/recruits/openapi/person-registry';
import get from 'lodash/get';

@Component({ methods: { get } })
export default class ImportResultsDialog extends Vue {
  @ModelSync('value', 'change')
  public showDialog!: boolean;

  @Prop()
  public readonly result: RegisteredImportResult;

  public expansion = false;

  closeDialog(): void {
    this.showDialog = false;
  }
}
</script>
