extends layout
block content
  .dashhead
    .dashhead-titles
      h6.dashhead-subtitle Product
      h2.dashhead-title Listings
    .btn-toolbar.dashhead-toolbar
      .btn-group
        a.btn.btn-primary-outline(href='/admin/product', type='button')
          | New Product
          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', value="#{search}", placeholder='Search products')
        span.icon.icon-magnifying-glass
    .flextable-item
  .table-full
    .table-responsive
      table.table(data-sort='table')
        thead
          tr
            th Image
            th Name
            th Description
            th Price
            th Created
            th Actions
        tbody
          if products.length
            each product in products
              tr
                td
                  img(src=product.image_url style="width: 80px;")
                td
                  =product.name
                td
                  =product.description
                td $#{product.price}
                td
                  =moment(product.date).format("YYYY-MM-DD")
                td
                  a.btn.btn-primary-outline.btn-sm(href='/admin/product/#{product._id}')
                    | View/Edit
                    span.icon.icon-pencil
                  | &nbsp;
                  a.btn.btn-primary-outline.btn-sm(href='/admin/product/delete/#{product._id}', data-remote='true', data-confirm='Are You Sure?')
                    | Delete
                    span.icon.icon-erase
                  | &nbsp;
          else
            tr
              td(colspan=7, class="text-center")
                | No products found
  .text-center
