extends layout
block content
  .dashhead
    .dashhead-titles
      h6.dashhead-subtitle Dashboards
      h2.dashhead-title Users
    .btn-toolbar.dashhead-toolbar
      .btn-group
        a.btn.btn-primary-outline(href='/admin/user', type='button')
          | Create New
          span.icon.icon-plus
  hr.m-t
  .flextable.table-actions
    .flextable-item.flextable-primary
      .btn-toolbar-item.input-with-icon
        input.form-control.input-block.model_search(type='text', name='search', value="#{search}", placeholder='Search users')
        span.icon.icon-magnifying-glass
    .flextable-item
  .table-full
    .table-responsive
      table.table(data-sort='table')
        thead
          tr
            th Email
            th Username
            th Role
            th Created
            th Actions
        tbody
          if users.length
            each user in users
              tr
                td
                  =user.email
                td
                  =user.profile.name
                td
                  =user.role
                td
                  =moment(user.created).format("YYYY-MM-DD")
                td
                  a.btn.btn-primary-outline.btn-sm(href='/admin/user/#{user._id}')
                    | Edit
                    span.icon.icon-pencil
                  | &nbsp;
                  a.btn.btn-primary-outline.btn-sm(href='/admin/user/delete/#{user._id}', data-remote='true', data-confirm='Are You Sure?')
                    | Delete
                    span.icon.icon-erase
          else
            tr
              td(colspan=7, class="text-center")
                | No users found
  .text-center
    
