<template>
  <b-table
    class="pb-6"
    :current-page="page"
    :data="motivos"
    :loading="isLoadingTable"
    :per-page="25"
    :total="total"
    @page-change="onPageChange"
    backend-pagination
    hoverable
    paginated
    striped
  >
    <b-table-column
      field="fecha_creacion"
      label="Fecha reporte"
      v-slot="props"
      centered
    >
      <p>{{ fechaHora(props.row.fecha_creacion) }}</p>
    </b-table-column>

    <b-table-column field="motivo" label="Motivo" v-slot="props" centered>
      <p>{{ props.row.motivo }}</p>
    </b-table-column>

    <b-table-column
      field="operador"
      label="Operador que cambio el status"
      v-slot="props"
      centered
    >
      <p>{{ props.row.operador.operador }}</p>
    </b-table-column>

    <b-table-column
      field="status"
      label="Status al que se cambió"
      v-slot="props"
      centered
    >
      <p>{{ props.row.status.status }}</p>
    </b-table-column>
  </b-table>
</template>

<script>
import moment from 'moment'

export default {
  props: {
    motivos: { type: Array, required: true, default: () => [] },
    isLoadingTable: { type: Boolean, required: true, default: false },
    onPageChange: { type: Function, required: true, default: () => {} },
    page: { type: Number, required: true, default: 0 },
    total: { type: Number, required: true, default: 0 },
  },
  methods: {
    fechaHora(date) {
      return moment(date).format('YYYY-MM-DD HH:MM')
    },
  },
}
</script>
