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

  include ../../post/components/draft-list
  include ../../post/components/list
  include ../../post/components/summary

  include ../../components/pagination-bar

  section.uk-section.uk-section-default.uk-section-small
    .uk-container.uk-container-expand
      h1 Post Author Dashboard
      div(uk-grid)
        .uk-width-2-3
          .uk-margin
            +renderSectionTitle('Your Posts')
            .content-block
              if published && Array.isArray(published.posts) && (published.posts.length > 0)
                .uk-margin
                  ul.uk-list.uk-list-divider
                    each post in published.posts
                      li
                        a(href=`/post/${post.slug}`).uk-display-block
                          div= post.title
                        .uk-article-meta
                          div(uk-grid).uk-grid-small.uk-text-small
                            .uk-width-expand
                              a(href=`/post/${post.slug}`)= moment(post.created).fromNow()

                            .uk-width-auto
                              a(href=`/post/${post._id}/edit`).uk-display-block
                                +renderButtonIcon('fa-pen', 'edit')

                            .uk-width-auto
                              a(
                                href="",
                                data-post-id= post._id,
                                data-post-title= post.title,
                                onclick="return dtp.app.deletePost(event);",
                              ).uk-display-block.uk-text-danger
                                +renderButtonIcon('fa-trash', 'delete')

                            div(style="width: 65px;")
                              span
                                i.fas.fa-eye
                              span.uk-margin-small-left= formatCount(post.stats.totalVisitCount)
                +renderPaginationBar('/author/post', published.totalPostCount)
              else
                div You have no published posts.

        .uk-width-1-3
          .uk-margin
            +renderSectionTitle('Your Drafts')
            +renderPostDraftList(drafts.posts)

          .uk-margin
            +renderSectionTitle('Archived')
            +renderPostList(archive.posts)