extends ../layouts/main
block content

  include ../components/pagination-bar

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

  include ../comment/components/comment

  if (user.permissions.canAuthorPosts && user.permissions.canPublishPosts || user.flags.isAdmin)
    section.uk-section.uk-section-default.uk-section-xsmall
      .uk-container.uk-container-expand
        div(uk-grid).uk-flex-middle
          .uk-width-expand
            h1.uk-margin-remove Author Dashboard
          .uk-width-auto
            a(href= "/post/compose").uk-button.uk-button-primary.uk-border-rounded
              span
                i.fas.fa-plus
              span.uk-margin-small-left.uk-text-bold Create Post
        div(uk-grid)
          if authorComments.length > 0
            div(class="uk-width-1-1 uk-width-2-3@m")
              +renderSectionTitle('Recent Comments', { url: '/author/comments', title: 'See All', label: 'SEE ALL' })
                .content-block
                  .uk-margin
                    ul#post-comment-list.uk-list.uk-list-divider.uk-list-large.uk-margin
                      each comment in authorComments
                        li
                          .uk-margin
                            a(href=`/post/${comment.resource.slug}`).uk-display-block.uk-link-reset
                              +renderPostSummary(comment.resource)
                          +renderComment(comment, { })
                    
                  +renderPaginationBar('/author', published.totalPostCount)
          else
            div(class="uk-width-1-1 uk-width-2-3@m")
              +renderSectionTitle('Comments')
              div There are no comments.

          div(class="uk-width-1-1 uk-width-1-3@m")
            .uk-margin
              if (drafts && drafts.length > 0)
                +renderSectionTitle('Drafts', { url: '/author/drafts', title: 'See All', label: 'SEE ALL' })
                +renderPostDraftList(drafts)
              else
                +renderSectionTitle('Drafts')
                +renderPostDraftList(drafts)

            .uk-margin
              if (published && published.length > 0)
                +renderSectionTitle('Posts', { url: '/author/posts', title: 'See All', label: 'SEE ALL' })
                +renderPostList(published)
              else
                +renderSectionTitle('Posts')
                +renderPostList(published)
  
  else if user.permissions.canAuthorPosts
    section.uk-section.uk-section-default.uk-section-xsmall
      .uk-container.uk-container-expand
        div(uk-grid).uk-flex-middle
          .uk-width-expand
            h1.uk-margin-remove Author Dashboard
          .uk-width-auto
            a(href= "/post/compose").uk-button.uk-button-primary.uk-border-rounded
              span
                i.fas.fa-plus
              span.uk-margin-small-left.uk-text-bold Create Post
        div(uk-grid)
          if authorComments.comments.length > 0
            div(class="uk-width-1-1 uk-width-2-3@m")
              +renderSectionTitle('Recent Comments', { url: '/author/comments', title: 'See All', label: 'SEE ALL' })
                .content-block
                  .uk-margin
                    ul#post-comment-list.uk-list.uk-list-divider.uk-list-large.uk-margin
                      each comment in authorComments.comments
                        li
                          .uk-margin
                            a(href=`/post/${comment.resource.slug}`).uk-display-block.uk-link-reset
                              +renderPostSummary(comment.resource)
                          +renderComment(comment, { })
                    
                  +renderPaginationBar('/author', published.totalPostCount)
          else
            div(class="uk-width-1-1 uk-width-2-3@m")
              +renderSectionTitle('Comments')
              div There are no comments.

          div(class="uk-width-1-1 uk-width-1-3@m")
            .uk-margin
              if (drafts && drafts.length > 0)
                +renderSectionTitle('Drafts', { url: '/author/drafts', title: 'See All', label: 'SEE ALL' })
                +renderPostDraftList(drafts)
              else
                +renderSectionTitle('Drafts')
                +renderPostDraftList(drafts)

            .uk-margin
              if (published && published.length > 0)
                +renderSectionTitle('Posts', { url: '/author/posts', title: 'See All', label: 'SEE ALL' })
                +renderPostList(published)
              else
                +renderSectionTitle('Posts')
                +renderPostList(published)

  else if user.permissions.canPublishPosts
    section.uk-section.uk-section-default.uk-section-xsmall
      .uk-container.uk-container-expand
        div(uk-grid).uk-flex-middle
          .uk-width-expand
            h1.uk-margin-remove Author Dashboard
          .uk-width-auto
            a(href= "/author/drafts").uk-button.uk-button-primary.uk-border-rounded
              .uk-margin-small-middle.uk-text-bold View Drafts
          .uk-width-medium
            a(href= "/author/posts").uk-button.uk-button-primary.uk-border-rounded
              .uk-margin-small-middle.uk-text-bold View Posts            
        .uk-margin
         div(class="uk-width-1-1 uk-width-3-3@m")
            .uk-margin
              +renderSectionTitle('All Posts')
              +renderPostList(posts)