wad-lab 1.1.6 → 1.1.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (93) hide show
  1. package/package.json +1 -1
  2. package/templates/fullstack-springboot-vue/backend/src/main/java/com/example/company/controller/CompanyController.java +88 -74
  3. package/templates/fullstack-springboot-vue/backend/src/main/java/com/example/company/model/Employee.java +73 -73
  4. package/templates/fullstack-springboot-vue/backend/src/main/java/com/example/company/service/CompanyService.java +90 -60
  5. package/templates/fullstack-springboot-vue/frontend/vue-axios-basic/src/App.vue +429 -405
  6. package/templates/fullstack-springboot-vue/frontend/vue-axios-interceptor/src/App.vue +177 -159
  7. package/templates/fullstack-springboot-vue/frontend/vue-axios-pinia/src/App.vue +441 -427
  8. package/templates/fullstack-springboot-vue/frontend/vue-axios-pinia/src/stores/companyStore.js +126 -96
  9. package/templates/fullstack-springboot-vue/frontend/vue-axios-pinia-props/src/App.vue +84 -69
  10. package/templates/fullstack-springboot-vue/frontend/vue-axios-pinia-props/src/components/DepartmentSection.vue +164 -152
  11. package/templates/fullstack-springboot-vue/frontend/vue-axios-pinia-props/src/components/EmployeeSection.vue +193 -181
  12. package/templates/fullstack-springboot-vue/frontend/vue-axios-pinia-props/src/stores/companyStore.js +126 -35
  13. package/templates/fullstack-springboot-vue/frontend/vue-axios-props-emits/src/App.vue +191 -167
  14. package/templates/fullstack-springboot-vue/frontend/vue-axios-props-emits/src/components/DepartmentForm.vue +98 -98
  15. package/templates/fullstack-springboot-vue/frontend/vue-axios-props-emits/src/components/DepartmentList.vue +92 -91
  16. package/templates/fullstack-springboot-vue/frontend/vue-axios-props-emits/src/components/EmployeeForm.vue +128 -128
  17. package/templates/fullstack-springboot-vue/frontend/vue-axios-props-emits/src/components/EmployeeList.vue +95 -94
  18. package/templates/fullstack-springboot-vue/frontend/vue-axios-router/src/App.vue +90 -90
  19. package/templates/fullstack-springboot-vue/frontend/vue-axios-router/src/views/AddEmployeeView.vue +247 -247
  20. package/templates/fullstack-springboot-vue/frontend/vue-axios-router/src/views/DepartmentView.vue +296 -273
  21. package/templates/fullstack-springboot-vue/frontend/vue-axios-router/src/views/EmployeeView.vue +219 -196
  22. package/templates/fullstack-springboot-vue/frontend/vue-axios-router/src/views/HomeDashboardView.vue +263 -263
  23. package/templates/fullstack-springboot-vue/frontend/vue-axios-router-children/src/views/DepartmentListView.vue +250 -231
  24. package/templates/fullstack-springboot-vue/frontend/vue-axios-router-children/src/views/EmployeeDetailView.vue +181 -159
  25. package/templates/fullstack-springboot-vue/frontend/vue-axios-router-children/src/views/EmployeeListView.vue +315 -295
  26. package/templates/fullstack-springboot-vue/frontend/vue-axios-router-pinia/src/stores/companyStore.js +137 -70
  27. package/templates/fullstack-springboot-vue/frontend/vue-axios-router-pinia/src/views/DepartmentView.vue +229 -209
  28. package/templates/fullstack-springboot-vue/frontend/vue-axios-router-pinia/src/views/EmployeeView.vue +257 -237
  29. package/templates/fullstack-springboot-vue/frontend/vue-axios-router-pinia-props/src/components/EntityTable.vue +106 -92
  30. package/templates/fullstack-springboot-vue/frontend/vue-axios-router-pinia-props/src/stores/companyStore.js +139 -84
  31. package/templates/fullstack-springboot-vue/frontend/vue-axios-router-pinia-props/src/views/ManageDepartmentsView.vue +73 -64
  32. package/templates/fullstack-springboot-vue/frontend/vue-axios-router-pinia-props/src/views/ManageEmployeesView.vue +76 -67
  33. package/templates/fullstack-springboot-vue/frontend/vue-axios-router-props/src/App.vue +59 -59
  34. package/templates/fullstack-springboot-vue/frontend/vue-axios-router-props/src/components/DataCard.vue +72 -53
  35. package/templates/fullstack-springboot-vue/frontend/vue-axios-router-props/src/views/DepartmentPage.vue +89 -77
  36. package/templates/fullstack-springboot-vue/frontend/vue-axios-router-props/src/views/EmployeePage.vue +128 -116
  37. package/templates/springboot-2model-1controller-api/src/main/java/com/example/company/controller/CompanyController.java +88 -74
  38. package/templates/springboot-2model-1controller-api/src/main/java/com/example/company/model/Employee.java +73 -73
  39. package/templates/springboot-2model-1controller-api/src/main/java/com/example/company/service/CompanyService.java +90 -60
  40. package/templates/springboot-course-registration/src/main/java/com/example/coursereg/controller/CourseController.java +46 -42
  41. package/templates/springboot-course-registration/src/main/java/com/example/coursereg/service/CourseService.java +70 -60
  42. package/templates/springboot-hospital-api/src/main/java/com/example/hospital/controller/HospitalController.java +54 -50
  43. package/templates/springboot-hospital-api/src/main/java/com/example/hospital/service/HospitalService.java +65 -54
  44. package/templates/springboot-library-api/src/main/java/com/example/library/controller/LibraryController.java +57 -51
  45. package/templates/springboot-library-api/src/main/java/com/example/library/service/LibraryService.java +70 -60
  46. package/templates/springboot-mockmvc/src/main/java/com/example/mockmvc/controller/ItemController.java +45 -41
  47. package/templates/springboot-mockmvc/src/main/java/com/example/mockmvc/service/ItemService.java +48 -38
  48. package/templates/springboot-mongo-aggregation/src/main/java/com/example/aggregation/controller/ItemController.java +45 -41
  49. package/templates/springboot-mongo-aggregation/src/main/java/com/example/aggregation/service/ItemService.java +48 -38
  50. package/templates/springboot-mongo-aggregation-mockmvc/src/main/java/com/example/aggmockmvc/controller/ItemController.java +45 -41
  51. package/templates/springboot-mongo-aggregation-mockmvc/src/main/java/com/example/aggmockmvc/service/ItemService.java +48 -38
  52. package/templates/springboot-mongo-crud/src/main/java/com/example/crud/controller/ItemController.java +45 -41
  53. package/templates/springboot-mongo-crud/src/main/java/com/example/crud/service/ItemService.java +48 -38
  54. package/templates/vue-axios/src/App.vue +264 -243
  55. package/templates/vue-axios/src/services/ItemService.js +27 -21
  56. package/templates/vue-axios-basic/src/App.vue +24 -0
  57. package/templates/vue-axios-interceptor/src/App.vue +177 -159
  58. package/templates/vue-axios-pinia/src/App.vue +14 -0
  59. package/templates/vue-axios-pinia/src/stores/companyStore.js +126 -96
  60. package/templates/vue-axios-pinia-props/src/App.vue +84 -69
  61. package/templates/vue-axios-pinia-props/src/components/DepartmentSection.vue +164 -152
  62. package/templates/vue-axios-pinia-props/src/components/EmployeeSection.vue +193 -181
  63. package/templates/vue-axios-pinia-props/src/stores/companyStore.js +126 -35
  64. package/templates/vue-axios-props-emits/src/App.vue +24 -0
  65. package/templates/vue-axios-props-emits/src/components/DepartmentList.vue +2 -1
  66. package/templates/vue-axios-props-emits/src/components/EmployeeList.vue +2 -1
  67. package/templates/vue-axios-router/src/views/DepartmentView.vue +23 -0
  68. package/templates/vue-axios-router/src/views/EmployeeView.vue +23 -0
  69. package/templates/vue-axios-router-children/src/views/DepartmentListView.vue +250 -231
  70. package/templates/vue-axios-router-children/src/views/EmployeeDetailView.vue +181 -159
  71. package/templates/vue-axios-router-children/src/views/EmployeeListView.vue +315 -295
  72. package/templates/vue-axios-router-pinia/src/stores/companyStore.js +137 -70
  73. package/templates/vue-axios-router-pinia/src/views/DepartmentView.vue +229 -209
  74. package/templates/vue-axios-router-pinia/src/views/EmployeeView.vue +257 -237
  75. package/templates/vue-axios-router-pinia-props/src/components/EntityTable.vue +106 -92
  76. package/templates/vue-axios-router-pinia-props/src/stores/companyStore.js +139 -84
  77. package/templates/vue-axios-router-pinia-props/src/views/ManageDepartmentsView.vue +73 -64
  78. package/templates/vue-axios-router-pinia-props/src/views/ManageEmployeesView.vue +76 -67
  79. package/templates/vue-axios-router-props/src/components/DataCard.vue +72 -53
  80. package/templates/vue-axios-router-props/src/views/DepartmentPage.vue +89 -77
  81. package/templates/vue-axios-router-props/src/views/EmployeePage.vue +128 -116
  82. package/templates/vue-fetch/src/App.vue +285 -259
  83. package/templates/vue-router-pinia-springboot/backend/src/main/java/com/example/crud/controller/ItemController.java +45 -41
  84. package/templates/vue-router-pinia-springboot/backend/src/main/java/com/example/crud/service/ItemService.java +45 -35
  85. package/templates/vue-router-pinia-springboot/frontend/src/services/ItemService.js +24 -21
  86. package/templates/vue-router-pinia-springboot/frontend/src/stores/itemStore.js +42 -37
  87. package/templates/vue-router-pinia-springboot/frontend/src/views/ListView.vue +76 -67
  88. package/templates/vue-springboot-mongo-aggregation/backend/src/main/java/com/example/aggregation/controller/ItemController.java +45 -41
  89. package/templates/vue-springboot-mongo-aggregation/backend/src/main/java/com/example/aggregation/service/ItemService.java +45 -35
  90. package/templates/vue-springboot-mongo-crud/backend/src/main/java/com/example/crud/controller/ItemController.java +45 -41
  91. package/templates/vue-springboot-mongo-crud/backend/src/main/java/com/example/crud/service/ItemService.java +45 -35
  92. package/templates/vue-springboot-mongo-crud/frontend/src/App.vue +158 -149
  93. package/templates/vue-springboot-mongo-crud/frontend/src/services/ItemService.js +24 -21
@@ -1,91 +1,92 @@
1
- <template>
2
- <div class="table-wrapper">
3
- <table>
4
- <thead>
5
- <tr>
6
- <th>ID</th>
7
- <th>Name</th>
8
- <th>Code</th>
9
- <th>Action</th>
10
- </tr>
11
- </thead>
12
- <tbody>
13
- <tr v-if="departments.length === 0">
14
- <td colspan="4" class="empty">No departments found</td>
15
- </tr>
16
- <tr v-for="dept in departments" :key="dept.id">
17
- <td>{{ dept.id }}</td>
18
- <td>{{ dept.name }}</td>
19
- <td><code>{{ dept.code }}</code></td>
20
- <td>
21
- <button @click="emit('delete-department', dept.id)" class="btn btn-danger">Delete</button>
22
- </td>
23
- </tr>
24
- </tbody>
25
- </table>
26
- </div>
27
- </template>
28
-
29
- <script setup>
30
- defineProps(['departments'])
31
- const emit = defineEmits(['delete-department'])
32
- </script>
33
-
34
- <style scoped>
35
- .table-wrapper {
36
- overflow-x: auto;
37
- }
38
-
39
- table {
40
- width: 100%;
41
- border-collapse: collapse;
42
- font-size: 13px;
43
- margin-top: 8px;
44
- }
45
-
46
- th, td {
47
- text-align: left;
48
- padding: 8px 10px;
49
- border-bottom: 1px solid #eeeeee;
50
- }
51
-
52
- th {
53
- background-color: #fafbfc;
54
- color: #555555;
55
- font-weight: 600;
56
- }
57
-
58
- code {
59
- background: #f0f0f0;
60
- padding: 2px 4px;
61
- border-radius: 3px;
62
- font-size: 12px;
63
- }
64
-
65
- .empty {
66
- text-align: center;
67
- color: #888888;
68
- padding: 16px;
69
- }
70
-
71
- .btn {
72
- padding: 8px 14px;
73
- border: none;
74
- border-radius: 4px;
75
- cursor: pointer;
76
- font-size: 13px;
77
- font-weight: 600;
78
- transition: background-color 0.15s ease;
79
- }
80
-
81
- .btn-danger {
82
- background-color: #d9383a;
83
- color: #ffffff;
84
- padding: 4px 8px;
85
- font-size: 12px;
86
- }
87
-
88
- .btn-danger:hover {
89
- background-color: #b8282a;
90
- }
91
- </style>
1
+ <template>
2
+ <div class="table-wrapper">
3
+ <table>
4
+ <thead>
5
+ <tr>
6
+ <th>ID</th>
7
+ <th>Name</th>
8
+ <th>Code</th>
9
+ <th>Action</th>
10
+ </tr>
11
+ </thead>
12
+ <tbody>
13
+ <tr v-if="departments.length === 0">
14
+ <td colspan="4" class="empty">No departments found</td>
15
+ </tr>
16
+ <tr v-for="dept in departments" :key="dept.id">
17
+ <td>{{ dept.id }}</td>
18
+ <td>{{ dept.name }}</td>
19
+ <td><code>{{ dept.code }}</code></td>
20
+ <td>
21
+ <button @click="emit('patch-department', dept.id, dept.code)" class="btn">Patch</button>
22
+ <button @click="emit('delete-department', dept.id)" class="btn btn-danger">Delete</button>
23
+ </td>
24
+ </tr>
25
+ </tbody>
26
+ </table>
27
+ </div>
28
+ </template>
29
+
30
+ <script setup>
31
+ defineProps(['departments'])
32
+ const emit = defineEmits(['delete-department', 'patch-department'])
33
+ </script>
34
+
35
+ <style scoped>
36
+ .table-wrapper {
37
+ overflow-x: auto;
38
+ }
39
+
40
+ table {
41
+ width: 100%;
42
+ border-collapse: collapse;
43
+ font-size: 13px;
44
+ margin-top: 8px;
45
+ }
46
+
47
+ th, td {
48
+ text-align: left;
49
+ padding: 8px 10px;
50
+ border-bottom: 1px solid #eeeeee;
51
+ }
52
+
53
+ th {
54
+ background-color: #fafbfc;
55
+ color: #555555;
56
+ font-weight: 600;
57
+ }
58
+
59
+ code {
60
+ background: #f0f0f0;
61
+ padding: 2px 4px;
62
+ border-radius: 3px;
63
+ font-size: 12px;
64
+ }
65
+
66
+ .empty {
67
+ text-align: center;
68
+ color: #888888;
69
+ padding: 16px;
70
+ }
71
+
72
+ .btn {
73
+ padding: 8px 14px;
74
+ border: none;
75
+ border-radius: 4px;
76
+ cursor: pointer;
77
+ font-size: 13px;
78
+ font-weight: 600;
79
+ transition: background-color 0.15s ease;
80
+ }
81
+
82
+ .btn-danger {
83
+ background-color: #d9383a;
84
+ color: #ffffff;
85
+ padding: 4px 8px;
86
+ font-size: 12px;
87
+ }
88
+
89
+ .btn-danger:hover {
90
+ background-color: #b8282a;
91
+ }
92
+ </style>
@@ -1,128 +1,128 @@
1
- <template>
2
- <form @submit.prevent="handleSubmit" class="form">
3
- <div class="form-group">
4
- <label for="emp-name">Full Name</label>
5
- <input
6
- id="emp-name"
7
- v-model="empForm.name"
8
- type="text"
9
- required
10
- placeholder="e.g. Jane Doe"
11
- />
12
- </div>
13
- <div class="form-group">
14
- <label for="emp-email">Email Address</label>
15
- <input
16
- id="emp-email"
17
- v-model="empForm.email"
18
- type="email"
19
- required
20
- placeholder="e.g. jane@example.com"
21
- />
22
- </div>
23
- <div class="form-group">
24
- <label for="emp-dept">Department</label>
25
- <select id="emp-dept" v-model="empForm.departmentId" required>
26
- <option value="" disabled>Select Department</option>
27
- <option v-for="dept in departments" :key="dept.id" :value="dept.id">
28
- {{ dept.name }} ({{ dept.code }})
29
- </option>
30
- </select>
31
- </div>
32
- <div class="form-group">
33
- <label for="emp-salary">Salary</label>
34
- <input
35
- id="emp-salary"
36
- v-model.number="empForm.salary"
37
- type="number"
38
- min="0"
39
- step="any"
40
- required
41
- placeholder="e.g. 75000"
42
- />
43
- </div>
44
- <button type="submit" class="btn btn-primary">Add Employee</button>
45
- </form>
46
- </template>
47
-
48
- <script setup>
49
- import { reactive } from 'vue'
50
-
51
- defineProps(['departments'])
52
- const emit = defineEmits(['create-employee'])
53
-
54
- const empForm = reactive({
55
- name: '',
56
- email: '',
57
- departmentId: '',
58
- salary: ''
59
- })
60
-
61
- const handleSubmit = () => {
62
- emit('create-employee', {
63
- name: empForm.name,
64
- email: empForm.email,
65
- departmentId: empForm.departmentId,
66
- salary: Number(empForm.salary)
67
- })
68
- empForm.name = ''
69
- empForm.email = ''
70
- empForm.departmentId = ''
71
- empForm.salary = ''
72
- }
73
- </script>
74
-
75
- <style scoped>
76
- .form {
77
- display: flex;
78
- flex-direction: column;
79
- gap: 12px;
80
- margin-bottom: 20px;
81
- }
82
-
83
- .form-group {
84
- display: flex;
85
- flex-direction: column;
86
- gap: 4px;
87
- }
88
-
89
- .form-group label {
90
- font-size: 13px;
91
- font-weight: 600;
92
- color: #444444;
93
- }
94
-
95
- .form-group input,
96
- .form-group select {
97
- padding: 8px 10px;
98
- border: 1px solid #cccccc;
99
- border-radius: 4px;
100
- font-size: 14px;
101
- background-color: #ffffff;
102
- }
103
-
104
- .form-group input:focus,
105
- .form-group select:focus {
106
- outline: none;
107
- border-color: #0066cc;
108
- }
109
-
110
- .btn {
111
- padding: 8px 14px;
112
- border: none;
113
- border-radius: 4px;
114
- cursor: pointer;
115
- font-size: 13px;
116
- font-weight: 600;
117
- transition: background-color 0.15s ease;
118
- }
119
-
120
- .btn-primary {
121
- background-color: #0066cc;
122
- color: #ffffff;
123
- }
124
-
125
- .btn-primary:hover {
126
- background-color: #0052a3;
127
- }
128
- </style>
1
+ <template>
2
+ <form @submit.prevent="handleSubmit" class="form">
3
+ <div class="form-group">
4
+ <label for="emp-name">Full Name</label>
5
+ <input
6
+ id="emp-name"
7
+ v-model="empForm.name"
8
+ type="text"
9
+ required
10
+ placeholder="e.g. Jane Doe"
11
+ />
12
+ </div>
13
+ <div class="form-group">
14
+ <label for="emp-email">Email Address</label>
15
+ <input
16
+ id="emp-email"
17
+ v-model="empForm.email"
18
+ type="email"
19
+ required
20
+ placeholder="e.g. jane@example.com"
21
+ />
22
+ </div>
23
+ <div class="form-group">
24
+ <label for="emp-dept">Department</label>
25
+ <select id="emp-dept" v-model="empForm.departmentId" required>
26
+ <option value="" disabled>Select Department</option>
27
+ <option v-for="dept in departments" :key="dept.id" :value="dept.id">
28
+ {{ dept.name }} ({{ dept.code }})
29
+ </option>
30
+ </select>
31
+ </div>
32
+ <div class="form-group">
33
+ <label for="emp-salary">Salary</label>
34
+ <input
35
+ id="emp-salary"
36
+ v-model.number="empForm.salary"
37
+ type="number"
38
+ min="0"
39
+ step="any"
40
+ required
41
+ placeholder="e.g. 75000"
42
+ />
43
+ </div>
44
+ <button type="submit" class="btn btn-primary">Add Employee</button>
45
+ </form>
46
+ </template>
47
+
48
+ <script setup>
49
+ import { reactive } from 'vue'
50
+
51
+ defineProps(['departments'])
52
+ const emit = defineEmits(['create-employee'])
53
+
54
+ const empForm = reactive({
55
+ name: '',
56
+ email: '',
57
+ departmentId: '',
58
+ salary: ''
59
+ })
60
+
61
+ const handleSubmit = () => {
62
+ emit('create-employee', {
63
+ name: empForm.name,
64
+ email: empForm.email,
65
+ departmentId: empForm.departmentId,
66
+ salary: Number(empForm.salary)
67
+ })
68
+ empForm.name = ''
69
+ empForm.email = ''
70
+ empForm.departmentId = ''
71
+ empForm.salary = ''
72
+ }
73
+ </script>
74
+
75
+ <style scoped>
76
+ .form {
77
+ display: flex;
78
+ flex-direction: column;
79
+ gap: 12px;
80
+ margin-bottom: 20px;
81
+ }
82
+
83
+ .form-group {
84
+ display: flex;
85
+ flex-direction: column;
86
+ gap: 4px;
87
+ }
88
+
89
+ .form-group label {
90
+ font-size: 13px;
91
+ font-weight: 600;
92
+ color: #444444;
93
+ }
94
+
95
+ .form-group input,
96
+ .form-group select {
97
+ padding: 8px 10px;
98
+ border: 1px solid #cccccc;
99
+ border-radius: 4px;
100
+ font-size: 14px;
101
+ background-color: #ffffff;
102
+ }
103
+
104
+ .form-group input:focus,
105
+ .form-group select:focus {
106
+ outline: none;
107
+ border-color: #0066cc;
108
+ }
109
+
110
+ .btn {
111
+ padding: 8px 14px;
112
+ border: none;
113
+ border-radius: 4px;
114
+ cursor: pointer;
115
+ font-size: 13px;
116
+ font-weight: 600;
117
+ transition: background-color 0.15s ease;
118
+ }
119
+
120
+ .btn-primary {
121
+ background-color: #0066cc;
122
+ color: #ffffff;
123
+ }
124
+
125
+ .btn-primary:hover {
126
+ background-color: #0052a3;
127
+ }
128
+ </style>
@@ -1,94 +1,95 @@
1
- <template>
2
- <div class="table-wrapper">
3
- <table>
4
- <thead>
5
- <tr>
6
- <th>ID</th>
7
- <th>Name</th>
8
- <th>Email</th>
9
- <th>Department</th>
10
- <th>Salary</th>
11
- <th>Action</th>
12
- </tr>
13
- </thead>
14
- <tbody>
15
- <tr v-if="employees.length === 0">
16
- <td colspan="6" class="empty">No employees found</td>
17
- </tr>
18
- <tr v-for="emp in employees" :key="emp.id">
19
- <td>{{ emp.id }}</td>
20
- <td>{{ emp.name }}</td>
21
- <td>{{ emp.email }}</td>
22
- <td>{{ getDepartmentName(emp.departmentId) }}</td>
23
- <td>${{ Number(emp.salary).toLocaleString() }}</td>
24
- <td>
25
- <button @click="emit('delete-employee', emp.id)" class="btn btn-danger">Delete</button>
26
- </td>
27
- </tr>
28
- </tbody>
29
- </table>
30
- </div>
31
- </template>
32
-
33
- <script setup>
34
- const props = defineProps(['employees', 'departments'])
35
- const emit = defineEmits(['delete-employee'])
36
-
37
- const getDepartmentName = (deptId) => {
38
- if (!props.departments) return `Dept #${deptId}`
39
- const dept = props.departments.find((d) => String(d.id) === String(deptId))
40
- return dept ? dept.name : `Dept #${deptId}`
41
- }
42
- </script>
43
-
44
- <style scoped>
45
- .table-wrapper {
46
- overflow-x: auto;
47
- }
48
-
49
- table {
50
- width: 100%;
51
- border-collapse: collapse;
52
- font-size: 13px;
53
- margin-top: 8px;
54
- }
55
-
56
- th, td {
57
- text-align: left;
58
- padding: 8px 10px;
59
- border-bottom: 1px solid #eeeeee;
60
- }
61
-
62
- th {
63
- background-color: #fafbfc;
64
- color: #555555;
65
- font-weight: 600;
66
- }
67
-
68
- .empty {
69
- text-align: center;
70
- color: #888888;
71
- padding: 16px;
72
- }
73
-
74
- .btn {
75
- padding: 8px 14px;
76
- border: none;
77
- border-radius: 4px;
78
- cursor: pointer;
79
- font-size: 13px;
80
- font-weight: 600;
81
- transition: background-color 0.15s ease;
82
- }
83
-
84
- .btn-danger {
85
- background-color: #d9383a;
86
- color: #ffffff;
87
- padding: 4px 8px;
88
- font-size: 12px;
89
- }
90
-
91
- .btn-danger:hover {
92
- background-color: #b8282a;
93
- }
94
- </style>
1
+ <template>
2
+ <div class="table-wrapper">
3
+ <table>
4
+ <thead>
5
+ <tr>
6
+ <th>ID</th>
7
+ <th>Name</th>
8
+ <th>Email</th>
9
+ <th>Department</th>
10
+ <th>Salary</th>
11
+ <th>Action</th>
12
+ </tr>
13
+ </thead>
14
+ <tbody>
15
+ <tr v-if="employees.length === 0">
16
+ <td colspan="6" class="empty">No employees found</td>
17
+ </tr>
18
+ <tr v-for="emp in employees" :key="emp.id">
19
+ <td>{{ emp.id }}</td>
20
+ <td>{{ emp.name }}</td>
21
+ <td>{{ emp.email }}</td>
22
+ <td>{{ getDepartmentName(emp.departmentId) }}</td>
23
+ <td>${{ Number(emp.salary).toLocaleString() }}</td>
24
+ <td>
25
+ <button @click="emit('patch-employee', emp.id, emp.salary)" class="btn">Patch</button>
26
+ <button @click="emit('delete-employee', emp.id)" class="btn btn-danger">Delete</button>
27
+ </td>
28
+ </tr>
29
+ </tbody>
30
+ </table>
31
+ </div>
32
+ </template>
33
+
34
+ <script setup>
35
+ const props = defineProps(['employees', 'departments'])
36
+ const emit = defineEmits(['delete-employee', 'patch-employee'])
37
+
38
+ const getDepartmentName = (deptId) => {
39
+ if (!props.departments) return `Dept #${deptId}`
40
+ const dept = props.departments.find((d) => String(d.id) === String(deptId))
41
+ return dept ? dept.name : `Dept #${deptId}`
42
+ }
43
+ </script>
44
+
45
+ <style scoped>
46
+ .table-wrapper {
47
+ overflow-x: auto;
48
+ }
49
+
50
+ table {
51
+ width: 100%;
52
+ border-collapse: collapse;
53
+ font-size: 13px;
54
+ margin-top: 8px;
55
+ }
56
+
57
+ th, td {
58
+ text-align: left;
59
+ padding: 8px 10px;
60
+ border-bottom: 1px solid #eeeeee;
61
+ }
62
+
63
+ th {
64
+ background-color: #fafbfc;
65
+ color: #555555;
66
+ font-weight: 600;
67
+ }
68
+
69
+ .empty {
70
+ text-align: center;
71
+ color: #888888;
72
+ padding: 16px;
73
+ }
74
+
75
+ .btn {
76
+ padding: 8px 14px;
77
+ border: none;
78
+ border-radius: 4px;
79
+ cursor: pointer;
80
+ font-size: 13px;
81
+ font-weight: 600;
82
+ transition: background-color 0.15s ease;
83
+ }
84
+
85
+ .btn-danger {
86
+ background-color: #d9383a;
87
+ color: #ffffff;
88
+ padding: 4px 8px;
89
+ font-size: 12px;
90
+ }
91
+
92
+ .btn-danger:hover {
93
+ background-color: #b8282a;
94
+ }
95
+ </style>