|
| 1 | +<script setup lang="ts"> |
| 2 | + import { h, resolveComponent } from 'vue' |
| 3 | + import type { TableColumn } from '@nuxt/ui' |
| 4 | +
|
| 5 | + const UBadge = resolveComponent('UBadge') |
| 6 | + const { data: rides, status } = await useFetch('/api/get/rides') |
| 7 | +
|
| 8 | + const columns: TableColumn<any>[] = [ |
| 9 | + { |
| 10 | + accessorKey: 'status', |
| 11 | + header: 'Status', |
| 12 | + cell: ({ row }) => { |
| 13 | + const color = |
| 14 | + { |
| 15 | + CREATED: 'info' as const, |
| 16 | + ASSIGNED: 'warning' as const, |
| 17 | + COMPLETED: 'success' as const, |
| 18 | + CANCELLED: 'error' as const, |
| 19 | + }[row.getValue('status') as string] || 'neutral' |
| 20 | +
|
| 21 | + return h(UBadge, { class: 'capitalize', variant: 'subtle', color }, () => |
| 22 | + row.getValue('status') |
| 23 | + ) |
| 24 | + }, |
| 25 | + }, |
| 26 | + { |
| 27 | + accessorKey: 'scheduledTime', |
| 28 | + header: 'Date', |
| 29 | + cell: ({ row }) => { |
| 30 | + return new Date(row.getValue('scheduledTime')).toLocaleString('en-US', { |
| 31 | + day: 'numeric', |
| 32 | + month: 'short', |
| 33 | + year: 'numeric', |
| 34 | + hour: '2-digit', |
| 35 | + minute: '2-digit', |
| 36 | + }) |
| 37 | + }, |
| 38 | + }, |
| 39 | + { |
| 40 | + accessorKey: 'client.user.name', |
| 41 | + header: 'Client', |
| 42 | + }, |
| 43 | + { |
| 44 | + accessorKey: 'pickupDisplay', |
| 45 | + header: 'Pickup', |
| 46 | + }, |
| 47 | + { |
| 48 | + accessorKey: 'dropoffDisplay', |
| 49 | + header: 'Dropoff', |
| 50 | + }, |
| 51 | + ] |
| 52 | +</script> |
| 53 | + |
1 | 54 | <template> |
2 | 55 | <UContainer class="py-10"> |
3 | | - <UPageHeader title="Rides" description="Manage and view all rides." /> |
4 | 56 | <UPageBody> |
5 | | - <div |
6 | | - class="flex h-64 items-center justify-center rounded-lg border-2 border-dashed border-gray-300" |
7 | | - > |
8 | | - <p class="text-lg text-gray-500">Rides management coming soon...</p> |
9 | | - </div> |
| 57 | + <UTable |
| 58 | + :data="rides || []" |
| 59 | + :columns="columns" |
| 60 | + :loading="status === 'pending'" |
| 61 | + class="w-full" |
| 62 | + /> |
10 | 63 | </UPageBody> |
11 | 64 | </UContainer> |
12 | 65 | </template> |
0 commit comments