|
1 | | -import type { LabManagedByAdmin } from "./schema"; |
2 | | -import type { AugmentedColumnDef } from "~/components/common/DataTable/column"; |
3 | | -import { Icon, Button } from "#components"; |
| 1 | +import type { LabManagedByAdmin } from './schema'; |
| 2 | +import type { AugmentedColumnDef } from '~/components/common/DataTable/column'; |
| 3 | +import { Icon, Button } from '#components'; |
4 | 4 |
|
5 | 5 | const formatTimetable = (timetable: Record<string, string[]>) => { |
6 | 6 | const days: Record<string, string> = { |
7 | | - "2": "Thứ 2", |
8 | | - "3": "Thứ 3", |
9 | | - "4": "Thứ 4", |
10 | | - "5": "Thứ 5", |
11 | | - "6": "Thứ 6", |
12 | | - "7": "Thứ 7", |
13 | | - "8": "Chủ nhật", |
| 7 | + '2': 'Thứ 2', |
| 8 | + '3': 'Thứ 3', |
| 9 | + '4': 'Thứ 4', |
| 10 | + '5': 'Thứ 5', |
| 11 | + '6': 'Thứ 6', |
| 12 | + '7': 'Thứ 7', |
| 13 | + '8': 'Chủ nhật', |
14 | 14 | }; |
15 | 15 |
|
16 | 16 | return Object.entries(timetable || {}).map(([day, slots]) => { |
17 | | - return h("div", { class: "mb-1" }, [ |
18 | | - h("span", { class: "font-medium" }, `${days[day]}: `), |
19 | | - h("span", {}, slots.join(", ")), |
| 17 | + return h('div', { class: 'mb-1' }, [ |
| 18 | + h('span', { class: 'font-medium' }, `${days[day]}: `), |
| 19 | + h('span', {}, slots.join(', ')), |
20 | 20 | ]); |
21 | 21 | }); |
22 | 22 | }; |
23 | 23 |
|
24 | 24 | export const columns: AugmentedColumnDef<LabManagedByAdmin>[] = [ |
25 | 25 | { |
26 | | - id: "name", |
27 | | - title: "Tên phòng", |
| 26 | + id: 'name', |
| 27 | + title: 'Tên phòng', |
28 | 28 | cell: ({ row }) => |
29 | 29 | h( |
30 | | - "div", |
| 30 | + 'div', |
31 | 31 | { |
32 | | - class: "flex items-center gap-2", |
| 32 | + class: 'flex items-center gap-2', |
33 | 33 | }, |
34 | 34 | [ |
35 | 35 | h(Icon, { |
36 | | - name: "i-heroicons-beaker", |
37 | | - class: "w-5 h-5 text-blue-500", |
| 36 | + name: 'i-heroicons-beaker', |
| 37 | + class: 'w-5 h-5 text-blue-500', |
38 | 38 | }), |
39 | | - h("span", { class: "text-gray-700 font-medium" }, row.original.name), |
| 39 | + h('span', { class: 'text-gray-700 font-medium' }, row.original.name), |
40 | 40 | ], |
41 | 41 | ), |
42 | 42 | enableSorting: true, |
43 | 43 | }, |
44 | 44 | { |
45 | | - id: "room", |
46 | | - title: "Phòng", |
47 | | - cell: ({ row }) => h("span", { class: "text-gray-600" }, row.original.room), |
| 45 | + id: 'room', |
| 46 | + title: 'Phòng', |
| 47 | + cell: ({ row }) => h('span', { class: 'text-gray-600' }, row.original.room), |
48 | 48 | enableSorting: true, |
49 | 49 | }, |
50 | 50 | { |
51 | | - id: "faculty", |
52 | | - title: "Khoa", |
| 51 | + id: 'faculty', |
| 52 | + title: 'Khoa', |
53 | 53 | cell: ({ row }) => |
54 | | - h("span", { class: "text-gray-600" }, row.original.faculty), |
| 54 | + h('span', { class: 'text-gray-600' }, row.original.faculty), |
55 | 55 | enableSorting: true, |
56 | 56 | }, |
57 | 57 | { |
58 | | - id: "branch", |
59 | | - title: "Cơ sở", |
| 58 | + id: 'branch', |
| 59 | + title: 'Cơ sở', |
60 | 60 | cell: ({ row }) => |
61 | | - h("span", { class: "text-gray-600" }, row.original.branch), |
| 61 | + h('span', { class: 'text-gray-600' }, row.original.branch), |
62 | 62 | enableSorting: true, |
63 | 63 | }, |
64 | 64 | { |
65 | | - id: "timetable", |
66 | | - title: "Lịch hoạt động", |
| 65 | + id: 'timetable', |
| 66 | + title: 'Lịch hoạt động', |
67 | 67 | cell: ({ row }) => |
68 | 68 | h( |
69 | | - "div", |
70 | | - { class: "text-sm text-gray-600" }, |
| 69 | + 'div', |
| 70 | + { class: 'text-sm text-gray-600' }, |
71 | 71 | row.original.timetable |
72 | 72 | ? formatTimetable(row.original.timetable) |
73 | | - : "Chưa có lịch", |
| 73 | + : 'Chưa có lịch', |
74 | 74 | ), |
75 | 75 | }, |
76 | 76 | { |
77 | | - id: "actions", |
78 | | - title: "Thao tác", |
| 77 | + id: 'actions', |
| 78 | + title: 'Thao tác', |
79 | 79 | cell: ({ row }) => |
80 | | - h("div", { class: "flex items-center gap-2" }, [ |
| 80 | + h('div', { class: 'flex items-center gap-2' }, [ |
81 | 81 | h( |
82 | 82 | Button, |
83 | 83 | { |
84 | | - variant: "ghost", |
85 | | - size: "icon", |
86 | | - onClick: () => console.log("Edit:", row.original), |
87 | | - class: "hover:text-blue-500", |
| 84 | + variant: 'ghost', |
| 85 | + size: 'icon', |
| 86 | + onClick: () => console.log('Edit:', row.original), |
| 87 | + class: 'hover:text-blue-500', |
88 | 88 | }, |
89 | 89 | [ |
90 | 90 | h(Icon, { |
91 | | - name: "i-heroicons-pencil-square", |
92 | | - class: "w-5 h-5", |
| 91 | + name: 'i-heroicons-pencil-square', |
| 92 | + class: 'w-5 h-5', |
93 | 93 | }), |
94 | 94 | ], |
95 | 95 | ), |
96 | 96 | h( |
97 | 97 | Button, |
98 | 98 | { |
99 | | - variant: "ghost", |
100 | | - size: "icon", |
101 | | - onClick: () => console.log("Delete:", row.original), |
102 | | - class: "hover:text-red-500", |
| 99 | + variant: 'ghost', |
| 100 | + size: 'icon', |
| 101 | + onClick: () => console.log('Delete:', row.original), |
| 102 | + class: 'hover:text-red-500', |
103 | 103 | }, |
104 | 104 | [ |
105 | 105 | h(Icon, { |
106 | | - name: "i-heroicons-trash", |
107 | | - class: "w-5 h-5", |
| 106 | + name: 'i-heroicons-trash', |
| 107 | + class: 'w-5 h-5', |
108 | 108 | }), |
109 | 109 | ], |
110 | 110 | ), |
|
0 commit comments