wad-lab 1.2.2 → 1.2.3

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 (207) hide show
  1. package/bin/index.js +472 -631
  2. package/package.json +1 -1
  3. package/templates/fullstack-springboot-vue/frontend/vue-axios-basic/src/App.vue +241 -429
  4. package/templates/fullstack-springboot-vue/frontend/vue-axios-basic/src/components/ItemFormModal.vue +183 -0
  5. package/templates/fullstack-springboot-vue/frontend/vue-axios-basic/src/components/ItemPatchModal.vue +193 -0
  6. package/templates/fullstack-springboot-vue/frontend/vue-axios-basic/src/components/ItemTable.vue +177 -0
  7. package/templates/fullstack-springboot-vue/frontend/vue-axios-pinia/src/App.vue +150 -441
  8. package/templates/fullstack-springboot-vue/frontend/vue-axios-pinia/src/components/ItemFormModal.vue +207 -0
  9. package/templates/fullstack-springboot-vue/frontend/vue-axios-pinia/src/components/ItemStats.vue +64 -0
  10. package/templates/fullstack-springboot-vue/frontend/vue-axios-pinia/src/components/ItemTable.vue +195 -0
  11. package/templates/fullstack-springboot-vue/frontend/vue-axios-router/src/App.vue +41 -90
  12. package/templates/fullstack-springboot-vue/frontend/vue-axios-router/src/components/ItemFormModal.vue +173 -0
  13. package/templates/fullstack-springboot-vue/frontend/vue-axios-router/src/components/ItemTable.vue +102 -0
  14. package/templates/fullstack-springboot-vue/frontend/vue-axios-router/src/components/NavBar.vue +57 -0
  15. package/templates/fullstack-springboot-vue/frontend/vue-axios-router/src/views/DepartmentView.vue +132 -296
  16. package/templates/fullstack-springboot-vue/frontend/vue-axios-router/src/views/EmployeeView.vue +126 -219
  17. package/templates/fullstack-springboot-vue/frontend/vue-axios-router-children/src/components/ItemDetail.vue +115 -0
  18. package/templates/fullstack-springboot-vue/frontend/vue-axios-router-children/src/components/ItemTable.vue +104 -0
  19. package/templates/fullstack-springboot-vue/frontend/vue-axios-router-children/src/components/SideBar.vue +59 -0
  20. package/templates/fullstack-springboot-vue/frontend/vue-axios-router-children/src/views/CompanyLayout.vue +2 -51
  21. package/templates/fullstack-springboot-vue/frontend/vue-axios-router-children/src/views/DepartmentListView.vue +92 -250
  22. package/templates/fullstack-springboot-vue/frontend/vue-axios-router-children/src/views/EmployeeDetailView.vue +59 -181
  23. package/templates/fullstack-springboot-vue/frontend/vue-axios-router-children/src/views/EmployeeListView.vue +67 -315
  24. package/templates/fullstack-springboot-vue/frontend/vue-axios-router-pinia/src/App.vue +19 -70
  25. package/templates/fullstack-springboot-vue/frontend/vue-axios-router-pinia/src/components/ItemFormModal.vue +173 -0
  26. package/templates/fullstack-springboot-vue/frontend/vue-axios-router-pinia/src/components/ItemPatchModal.vue +144 -0
  27. package/templates/fullstack-springboot-vue/frontend/vue-axios-router-pinia/src/components/ItemTable.vue +102 -0
  28. package/templates/fullstack-springboot-vue/frontend/vue-axios-router-pinia/src/components/NavBar.vue +53 -0
  29. package/templates/fullstack-springboot-vue/frontend/vue-axios-router-pinia/src/views/DepartmentView.vue +107 -229
  30. package/templates/fullstack-springboot-vue/frontend/vue-axios-router-pinia/src/views/EmployeeView.vue +143 -257
  31. package/templates/game-bingo/script.js +1 -1
  32. package/templates/game-memory-cards/script.js +2 -2
  33. package/templates/game-rock-paper-scissors/index.html +3 -3
  34. package/templates/game-rock-paper-scissors/script.js +2 -2
  35. package/templates/game-tic-tac-toe/script.js +2 -2
  36. package/templates/game-whack-a-mole/index.html +9 -9
  37. package/templates/servlet-basic/WEB-INF/ItemServlet.java +13 -0
  38. package/templates/servlet-basic/WEB-INF/classes/ItemServlet.class +0 -0
  39. package/templates/servlet-flow/WEB-INF/HelloServlet.java +34 -25
  40. package/templates/servlet-flow/WEB-INF/classes/HelloServlet.class +0 -0
  41. package/templates/servlet-jdbc/WEB-INF/JdbcItemServlet.java +13 -0
  42. package/templates/servlet-jdbc/WEB-INF/classes/JdbcItemServlet.class +0 -0
  43. package/templates/snippets/mongo-queries-cheatsheet.txt +105 -0
  44. package/templates/springboot-2model-aggregation-join/.mvn/wrapper/maven-wrapper.properties +3 -0
  45. package/templates/springboot-2model-aggregation-join/mvnw +295 -0
  46. package/templates/springboot-2model-aggregation-join/mvnw.cmd +189 -0
  47. package/templates/springboot-2model-aggregation-join/pom.xml +54 -0
  48. package/templates/springboot-2model-aggregation-join/src/main/java/com/example/aggregation/AggregationApplication.java +11 -0
  49. package/templates/springboot-2model-aggregation-join/src/main/java/com/example/aggregation/controller/DepartmentController.java +65 -0
  50. package/templates/springboot-2model-aggregation-join/src/main/java/com/example/aggregation/controller/EmployeeController.java +65 -0
  51. package/templates/springboot-2model-aggregation-join/src/main/java/com/example/aggregation/dto/DepartmentStatsDTO.java +15 -0
  52. package/templates/springboot-2model-aggregation-join/src/main/java/com/example/aggregation/dto/EmployeeJoinDTO.java +19 -0
  53. package/templates/springboot-2model-aggregation-join/src/main/java/com/example/aggregation/model/Department.java +20 -0
  54. package/templates/springboot-2model-aggregation-join/src/main/java/com/example/aggregation/model/Employee.java +21 -0
  55. package/templates/springboot-2model-aggregation-join/src/main/java/com/example/aggregation/repository/DepartmentRepository.java +9 -0
  56. package/templates/springboot-2model-aggregation-join/src/main/java/com/example/aggregation/repository/EmployeeRepository.java +9 -0
  57. package/templates/springboot-2model-aggregation-join/src/main/java/com/example/aggregation/service/DepartmentService.java +81 -0
  58. package/templates/springboot-2model-aggregation-join/src/main/java/com/example/aggregation/service/EmployeeService.java +80 -0
  59. package/templates/springboot-2model-aggregation-join/src/main/resources/application.properties +2 -0
  60. package/templates/springboot-2model-aggregation-join/src/test/java/com/example/aggregation/AggregationApplicationTests.java +13 -0
  61. package/templates/vue-2model-crud-patch/README.md +64 -0
  62. package/templates/vue-2model-crud-patch/index.html +12 -0
  63. package/templates/vue-2model-crud-patch/package-lock.json +1785 -0
  64. package/templates/vue-2model-crud-patch/package.json +21 -0
  65. package/templates/vue-2model-crud-patch/src/App.vue +63 -0
  66. package/templates/vue-2model-crud-patch/src/components/AnalyticsBoard.vue +291 -0
  67. package/templates/vue-2model-crud-patch/src/components/DepartmentFormModal.vue +138 -0
  68. package/templates/vue-2model-crud-patch/src/components/DepartmentPatchModal.vue +210 -0
  69. package/templates/vue-2model-crud-patch/src/components/DepartmentTable.vue +133 -0
  70. package/templates/vue-2model-crud-patch/src/components/EmployeeFormModal.vue +177 -0
  71. package/templates/vue-2model-crud-patch/src/components/EmployeePatchModal.vue +221 -0
  72. package/templates/vue-2model-crud-patch/src/components/EmployeeTable.vue +171 -0
  73. package/templates/vue-2model-crud-patch/src/components/NavBar.vue +156 -0
  74. package/templates/vue-2model-crud-patch/src/main.js +12 -0
  75. package/templates/vue-2model-crud-patch/src/router/index.js +33 -0
  76. package/templates/vue-2model-crud-patch/src/services/api.js +64 -0
  77. package/templates/vue-2model-crud-patch/src/stores/departmentStore.js +149 -0
  78. package/templates/vue-2model-crud-patch/src/stores/employeeStore.js +143 -0
  79. package/templates/vue-2model-crud-patch/src/style.css +415 -0
  80. package/templates/vue-2model-crud-patch/src/views/AnalyticsView.vue +59 -0
  81. package/templates/vue-2model-crud-patch/src/views/DepartmentsView.vue +135 -0
  82. package/templates/vue-2model-crud-patch/src/views/EmployeesView.vue +143 -0
  83. package/templates/vue-2model-crud-patch/vite.config.js +9 -0
  84. package/templates/vue-axios/src/App.vue +255 -264
  85. package/templates/vue-axios/src/components/ItemFormModal.vue +183 -0
  86. package/templates/vue-axios/src/components/ItemPatchModal.vue +193 -0
  87. package/templates/vue-axios/src/components/ItemTable.vue +177 -0
  88. package/templates/vue-axios-basic/src/App.vue +241 -429
  89. package/templates/vue-axios-basic/src/components/ItemFormModal.vue +183 -0
  90. package/templates/vue-axios-basic/src/components/ItemPatchModal.vue +193 -0
  91. package/templates/vue-axios-basic/src/components/ItemTable.vue +177 -0
  92. package/templates/vue-axios-pinia/src/App.vue +150 -441
  93. package/templates/vue-axios-pinia/src/components/ItemFormModal.vue +207 -0
  94. package/templates/vue-axios-pinia/src/components/ItemStats.vue +64 -0
  95. package/templates/vue-axios-pinia/src/components/ItemTable.vue +195 -0
  96. package/templates/vue-axios-router/src/App.vue +41 -90
  97. package/templates/vue-axios-router/src/components/ItemFormModal.vue +173 -0
  98. package/templates/vue-axios-router/src/components/ItemTable.vue +102 -0
  99. package/templates/vue-axios-router/src/components/NavBar.vue +57 -0
  100. package/templates/vue-axios-router/src/views/DepartmentView.vue +132 -296
  101. package/templates/vue-axios-router/src/views/EmployeeView.vue +126 -219
  102. package/templates/vue-axios-router-children/src/components/ItemDetail.vue +115 -0
  103. package/templates/vue-axios-router-children/src/components/ItemTable.vue +104 -0
  104. package/templates/vue-axios-router-children/src/components/SideBar.vue +59 -0
  105. package/templates/vue-axios-router-children/src/views/CompanyLayout.vue +2 -51
  106. package/templates/vue-axios-router-children/src/views/DepartmentListView.vue +92 -250
  107. package/templates/vue-axios-router-children/src/views/EmployeeDetailView.vue +59 -181
  108. package/templates/vue-axios-router-children/src/views/EmployeeListView.vue +67 -315
  109. package/templates/vue-axios-router-pinia/src/App.vue +19 -70
  110. package/templates/vue-axios-router-pinia/src/components/ItemFormModal.vue +173 -0
  111. package/templates/vue-axios-router-pinia/src/components/ItemPatchModal.vue +144 -0
  112. package/templates/vue-axios-router-pinia/src/components/ItemTable.vue +102 -0
  113. package/templates/vue-axios-router-pinia/src/components/NavBar.vue +53 -0
  114. package/templates/vue-axios-router-pinia/src/views/DepartmentView.vue +107 -229
  115. package/templates/vue-axios-router-pinia/src/views/EmployeeView.vue +143 -257
  116. package/templates/vue-banking-app/src/components/AccountOverview.vue +75 -0
  117. package/templates/vue-banking-app/src/components/TransactionForm.vue +89 -0
  118. package/templates/vue-banking-app/src/components/TransactionTable.vue +113 -0
  119. package/templates/vue-banking-app/src/stores/bankStore.js +16 -3
  120. package/templates/vue-banking-app/src/views/DashboardView.vue +23 -71
  121. package/templates/vue-banking-app/src/views/StatementView.vue +11 -158
  122. package/templates/vue-banking-app/src/views/TransactionFormView.vue +23 -121
  123. package/templates/vue-basics/src/App.vue +105 -76
  124. package/templates/vue-basics/src/components/CounterCard.vue +107 -0
  125. package/templates/vue-basics/src/components/ItemList.vue +99 -0
  126. package/templates/vue-basics/src/components/UserForm.vue +138 -0
  127. package/templates/vue-cart-router-pinia/src/components/CartSummary.vue +139 -0
  128. package/templates/vue-cart-router-pinia/src/components/CheckoutModal.vue +149 -0
  129. package/templates/vue-cart-router-pinia/src/components/ProductCard.vue +63 -0
  130. package/templates/vue-cart-router-pinia/src/stores/cartStore.js +11 -0
  131. package/templates/vue-cart-router-pinia/src/views/CartView.vue +52 -118
  132. package/templates/vue-cart-router-pinia/src/views/CheckoutView.vue +2 -5
  133. package/templates/vue-cart-router-pinia/src/views/ProductCatalogView.vue +20 -56
  134. package/templates/vue-employee-system/src/App.vue +75 -344
  135. package/templates/vue-employee-system/src/components/DepartmentFilter.vue +108 -0
  136. package/templates/vue-employee-system/src/components/EmployeeModal.vue +183 -0
  137. package/templates/vue-employee-system/src/components/EmployeeTable.vue +91 -0
  138. package/templates/vue-employee-system/src/stores/employeeStore.js +12 -0
  139. package/templates/vue-fetch/src/App.vue +261 -285
  140. package/templates/vue-fetch/src/components/FetchFormModal.vue +183 -0
  141. package/templates/vue-fetch/src/components/FetchPatchModal.vue +193 -0
  142. package/templates/vue-fetch/src/components/FetchTable.vue +177 -0
  143. package/templates/vue-food-ordering/src/components/CartSummary.vue +134 -0
  144. package/templates/vue-food-ordering/src/components/FoodMenu.vue +126 -0
  145. package/templates/vue-food-ordering/src/components/OrderModal.vue +150 -0
  146. package/templates/vue-food-ordering/src/views/MenuView.vue +11 -132
  147. package/templates/vue-food-ordering/src/views/OrderCartView.vue +31 -164
  148. package/templates/vue-game-rps/src/App.vue +29 -88
  149. package/templates/vue-game-tictactoe/src/App.vue +23 -53
  150. package/templates/vue-game-whackamole/src/App.vue +44 -63
  151. package/templates/vue-hospital-portal/src/components/AppointmentForm.vue +144 -0
  152. package/templates/vue-hospital-portal/src/components/DoctorCard.vue +73 -0
  153. package/templates/vue-hospital-portal/src/components/PatientTable.vue +123 -0
  154. package/templates/vue-hospital-portal/src/stores/hospitalStore.js +10 -1
  155. package/templates/vue-hospital-portal/src/views/OPDRegistrationView.vue +40 -416
  156. package/templates/vue-hospital-portal/src/views/PatientListView.vue +11 -301
  157. package/templates/vue-library-system/src/components/BookForm.vue +125 -0
  158. package/templates/vue-library-system/src/components/BookTable.vue +112 -0
  159. package/templates/vue-library-system/src/components/BorrowModal.vue +131 -0
  160. package/templates/vue-library-system/src/stores/libraryStore.js +26 -1
  161. package/templates/vue-library-system/src/views/BookCatalogView.vue +34 -415
  162. package/templates/vue-memory-game/src/App.vue +36 -40
  163. package/templates/vue-memory-game/src/stores/memoryStore.js +32 -37
  164. package/templates/vue-router/src/App.vue +24 -14
  165. package/templates/vue-router/src/components/AboutCard.vue +38 -0
  166. package/templates/vue-router/src/components/HomeHero.vue +75 -0
  167. package/templates/vue-router/src/components/NavBar.vue +54 -0
  168. package/templates/vue-router/src/views/ItemsLayout.vue +17 -9
  169. package/templates/vue-router/src/views/ListView.vue +106 -18
  170. package/templates/vue-router-pinia/src/App.vue +24 -14
  171. package/templates/vue-router-pinia/src/components/ItemFormModal.vue +163 -0
  172. package/templates/vue-router-pinia/src/components/ItemTable.vue +90 -0
  173. package/templates/vue-router-pinia/src/components/NavBar.vue +54 -0
  174. package/templates/vue-router-pinia/src/stores/itemStore.js +8 -1
  175. package/templates/vue-router-pinia/src/views/ListView.vue +78 -14
  176. package/templates/vue-router-pinia-springboot/frontend/src/App.vue +25 -8
  177. package/templates/vue-router-pinia-springboot/frontend/src/components/ItemFormModal.vue +183 -0
  178. package/templates/vue-router-pinia-springboot/frontend/src/components/ItemPatchModal.vue +193 -0
  179. package/templates/vue-router-pinia-springboot/frontend/src/components/ItemTable.vue +177 -0
  180. package/templates/vue-router-pinia-springboot/frontend/src/components/NavBar.vue +54 -0
  181. package/templates/vue-router-pinia-springboot/frontend/src/views/ListView.vue +92 -76
  182. package/templates/vue-springboot-mongo-aggregation/frontend/src/App.vue +184 -193
  183. package/templates/vue-springboot-mongo-aggregation/frontend/src/components/AnalyticsCards.vue +56 -0
  184. package/templates/vue-springboot-mongo-aggregation/frontend/src/components/CategorySummaryTable.vue +71 -0
  185. package/templates/vue-springboot-mongo-aggregation/frontend/src/components/ItemTable.vue +114 -0
  186. package/templates/vue-springboot-mongo-crud/frontend/src/App.vue +228 -158
  187. package/templates/vue-springboot-mongo-crud/frontend/src/components/ItemFormModal.vue +183 -0
  188. package/templates/vue-springboot-mongo-crud/frontend/src/components/ItemPatchModal.vue +193 -0
  189. package/templates/vue-springboot-mongo-crud/frontend/src/components/ItemTable.vue +177 -0
  190. package/templates/vue-symposium-system/src/App.vue +41 -256
  191. package/templates/vue-symposium-system/src/components/AttendeeTable.vue +100 -0
  192. package/templates/vue-symposium-system/src/components/EventCard.vue +67 -0
  193. package/templates/vue-symposium-system/src/components/RegistrationForm.vue +118 -0
  194. package/templates/vue-symposium-system/src/stores/symposiumStore.js +10 -0
  195. package/templates/vue-todo-pinia/src/App.vue +40 -138
  196. package/templates/vue-todo-pinia/src/components/TodoFilter.vue +74 -0
  197. package/templates/vue-todo-pinia/src/components/TodoInput.vue +53 -0
  198. package/templates/vue-todo-pinia/src/components/TodoList.vue +101 -0
  199. package/templates/vue-todo-pinia/src/stores/todoStore.js +6 -0
  200. package/templates/vue-todo-router/src/App.vue +5 -36
  201. package/templates/vue-todo-router/src/components/TodoForm.vue +78 -0
  202. package/templates/vue-todo-router/src/components/TodoList.vue +84 -0
  203. package/templates/vue-todo-router/src/components/TodoNavBar.vue +47 -0
  204. package/templates/vue-todo-router/src/data/todoState.js +7 -0
  205. package/templates/vue-todo-router/src/views/AddTodoView.vue +7 -66
  206. package/templates/vue-todo-router/src/views/TodoDetailView.vue +15 -1
  207. package/templates/vue-todo-router/src/views/TodoListView.vue +22 -64
@@ -1,250 +1,92 @@
1
- <template>
2
- <div class="departments-page">
3
- <header class="page-header">
4
- <h1>Departments</h1>
5
- <p>Manage company departments.</p>
6
- </header>
7
-
8
- <section class="card form-card">
9
- <h2>Add New Department</h2>
10
- <form @submit.prevent="createDepartment" class="form">
11
- <div class="form-row">
12
- <div class="form-group">
13
- <label for="dept-name">Department Name</label>
14
- <input
15
- id="dept-name"
16
- v-model="form.name"
17
- type="text"
18
- required
19
- placeholder="e.g. Finance"
20
- />
21
- </div>
22
- <div class="form-group">
23
- <label for="dept-code">Department Code</label>
24
- <input
25
- id="dept-code"
26
- v-model="form.code"
27
- type="text"
28
- required
29
- placeholder="e.g. FIN"
30
- />
31
- </div>
32
- </div>
33
- <button type="submit" class="btn btn-primary">Add Department</button>
34
- </form>
35
- </section>
36
-
37
- <section class="card table-card">
38
- <h2>All Departments</h2>
39
- <table class="data-table">
40
- <thead>
41
- <tr>
42
- <th>ID</th>
43
- <th>Name</th>
44
- <th>Code</th>
45
- <th>Actions</th>
46
- </tr>
47
- </thead>
48
- <tbody>
49
- <tr v-if="departments.length === 0">
50
- <td colspan="4" class="empty">No departments found.</td>
51
- </tr>
52
- <tr v-for="dept in departments" :key="dept.id">
53
- <td>{{ dept.id }}</td>
54
- <td>{{ dept.name }}</td>
55
- <td><code>{{ dept.code }}</code></td>
56
- <td>
57
- <button @click="handlePatch(dept.id, dept.code)" class="btn btn-warning">Patch</button>
58
- <button @click="deleteDepartment(dept.id)" class="btn btn-danger">Delete</button>
59
- </td>
60
- </tr>
61
- </tbody>
62
- </table>
63
- </section>
64
- </div>
65
- </template>
66
-
67
- <script setup>
68
- import { ref, reactive, onMounted } from 'vue'
69
- import api from '../services/api'
70
-
71
- const departments = ref([])
72
- const form = reactive({
73
- name: '',
74
- code: ''
75
- })
76
-
77
- const fetchDepartments = async () => {
78
- try {
79
- const res = await api.get('/departments')
80
- departments.value = Array.isArray(res.data) ? res.data : []
81
- } catch (err) {
82
- departments.value = []
83
- }
84
- }
85
-
86
- const createDepartment = async () => {
87
- try {
88
- await api.post('/departments', {
89
- name: form.name,
90
- code: form.code
91
- })
92
- form.name = ''
93
- form.code = ''
94
- await fetchDepartments()
95
- } catch (err) {
96
- alert('Failed to add department')
97
- }
98
- }
99
-
100
- const deleteDepartment = async (id) => {
101
- try {
102
- await api.delete(`/departments/${id}`)
103
- await fetchDepartments()
104
- } catch (err) {
105
- alert('Failed to delete department')
106
- }
107
- }
108
-
109
- const handlePatch = async (id, code) => {
110
- const newCode = prompt('New code:', code)
111
- if (newCode) {
112
- try {
113
- await api.patch(`/departments/${id}`, { code: newCode })
114
- await fetchDepartments()
115
- } catch (err) {
116
- alert('Failed to patch department')
117
- }
118
- }
119
- }
120
-
121
- onMounted(() => {
122
- fetchDepartments()
123
- })
124
- </script>
125
-
126
- <style scoped>
127
- .departments-page {
128
- max-width: 900px;
129
- }
130
-
131
- .page-header {
132
- margin-bottom: 24px;
133
- }
134
-
135
- .page-header h1 {
136
- font-size: 1.75rem;
137
- margin-bottom: 6px;
138
- color: #1e293b;
139
- }
140
-
141
- .page-header p {
142
- color: #64748b;
143
- }
144
-
145
- .card {
146
- background: #ffffff;
147
- padding: 24px;
148
- border-radius: 8px;
149
- box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
150
- margin-bottom: 24px;
151
- }
152
-
153
- .card h2 {
154
- font-size: 1.2rem;
155
- margin-bottom: 16px;
156
- color: #334155;
157
- }
158
-
159
- .form-row {
160
- display: flex;
161
- gap: 16px;
162
- margin-bottom: 16px;
163
- }
164
-
165
- .form-group {
166
- flex: 1;
167
- display: flex;
168
- flex-direction: column;
169
- gap: 6px;
170
- }
171
-
172
- label {
173
- font-size: 0.875rem;
174
- font-weight: 500;
175
- color: #475569;
176
- }
177
-
178
- input {
179
- padding: 8px 12px;
180
- border: 1px solid #cbd5e1;
181
- border-radius: 6px;
182
- font-size: 0.95rem;
183
- }
184
-
185
- input:focus {
186
- outline: none;
187
- border-color: #2563eb;
188
- }
189
-
190
- .btn {
191
- padding: 8px 16px;
192
- border: none;
193
- border-radius: 6px;
194
- cursor: pointer;
195
- font-weight: 500;
196
- transition: opacity 0.2s;
197
- }
198
-
199
- .btn:hover {
200
- opacity: 0.9;
201
- }
202
-
203
- .btn-primary {
204
- background-color: #2563eb;
205
- color: #ffffff;
206
- }
207
-
208
- .btn-danger {
209
- background-color: #ef4444;
210
- color: #ffffff;
211
- }
212
-
213
- .btn-warning {
214
- background-color: #f59e0b;
215
- color: #ffffff;
216
- margin-right: 8px;
217
- }
218
-
219
- .data-table {
220
- width: 100%;
221
- border-collapse: collapse;
222
- }
223
-
224
- .data-table th,
225
- .data-table td {
226
- padding: 12px;
227
- text-align: left;
228
- border-bottom: 1px solid #e2e8f0;
229
- }
230
-
231
- .data-table th {
232
- background-color: #f8fafc;
233
- font-size: 0.875rem;
234
- color: #475569;
235
- font-weight: 600;
236
- }
237
-
238
- .data-table td code {
239
- background-color: #f1f5f9;
240
- padding: 2px 6px;
241
- border-radius: 4px;
242
- font-size: 0.85rem;
243
- }
244
-
245
- .empty {
246
- text-align: center;
247
- color: #94a3b8;
248
- padding: 24px;
249
- }
250
- </style>
1
+ <script setup>
2
+ import { ref, onMounted } from 'vue'
3
+ import api from '../services/api'
4
+ import ItemTable from '../components/ItemTable.vue'
5
+
6
+ const departments = ref([])
7
+ const newName = ref('')
8
+ const newCode = ref('')
9
+
10
+ const columns = [
11
+ { key: 'id', label: 'ID' },
12
+ { key: 'name', label: 'Department Name' },
13
+ { key: 'code', label: 'Code' }
14
+ ]
15
+
16
+ async function fetchDepartments() {
17
+ const res = await api.get('/departments')
18
+ departments.value = res.data || []
19
+ }
20
+
21
+ async function handleAdd() {
22
+ if (!newName.value || !newCode.value) return
23
+ await api.post('/departments', { name: newName.value, code: newCode.value })
24
+ newName.value = ''
25
+ newCode.value = ''
26
+ await fetchDepartments()
27
+ }
28
+
29
+ async function handlePatch(dept) {
30
+ const code = prompt('Enter new code:', dept.code)
31
+ if (!code || code === dept.code) return
32
+ await api.patch('/departments/' + dept.id, { code })
33
+ await fetchDepartments()
34
+ }
35
+
36
+ async function handleDelete(id) {
37
+ if (!confirm('Delete this department?')) return
38
+ await api.delete('/departments/' + id)
39
+ await fetchDepartments()
40
+ }
41
+
42
+ onMounted(() => {
43
+ fetchDepartments()
44
+ })
45
+ </script>
46
+
47
+ <template>
48
+ <div class="dept-view">
49
+ <h2>Departments</h2>
50
+
51
+ <form @submit.prevent="handleAdd" class="add-form">
52
+ <input v-model="newName" placeholder="Department Name" required />
53
+ <input v-model="newCode" placeholder="Code" required />
54
+ <button type="submit" class="btn btn-primary">Add</button>
55
+ </form>
56
+
57
+ <ItemTable
58
+ :columns="columns"
59
+ :items="departments"
60
+ @patch="handlePatch"
61
+ @delete="handleDelete"
62
+ />
63
+ </div>
64
+ </template>
65
+
66
+ <style scoped>
67
+ .dept-view {
68
+ display: flex;
69
+ flex-direction: column;
70
+ gap: 16px;
71
+ }
72
+
73
+ .add-form {
74
+ display: flex;
75
+ gap: 10px;
76
+ }
77
+
78
+ .add-form input {
79
+ padding: 8px 12px;
80
+ border: 1px solid #d0d7de;
81
+ border-radius: 6px;
82
+ }
83
+
84
+ .btn-primary {
85
+ background: #0284c7;
86
+ color: #fff;
87
+ border: none;
88
+ padding: 8px 14px;
89
+ border-radius: 6px;
90
+ cursor: pointer;
91
+ }
92
+ </style>
@@ -1,181 +1,59 @@
1
- <template>
2
- <div class="employee-detail-page">
3
- <div class="header-actions">
4
- <router-link to="/company/employees" class="btn btn-secondary">&larr; Back to Employees</router-link>
5
- <button @click="handleQuickPatchSalary" class="btn btn-warning">Quick Patch Salary</button>
6
- </div>
7
-
8
- <div v-if="loading" class="card">
9
- <p>Loading employee details...</p>
10
- </div>
11
-
12
- <div v-else-if="error" class="card error-card">
13
- <p>{{ error }}</p>
14
- </div>
15
-
16
- <div v-else-if="employee" class="card detail-card">
17
- <header class="detail-header">
18
- <h1>{{ employee.name }}</h1>
19
- <span class="badge">ID: {{ employee.id }}</span>
20
- </header>
21
-
22
- <div class="detail-grid">
23
- <div class="detail-item">
24
- <span class="detail-label">Email Address</span>
25
- <span class="detail-value">{{ employee.email }}</span>
26
- </div>
27
-
28
- <div class="detail-item">
29
- <span class="detail-label">Department ID</span>
30
- <span class="detail-value">{{ employee.departmentId }}</span>
31
- </div>
32
-
33
- <div class="detail-item">
34
- <span class="detail-label">Salary</span>
35
- <span class="detail-value">${{ Number(employee.salary).toLocaleString() }}</span>
36
- </div>
37
- </div>
38
- </div>
39
- </div>
40
- </template>
41
-
42
- <script setup>
43
- import { ref, onMounted } from 'vue'
44
- import { useRoute } from 'vue-router'
45
- import api from '../services/api'
46
-
47
- const route = useRoute()
48
- const employee = ref(null)
49
- const loading = ref(true)
50
- const error = ref('')
51
-
52
- const fetchEmployee = async () => {
53
- const id = route.params.id
54
- loading.value = true
55
- error.value = ''
56
- try {
57
- const res = await api.get(`/employees/${id}`)
58
- employee.value = res.data
59
- } catch (err) {
60
- error.value = 'Failed to load employee details.'
61
- } finally {
62
- loading.value = false
63
- }
64
- }
65
-
66
- const handleQuickPatchSalary = async () => {
67
- if (!employee.value) return
68
- const id = route.params.id
69
- const salary = prompt('New salary:', employee.value.salary)
70
- if (salary !== null && salary !== '') {
71
- try {
72
- await api.patch(`/employees/${id}`, { salary: Number(salary) })
73
- await fetchEmployee()
74
- } catch (err) {
75
- error.value = 'Failed to patch employee salary.'
76
- }
77
- }
78
- }
79
-
80
- onMounted(() => {
81
- fetchEmployee()
82
- })
83
- </script>
84
-
85
- <style scoped>
86
- .employee-detail-page {
87
- max-width: 650px;
88
- }
89
-
90
- .header-actions {
91
- display: flex;
92
- gap: 12px;
93
- margin-bottom: 20px;
94
- }
95
-
96
- .btn {
97
- padding: 8px 16px;
98
- border: none;
99
- border-radius: 6px;
100
- cursor: pointer;
101
- font-weight: 500;
102
- text-decoration: none;
103
- display: inline-flex;
104
- align-items: center;
105
- transition: opacity 0.2s;
106
- }
107
-
108
- .btn:hover {
109
- opacity: 0.9;
110
- }
111
-
112
- .btn-secondary {
113
- background-color: #64748b;
114
- color: #ffffff;
115
- }
116
-
117
- .btn-warning {
118
- background-color: #f59e0b;
119
- color: #ffffff;
120
- }
121
-
122
- .card {
123
- background: #ffffff;
124
- padding: 28px;
125
- border-radius: 8px;
126
- box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
127
- }
128
-
129
- .error-card {
130
- color: #ef4444;
131
- }
132
-
133
- .detail-header {
134
- display: flex;
135
- align-items: center;
136
- justify-content: space-between;
137
- border-bottom: 1px solid #e2e8f0;
138
- padding-bottom: 16px;
139
- margin-bottom: 20px;
140
- }
141
-
142
- .detail-header h1 {
143
- font-size: 1.5rem;
144
- color: #1e293b;
145
- }
146
-
147
- .badge {
148
- background-color: #e2e8f0;
149
- color: #475569;
150
- font-size: 0.85rem;
151
- font-weight: 600;
152
- padding: 4px 10px;
153
- border-radius: 20px;
154
- }
155
-
156
- .detail-grid {
157
- display: flex;
158
- flex-direction: column;
159
- gap: 16px;
160
- }
161
-
162
- .detail-item {
163
- display: flex;
164
- flex-direction: column;
165
- gap: 4px;
166
- }
167
-
168
- .detail-label {
169
- font-size: 0.85rem;
170
- color: #64748b;
171
- font-weight: 500;
172
- text-transform: uppercase;
173
- letter-spacing: 0.05em;
174
- }
175
-
176
- .detail-value {
177
- font-size: 1.1rem;
178
- color: #0f172a;
179
- font-weight: 600;
180
- }
181
- </style>
1
+ <script setup>
2
+ import { ref, computed, onMounted } from 'vue'
3
+ import { useRoute, useRouter } from 'vue-router'
4
+ import api from '../services/api'
5
+ import ItemDetail from '../components/ItemDetail.vue'
6
+
7
+ const route = useRoute()
8
+ const router = useRouter()
9
+
10
+ const employee = ref(null)
11
+ const departments = ref([])
12
+
13
+ const departmentName = computed(() => {
14
+ if (!employee.value) return 'N/A'
15
+ const dept = departments.value.find(d => d.id === employee.value.departmentId)
16
+ return dept ? dept.name : 'Dept #' + employee.value.departmentId
17
+ })
18
+
19
+ async function fetchEmployee() {
20
+ try {
21
+ const [empRes, deptRes] = await Promise.all([
22
+ api.get('/employees/' + route.params.id),
23
+ api.get('/departments').catch(() => ({ data: [] }))
24
+ ])
25
+ employee.value = empRes.data
26
+ departments.value = deptRes.data || []
27
+ } catch (err) {
28
+ employee.value = null
29
+ }
30
+ }
31
+
32
+ async function handlePatchSalary() {
33
+ if (!employee.value) return
34
+ const salary = prompt('Enter new salary:', employee.value.salary)
35
+ if (!salary || Number(salary) === Number(employee.value.salary)) return
36
+ await api.patch('/employees/' + employee.value.id, { salary: Number(salary) })
37
+ await fetchEmployee()
38
+ }
39
+
40
+ async function handleDelete(id) {
41
+ if (!confirm('Delete this employee?')) return
42
+ await api.delete('/employees/' + id)
43
+ router.push('/company/employees')
44
+ }
45
+
46
+ onMounted(() => {
47
+ fetchEmployee()
48
+ })
49
+ </script>
50
+
51
+ <template>
52
+ <ItemDetail
53
+ :item="employee"
54
+ :department-name="departmentName"
55
+ @patch-salary="handlePatchSalary"
56
+ @delete="handleDelete"
57
+ @back="router.push('/company/employees')"
58
+ />
59
+ </template>