<script setup lang="ts">
// Components
import PaginationView from '~/components/pub/my-ui/pagination/pagination-view.vue'

// Types
import type { PaginationMeta } from '~/components/pub/my-ui/pagination/pagination.type'

// Configs
import { config } from './list-cfg.visit'

interface Props {
  data: any[]
  paginationMeta: PaginationMeta
}

defineProps<Props>()

const emit = defineEmits<{
  pageChange: [page: number]
  verify: [rec: any]
}>()

function handlePageChange(page: number) {
  emit('pageChange', page)
}

// Provide verify handler to child components via provide/inject
function handleVerify(rec: any) {
  emit('verify', rec)
}

provide('verify-handler', handleVerify)
</script>

<template>
  <div class="space-y-4">
    <PubMyUiDataTable
      v-bind="config"
      :rows="data"
      :skeleton-size="paginationMeta?.pageSize"
    />
    <PaginationView :pagination-meta="paginationMeta" @page-change="handlePageChange" />
  </div>
</template>

