PendingProvidersTable.vue 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. <template>
  2. <div class="q-mb-lg">
  3. <div class="text-h6 text-weight-bold q-mb-sm">
  4. {{ $t('provider.approval.pending_table_title') }}
  5. </div>
  6. <DefaultTableServerSide
  7. ref="tableRef"
  8. class="bg-surface-light"
  9. :columns="columns"
  10. :api-call="getPendingProviders"
  11. :add-item="false"
  12. :show-search-field="false"
  13. :open-item="true"
  14. @on-row-click="onRowClick"
  15. >
  16. <template #body-cell-name="slotProps">
  17. <q-td :props="slotProps">
  18. {{ slotProps.row.user?.name || '—' }}
  19. </q-td>
  20. </template>
  21. <template #body-cell-approval_status="slotProps">
  22. <q-td :props="slotProps">
  23. <q-badge color="warning" :label="$t(`provider.approval_status.${slotProps.row.approval_status}`)" />
  24. </q-td>
  25. </template>
  26. <template #body-cell-created_at="slotProps">
  27. <q-td :props="slotProps">
  28. {{ formatDate(slotProps.row.created_at) }}
  29. </q-td>
  30. </template>
  31. <template #body-cell-actions="slotProps">
  32. <q-td :props="slotProps" class="text-right">
  33. <q-btn
  34. flat
  35. dense
  36. round
  37. icon="mdi-eye-outline"
  38. color="primary"
  39. @click.stop="onRowClick({ row: slotProps.row })"
  40. >
  41. <q-tooltip>{{ $t('common.actions.view') }}</q-tooltip>
  42. </q-btn>
  43. </q-td>
  44. </template>
  45. </DefaultTableServerSide>
  46. </div>
  47. </template>
  48. <script setup>
  49. import { defineAsyncComponent, ref } from 'vue';
  50. import { useQuasar } from 'quasar';
  51. import { useI18n } from 'vue-i18n';
  52. import { getPendingProviders } from 'src/api/provider';
  53. import DefaultTableServerSide from 'src/components/defaults/DefaultTableServerSide.vue';
  54. import { format, parseISO } from 'date-fns';
  55. const ProviderApprovalDialog = defineAsyncComponent(
  56. () => import('src/pages/dashboard/components/ProviderApprovalDialog.vue'),
  57. );
  58. const $q = useQuasar();
  59. const { t } = useI18n();
  60. const tableRef = ref(null);
  61. const columns = [
  62. { name: 'name', label: t('common.terms.name'), field: (row) => row.user?.name || '—', align: 'left', sortable: false, style: 'width: 25%' },
  63. { name: 'document', label: t('provider.fields.document'), field: 'document', align: 'left', sortable: false, style: 'width: 25%' },
  64. { name: 'created_at', label: t('common.terms.created_at'), field: 'created_at', align: 'left', sortable: false, style: 'width: 25%' },
  65. { name: 'approval_status', label: t('provider.fields.approval_status'), field: 'approval_status', align: 'left', sortable: false, style: 'width: 25%' },
  66. { name: 'actions', label: '', field: 'actions', align: 'right', sortable: false, style: 'width: 25%' },
  67. ];
  68. const formatDate = (value) => {
  69. if (!value) return '—';
  70. try { return format(parseISO(value), 'dd/MM/yyyy HH:mm'); } catch { return value; }
  71. };
  72. const onRowClick = ({ row }) => {
  73. $q.dialog({
  74. component: ProviderApprovalDialog,
  75. componentProps: { provider: row },
  76. }).onOk(() => tableRef.value?.refresh());
  77. };
  78. </script>