<script setup lang="ts">
import type { PaginationMeta } from '~/components/pub/my-ui/pagination/pagination.type'
import PaginationView from '~/components/pub/my-ui/pagination/pagination-view.vue'
import { config as configDoctor } from './list-doctor.cfg'
import { config as configNursePhysio } from './list-nurse-physio.cfg'

const props = withDefaults(defineProps<{
  data: any[]
  paginationMeta: PaginationMeta
}>(), {
  
})

const { user, } = useUserStore()
const tableConfig = computed(() => {
  if(user.activeRole === 'emp|doc' || user.activeRole === 'system') {
    return configDoctor
  } else {
    return configNursePhysio
  }
})

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

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

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