<script setup lang="ts">
const props = defineProps({
  columns: {
    type: Array as () => any[],
    require: true,
  },
  row: {
    type: Array as () => any[],
    require: true,
  },
  isLoading: {
    type: Boolean,
    default: false,
  },
});
</script>

<template>
  <div class="q-pa-sm row col-12">
    <d-table
      ref="table"
      flat
      bordered
      :columns="props.columns"
      :rows="props.row"
      dense
      :rows-per-page-options="[10, 25, 50, 100]"
      virtual-scroll
      class="row col-12"
      :style="$q.screen.lt.sm ? 'width: 80vw' : 'width: 50vw;'"
      :pagination="{ page: 1, rowsPerPage: 10 }"
      :loading="isLoading"
      row-key="id"
    >
      <template v-slot:header="props">
        <q-tr :props="props" class="bg-grey-2">
          <q-th v-for="col in props.cols" :key="col.name" :props="props">
            <span class="text-body2 text-black">{{ col.label }}</span>
          </q-th>
        </q-tr>
      </template>

      <template v-slot:body="props">
        <q-tr :props="props">
          <q-td v-for="col in props.cols" :key="col.name" :props="props">
            <div>
              {{ !col.value ? "-" : col.value }}
            </div>
          </q-td>
        </q-tr>
      </template>
    </d-table>
  </div>
</template>

<style lang="scss" scoped></style>
