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

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

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

const props = defineProps<{
  data: PatientData[]
  selected?: string
  paginationMeta?: PaginationMeta
}>()

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

function handlePageChange(page: number) {
  emit('pageChange', page)
}
</script>

<template>
  <PubMyUiDataTable
    v-bind="config"
    :rows="props.data"
    :selected="props.selected"
  />
  <PaginationView
    v-if="paginationMeta"
    :pagination-meta="paginationMeta"
    @page-change="handlePageChange"
  />
</template>
