extends ../../layouts/main
block content

  include ../components/list-item

  form(method="POST", action=`/admin/user/archive/${archive._id}/action`).uk-form
    .uk-card.uk-card-default.uk-card-small
      .uk-card-header
        h1.uk-card-title
          span
            i.fas.fa-id-card
          span.uk-margin-small-left User Archive

      .uk-card-body
        .uk-margin
          div(uk-grid)
            .uk-width-auto
              .uk-form-label Archive ID
              .uk-text-bold= archive._id
            .uk-width-auto
              .uk-form-label Created
              .uk-text-bold= moment(archive.created).format('MMMM DD, YYYY, [at] h:mm:ss a')
            .uk-width-auto
              .uk-form-label User
              .uk-text-bold= archive.user.username
            .uk-width-auto
              .uk-form-label User ID
              .uk-text-bold= archive.user._id
            .uk-width-auto
              .uk-form-label User email
              .uk-text-bold= archive.user.email

          if archive.archive
            div(uk-grid)
              .uk-width-auto
                .uk-form-label Archive file
                .uk-text-bold= archive.archive.key.replace(/\/user-archive\//, '')
              .uk-width-auto
                .uk-form-label Download size
                .uk-text-bold= numeral(archive.archive.size).format('0,0.0a')
          else
            .uk-text-italic (archive file removed)

        .uk-margin
          label(for="notes").uk-form-label Notes
          textarea(id="notes", name="notes", rows="4", placeholder="Enter notes").uk-textarea.uk-resize-vertical= archive.notes

      .uk-card-footer
        div(uk-grid)
          .uk-width-expand
            div(hidden= !archive.archive, uk-grid)
              .uk-width-auto
                a(href=`/admin/user/archive/${archive._id}/file`).uk-button.uk-button-default.uk-border-rounded
                  span
                    i.fas.fa-download
                  span.uk-margin-small-left Download#[span(class="uk-visible@s")  File]
              .uk-width-auto
                button(
                  type="submit",
                  name="action",
                  value="delete-file",
                  uk-tooltip={ title: 'Remove the .zip file attached to the UserArchive' },
                ).uk-button.uk-button-danger.uk-border-rounded
                  span
                    i.fas.fa-trash
                  span.uk-margin-small-left Delete#[span(class="uk-visible@s")  File]

          .uk-width-auto
            button(
              type="submit",
              name="action",
              value="delete",
              uk-tooltip={ title: 'Remove the UserArchive from the database' },
              ).uk-button.uk-button-danger.uk-border-rounded
              span
                i.fas.fa-save
              span.uk-margin-small-left Delete

          .uk-width-auto
            button(type="submit", name="action", value="update").uk-button.uk-button-primary.uk-border-rounded
              span
                i.fas.fa-save
              span.uk-margin-small-left Update