<template>
  <div>
    <CustomSubHeader>
      <CBreadcrumb class="border-0 mb-0">{{ title }}</CBreadcrumb>
      <CButton size="sm" color="success" :to="{ name: 'admin-warranty-terms-new' }" class="mr-auto">افزودن</CButton>
    </CustomSubHeader>

    <CCard>
      <!--      <CCardHeader-->
      <!--          :dir="paginate ? 'ltr' : 'rtl'"-->
      <!--          :style="{textAlign: paginate ? 'center' : 'right'}">-->

      <!--        <el-pagination-->
      <!--            background-->
      <!--            layout="prev, pager, next"-->
      <!--            v-if="paginate"-->
      <!--            @current-change="pageNumber"-->
      <!--            :current-page="Number($route.params.page)"-->
      <!--            :page-count="Number(warranties.totalPages)"-->
      <!--        >-->
      <!--        </el-pagination>-->

      <!--        <slot name="header" v-else>-->
      <!--          <CIcon name="cil-grid"/>-->
      <!--          {{ list_title }}-->
      <!--        </slot>-->

      <!--      </CCardHeader>-->

      <CCardHeader>
        <slot name="header">
          <CIcon name="cil-grid" />
          {{ list_title }}
        </slot>
      </CCardHeader>

      <CCardBody>
        <el-table :data="transactions" style="width: 100%">
          <el-table-column type="index" label="#"> </el-table-column>

          <el-table-column prop="Description" label="پیام" width=""> </el-table-column>

          <el-table-column prop="TransNumber" label="شماره سفارش" width=""> </el-table-column>

          <el-table-column label="مشاهده" width="75" align="left">
            <template slot-scope="scope">
              <CButton
                :key="scope.row._id"
                color="success"
                variant="outline"
                :to="{ name: 'admin-transactions-item', params: { item: scope.row._id } }"
              >
                <i class="fal fa-eye"></i>
              </CButton>
            </template>
          </el-table-column>
        </el-table>
      </CCardBody>
    </CCard>
  </div>
</template>

<script>
export default {
  name: 'AddminTransactionsList',
  layout: 'admin',
  async asyncData({ $axios, error }) {
    try {
      const transactions = await $axios.get(`/api/admin/transactions`)
      return {
        transactions: transactions.data
      }
    } catch (e) {
      error({ status: 404, message: 'There is a problem here' })
    }
  },
  data() {
    return {
      title: 'فرم های گارانتی',
      list_title: 'لیست',
      transactions: null
    }
  },
  head() {
    return {
      title: this.title
    }
  },
  computed: {},
  methods: {}
}
</script>
