wad-lab 1.1.6 → 1.1.7

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,427 +1,441 @@
1
- <template>
2
- <div class="container">
3
- <header class="header">
4
- <h1>Company Management</h1>
5
- <p>Vue 3 + Axios + Pinia</p>
6
- </header>
7
-
8
- <div class="stats-grid">
9
- <div class="stat-card">
10
- <h3>Total Departments</h3>
11
- <p class="stat-value">{{ companyStore.totalDepartments }}</p>
12
- </div>
13
- <div class="stat-card">
14
- <h3>Total Employees</h3>
15
- <p class="stat-value">{{ companyStore.totalEmployees }}</p>
16
- </div>
17
- <div class="stat-card">
18
- <h3>Total Payroll</h3>
19
- <p class="stat-value">${{ companyStore.totalPayroll.toLocaleString() }}</p>
20
- </div>
21
- </div>
22
-
23
- <div v-if="companyStore.loading" class="status-msg info">Loading data...</div>
24
- <div v-if="companyStore.error" class="status-msg error">{{ companyStore.error }}</div>
25
-
26
- <div class="main-grid">
27
- <section class="card">
28
- <h2>Departments</h2>
29
-
30
- <form @submit.prevent="handleCreateDepartment" class="form">
31
- <div class="form-group">
32
- <label for="dept-name">Department Name</label>
33
- <input
34
- id="dept-name"
35
- v-model="deptForm.name"
36
- type="text"
37
- required
38
- placeholder="e.g. Engineering"
39
- />
40
- </div>
41
- <div class="form-group">
42
- <label for="dept-code">Department Code</label>
43
- <input
44
- id="dept-code"
45
- v-model="deptForm.code"
46
- type="text"
47
- required
48
- placeholder="e.g. ENG"
49
- />
50
- </div>
51
- <button type="submit" class="btn btn-primary">Add Department</button>
52
- </form>
53
-
54
- <div class="table-wrapper">
55
- <table>
56
- <thead>
57
- <tr>
58
- <th>ID</th>
59
- <th>Name</th>
60
- <th>Code</th>
61
- <th>Action</th>
62
- </tr>
63
- </thead>
64
- <tbody>
65
- <tr v-if="companyStore.departments.length === 0">
66
- <td colspan="4" class="empty">No departments found</td>
67
- </tr>
68
- <tr v-for="dept in companyStore.departments" :key="dept.id">
69
- <td>{{ dept.id }}</td>
70
- <td>{{ dept.name }}</td>
71
- <td><code>{{ dept.code }}</code></td>
72
- <td>
73
- <button @click="companyStore.deleteDepartment(dept.id)" class="btn btn-danger">Delete</button>
74
- </td>
75
- </tr>
76
- </tbody>
77
- </table>
78
- </div>
79
- </section>
80
-
81
- <section class="card">
82
- <h2>Employees</h2>
83
-
84
- <form @submit.prevent="handleCreateEmployee" class="form">
85
- <div class="form-group">
86
- <label for="emp-name">Full Name</label>
87
- <input
88
- id="emp-name"
89
- v-model="empForm.name"
90
- type="text"
91
- required
92
- placeholder="e.g. Jane Doe"
93
- />
94
- </div>
95
- <div class="form-group">
96
- <label for="emp-email">Email Address</label>
97
- <input
98
- id="emp-email"
99
- v-model="empForm.email"
100
- type="email"
101
- required
102
- placeholder="e.g. jane@example.com"
103
- />
104
- </div>
105
- <div class="form-group">
106
- <label for="emp-dept">Department</label>
107
- <select id="emp-dept" v-model="empForm.departmentId" required>
108
- <option value="" disabled>Select Department</option>
109
- <option v-for="dept in companyStore.departments" :key="dept.id" :value="dept.id">
110
- {{ dept.name }} ({{ dept.code }})
111
- </option>
112
- </select>
113
- </div>
114
- <div class="form-group">
115
- <label for="emp-salary">Salary</label>
116
- <input
117
- id="emp-salary"
118
- v-model.number="empForm.salary"
119
- type="number"
120
- min="0"
121
- step="any"
122
- required
123
- placeholder="e.g. 75000"
124
- />
125
- </div>
126
- <button type="submit" class="btn btn-primary">Add Employee</button>
127
- </form>
128
-
129
- <div class="table-wrapper">
130
- <table>
131
- <thead>
132
- <tr>
133
- <th>ID</th>
134
- <th>Name</th>
135
- <th>Email</th>
136
- <th>Department</th>
137
- <th>Salary</th>
138
- <th>Action</th>
139
- </tr>
140
- </thead>
141
- <tbody>
142
- <tr v-if="companyStore.employees.length === 0">
143
- <td colspan="6" class="empty">No employees found</td>
144
- </tr>
145
- <tr v-for="emp in companyStore.employees" :key="emp.id">
146
- <td>{{ emp.id }}</td>
147
- <td>{{ emp.name }}</td>
148
- <td>{{ emp.email }}</td>
149
- <td>{{ getDepartmentName(emp.departmentId) }}</td>
150
- <td>${{ Number(emp.salary).toLocaleString() }}</td>
151
- <td>
152
- <button @click="companyStore.deleteEmployee(emp.id)" class="btn btn-danger">Delete</button>
153
- </td>
154
- </tr>
155
- </tbody>
156
- </table>
157
- </div>
158
- </section>
159
- </div>
160
- </div>
161
- </template>
162
-
163
- <script setup>
164
- import { reactive, onMounted } from 'vue'
165
- import { useCompanyStore } from './stores/companyStore'
166
-
167
- const companyStore = useCompanyStore()
168
-
169
- const deptForm = reactive({
170
- name: '',
171
- code: ''
172
- })
173
-
174
- const empForm = reactive({
175
- name: '',
176
- email: '',
177
- departmentId: '',
178
- salary: ''
179
- })
180
-
181
- const handleCreateDepartment = async () => {
182
- if (!deptForm.name || !deptForm.code) return
183
- await companyStore.createDepartment({
184
- name: deptForm.name,
185
- code: deptForm.code
186
- })
187
- deptForm.name = ''
188
- deptForm.code = ''
189
- }
190
-
191
- const handleCreateEmployee = async () => {
192
- if (!empForm.name || !empForm.email || !empForm.departmentId) return
193
- await companyStore.createEmployee({
194
- name: empForm.name,
195
- email: empForm.email,
196
- departmentId: empForm.departmentId,
197
- salary: Number(empForm.salary) || 0
198
- })
199
- empForm.name = ''
200
- empForm.email = ''
201
- empForm.departmentId = ''
202
- empForm.salary = ''
203
- }
204
-
205
- const getDepartmentName = (deptId) => {
206
- const dept = companyStore.departments.find(d => d.id === deptId)
207
- return dept ? dept.name : (deptId || 'N/A')
208
- }
209
-
210
- onMounted(() => {
211
- companyStore.fetchDepartments()
212
- companyStore.fetchEmployees()
213
- })
214
- </script>
215
-
216
- <style>
217
- * {
218
- box-sizing: border-box;
219
- margin: 0;
220
- padding: 0;
221
- }
222
-
223
- body {
224
- font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
225
- background-color: #f4f5f7;
226
- color: #333333;
227
- line-height: 1.5;
228
- }
229
-
230
- .container {
231
- max-width: 1200px;
232
- margin: 0 auto;
233
- padding: 32px 16px;
234
- }
235
-
236
- .header {
237
- margin-bottom: 24px;
238
- }
239
-
240
- .header h1 {
241
- font-size: 28px;
242
- color: #1a1a1a;
243
- }
244
-
245
- .header p {
246
- color: #666666;
247
- font-size: 14px;
248
- }
249
-
250
- .stats-grid {
251
- display: grid;
252
- grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
253
- gap: 16px;
254
- margin-bottom: 24px;
255
- }
256
-
257
- .stat-card {
258
- background: #ffffff;
259
- border: 1px solid #e1e4e8;
260
- border-radius: 8px;
261
- padding: 16px;
262
- box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
263
- }
264
-
265
- .stat-card h3 {
266
- font-size: 13px;
267
- text-transform: uppercase;
268
- color: #666666;
269
- margin-bottom: 6px;
270
- }
271
-
272
- .stat-value {
273
- font-size: 24px;
274
- font-weight: 700;
275
- color: #0969da;
276
- }
277
-
278
- .status-msg {
279
- padding: 10px 14px;
280
- border-radius: 6px;
281
- font-size: 14px;
282
- margin-bottom: 20px;
283
- }
284
-
285
- .status-msg.info {
286
- background-color: #ddf4ff;
287
- color: #0969da;
288
- border: 1px solid #54aeff66;
289
- }
290
-
291
- .status-msg.error {
292
- background-color: #ffebe9;
293
- color: #cf222e;
294
- border: 1px solid #ff818266;
295
- }
296
-
297
- .main-grid {
298
- display: grid;
299
- grid-template-columns: 1fr;
300
- gap: 24px;
301
- }
302
-
303
- @media (min-width: 900px) {
304
- .main-grid {
305
- grid-template-columns: 1fr 1fr;
306
- }
307
- }
308
-
309
- .card {
310
- background: #ffffff;
311
- border: 1px solid #e1e4e8;
312
- border-radius: 8px;
313
- padding: 20px;
314
- box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
315
- }
316
-
317
- .card h2 {
318
- font-size: 20px;
319
- margin-bottom: 16px;
320
- color: #24292f;
321
- border-bottom: 1px solid #eaecef;
322
- padding-bottom: 8px;
323
- }
324
-
325
- .form {
326
- display: flex;
327
- flex-direction: column;
328
- gap: 12px;
329
- margin-bottom: 24px;
330
- }
331
-
332
- .form-group {
333
- display: flex;
334
- flex-direction: column;
335
- gap: 4px;
336
- }
337
-
338
- .form-group label {
339
- font-size: 13px;
340
- font-weight: 600;
341
- color: #444444;
342
- }
343
-
344
- .form-group input,
345
- .form-group select {
346
- padding: 8px 12px;
347
- border: 1px solid #d0d7de;
348
- border-radius: 6px;
349
- font-size: 14px;
350
- background-color: #ffffff;
351
- color: #24292f;
352
- outline: none;
353
- }
354
-
355
- .form-group input:focus,
356
- .form-group select:focus {
357
- border-color: #0969da;
358
- box-shadow: 0 0 0 3px rgba(9, 105, 218, 0.15);
359
- }
360
-
361
- .btn {
362
- display: inline-block;
363
- padding: 8px 16px;
364
- font-size: 14px;
365
- font-weight: 500;
366
- border-radius: 6px;
367
- border: 1px solid transparent;
368
- cursor: pointer;
369
- text-align: center;
370
- transition: background-color 0.15s ease-in-out;
371
- }
372
-
373
- .btn-primary {
374
- background-color: #1f883d;
375
- color: #ffffff;
376
- }
377
-
378
- .btn-primary:hover {
379
- background-color: #1a7f37;
380
- }
381
-
382
- .btn-danger {
383
- background-color: #cf222e;
384
- color: #ffffff;
385
- padding: 4px 10px;
386
- font-size: 12px;
387
- }
388
-
389
- .btn-danger:hover {
390
- background-color: #a40e26;
391
- }
392
-
393
- .table-wrapper {
394
- overflow-x: auto;
395
- }
396
-
397
- table {
398
- width: 100%;
399
- border-collapse: collapse;
400
- font-size: 14px;
401
- text-align: left;
402
- }
403
-
404
- th, td {
405
- padding: 10px 12px;
406
- border-bottom: 1px solid #e1e4e8;
407
- }
408
-
409
- th {
410
- background-color: #f6f8fa;
411
- font-weight: 600;
412
- color: #57606a;
413
- }
414
-
415
- td code {
416
- background-color: #eff1f3;
417
- padding: 2px 6px;
418
- border-radius: 4px;
419
- font-size: 12px;
420
- }
421
-
422
- .empty {
423
- text-align: center;
424
- color: #8c959f;
425
- padding: 24px;
426
- }
427
- </style>
1
+ <template>
2
+ <div class="container">
3
+ <header class="header">
4
+ <h1>Company Management</h1>
5
+ <p>Vue 3 + Axios + Pinia</p>
6
+ </header>
7
+
8
+ <div class="stats-grid">
9
+ <div class="stat-card">
10
+ <h3>Total Departments</h3>
11
+ <p class="stat-value">{{ companyStore.totalDepartments }}</p>
12
+ </div>
13
+ <div class="stat-card">
14
+ <h3>Total Employees</h3>
15
+ <p class="stat-value">{{ companyStore.totalEmployees }}</p>
16
+ </div>
17
+ <div class="stat-card">
18
+ <h3>Total Payroll</h3>
19
+ <p class="stat-value">${{ companyStore.totalPayroll.toLocaleString() }}</p>
20
+ </div>
21
+ </div>
22
+
23
+ <div v-if="companyStore.loading" class="status-msg info">Loading data...</div>
24
+ <div v-if="companyStore.error" class="status-msg error">{{ companyStore.error }}</div>
25
+
26
+ <div class="main-grid">
27
+ <section class="card">
28
+ <h2>Departments</h2>
29
+
30
+ <form @submit.prevent="handleCreateDepartment" class="form">
31
+ <div class="form-group">
32
+ <label for="dept-name">Department Name</label>
33
+ <input
34
+ id="dept-name"
35
+ v-model="deptForm.name"
36
+ type="text"
37
+ required
38
+ placeholder="e.g. Engineering"
39
+ />
40
+ </div>
41
+ <div class="form-group">
42
+ <label for="dept-code">Department Code</label>
43
+ <input
44
+ id="dept-code"
45
+ v-model="deptForm.code"
46
+ type="text"
47
+ required
48
+ placeholder="e.g. ENG"
49
+ />
50
+ </div>
51
+ <button type="submit" class="btn btn-primary">Add Department</button>
52
+ </form>
53
+
54
+ <div class="table-wrapper">
55
+ <table>
56
+ <thead>
57
+ <tr>
58
+ <th>ID</th>
59
+ <th>Name</th>
60
+ <th>Code</th>
61
+ <th>Action</th>
62
+ </tr>
63
+ </thead>
64
+ <tbody>
65
+ <tr v-if="companyStore.departments.length === 0">
66
+ <td colspan="4" class="empty">No departments found</td>
67
+ </tr>
68
+ <tr v-for="dept in companyStore.departments" :key="dept.id">
69
+ <td>{{ dept.id }}</td>
70
+ <td>{{ dept.name }}</td>
71
+ <td><code>{{ dept.code }}</code></td>
72
+ <td>
73
+ <button @click="handlePatchDepartment(dept.id, dept.code)" class="btn">Patch</button>
74
+ <button @click="companyStore.deleteDepartment(dept.id)" class="btn btn-danger">Delete</button>
75
+ </td>
76
+ </tr>
77
+ </tbody>
78
+ </table>
79
+ </div>
80
+ </section>
81
+
82
+ <section class="card">
83
+ <h2>Employees</h2>
84
+
85
+ <form @submit.prevent="handleCreateEmployee" class="form">
86
+ <div class="form-group">
87
+ <label for="emp-name">Full Name</label>
88
+ <input
89
+ id="emp-name"
90
+ v-model="empForm.name"
91
+ type="text"
92
+ required
93
+ placeholder="e.g. Jane Doe"
94
+ />
95
+ </div>
96
+ <div class="form-group">
97
+ <label for="emp-email">Email Address</label>
98
+ <input
99
+ id="emp-email"
100
+ v-model="empForm.email"
101
+ type="email"
102
+ required
103
+ placeholder="e.g. jane@example.com"
104
+ />
105
+ </div>
106
+ <div class="form-group">
107
+ <label for="emp-dept">Department</label>
108
+ <select id="emp-dept" v-model="empForm.departmentId" required>
109
+ <option value="" disabled>Select Department</option>
110
+ <option v-for="dept in companyStore.departments" :key="dept.id" :value="dept.id">
111
+ {{ dept.name }} ({{ dept.code }})
112
+ </option>
113
+ </select>
114
+ </div>
115
+ <div class="form-group">
116
+ <label for="emp-salary">Salary</label>
117
+ <input
118
+ id="emp-salary"
119
+ v-model.number="empForm.salary"
120
+ type="number"
121
+ min="0"
122
+ step="any"
123
+ required
124
+ placeholder="e.g. 75000"
125
+ />
126
+ </div>
127
+ <button type="submit" class="btn btn-primary">Add Employee</button>
128
+ </form>
129
+
130
+ <div class="table-wrapper">
131
+ <table>
132
+ <thead>
133
+ <tr>
134
+ <th>ID</th>
135
+ <th>Name</th>
136
+ <th>Email</th>
137
+ <th>Department</th>
138
+ <th>Salary</th>
139
+ <th>Action</th>
140
+ </tr>
141
+ </thead>
142
+ <tbody>
143
+ <tr v-if="companyStore.employees.length === 0">
144
+ <td colspan="6" class="empty">No employees found</td>
145
+ </tr>
146
+ <tr v-for="emp in companyStore.employees" :key="emp.id">
147
+ <td>{{ emp.id }}</td>
148
+ <td>{{ emp.name }}</td>
149
+ <td>{{ emp.email }}</td>
150
+ <td>{{ getDepartmentName(emp.departmentId) }}</td>
151
+ <td>${{ Number(emp.salary).toLocaleString() }}</td>
152
+ <td>
153
+ <button @click="handlePatchEmployee(emp.id, emp.salary)" class="btn">Patch</button>
154
+ <button @click="companyStore.deleteEmployee(emp.id)" class="btn btn-danger">Delete</button>
155
+ </td>
156
+ </tr>
157
+ </tbody>
158
+ </table>
159
+ </div>
160
+ </section>
161
+ </div>
162
+ </div>
163
+ </template>
164
+
165
+ <script setup>
166
+ import { reactive, onMounted } from 'vue'
167
+ import { useCompanyStore } from './stores/companyStore'
168
+
169
+ const companyStore = useCompanyStore()
170
+
171
+ const deptForm = reactive({
172
+ name: '',
173
+ code: ''
174
+ })
175
+
176
+ const empForm = reactive({
177
+ name: '',
178
+ email: '',
179
+ departmentId: '',
180
+ salary: ''
181
+ })
182
+
183
+ const handleCreateDepartment = async () => {
184
+ if (!deptForm.name || !deptForm.code) return
185
+ await companyStore.createDepartment({
186
+ name: deptForm.name,
187
+ code: deptForm.code
188
+ })
189
+ deptForm.name = ''
190
+ deptForm.code = ''
191
+ }
192
+
193
+ const handleCreateEmployee = async () => {
194
+ if (!empForm.name || !empForm.email || !empForm.departmentId) return
195
+ await companyStore.createEmployee({
196
+ name: empForm.name,
197
+ email: empForm.email,
198
+ departmentId: empForm.departmentId,
199
+ salary: Number(empForm.salary) || 0
200
+ })
201
+ empForm.name = ''
202
+ empForm.email = ''
203
+ empForm.departmentId = ''
204
+ empForm.salary = ''
205
+ }
206
+
207
+ const handlePatchDepartment = async (id, currentCode) => {
208
+ const code = prompt('Enter new department code:', currentCode)
209
+ if (!code || code === currentCode) return
210
+ await companyStore.patchDepartment(id, { code })
211
+ }
212
+
213
+ const handlePatchEmployee = async (id, currentSalary) => {
214
+ const salary = prompt('Enter new salary:', currentSalary)
215
+ if (!salary || Number(salary) === Number(currentSalary)) return
216
+ await companyStore.patchEmployee(id, { salary: Number(salary) })
217
+ }
218
+
219
+ const getDepartmentName = (deptId) => {
220
+ const dept = companyStore.departments.find(d => d.id === deptId)
221
+ return dept ? dept.name : (deptId || 'N/A')
222
+ }
223
+
224
+ onMounted(() => {
225
+ companyStore.fetchDepartments()
226
+ companyStore.fetchEmployees()
227
+ })
228
+ </script>
229
+
230
+ <style>
231
+ * {
232
+ box-sizing: border-box;
233
+ margin: 0;
234
+ padding: 0;
235
+ }
236
+
237
+ body {
238
+ font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
239
+ background-color: #f4f5f7;
240
+ color: #333333;
241
+ line-height: 1.5;
242
+ }
243
+
244
+ .container {
245
+ max-width: 1200px;
246
+ margin: 0 auto;
247
+ padding: 32px 16px;
248
+ }
249
+
250
+ .header {
251
+ margin-bottom: 24px;
252
+ }
253
+
254
+ .header h1 {
255
+ font-size: 28px;
256
+ color: #1a1a1a;
257
+ }
258
+
259
+ .header p {
260
+ color: #666666;
261
+ font-size: 14px;
262
+ }
263
+
264
+ .stats-grid {
265
+ display: grid;
266
+ grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
267
+ gap: 16px;
268
+ margin-bottom: 24px;
269
+ }
270
+
271
+ .stat-card {
272
+ background: #ffffff;
273
+ border: 1px solid #e1e4e8;
274
+ border-radius: 8px;
275
+ padding: 16px;
276
+ box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
277
+ }
278
+
279
+ .stat-card h3 {
280
+ font-size: 13px;
281
+ text-transform: uppercase;
282
+ color: #666666;
283
+ margin-bottom: 6px;
284
+ }
285
+
286
+ .stat-value {
287
+ font-size: 24px;
288
+ font-weight: 700;
289
+ color: #0969da;
290
+ }
291
+
292
+ .status-msg {
293
+ padding: 10px 14px;
294
+ border-radius: 6px;
295
+ font-size: 14px;
296
+ margin-bottom: 20px;
297
+ }
298
+
299
+ .status-msg.info {
300
+ background-color: #ddf4ff;
301
+ color: #0969da;
302
+ border: 1px solid #54aeff66;
303
+ }
304
+
305
+ .status-msg.error {
306
+ background-color: #ffebe9;
307
+ color: #cf222e;
308
+ border: 1px solid #ff818266;
309
+ }
310
+
311
+ .main-grid {
312
+ display: grid;
313
+ grid-template-columns: 1fr;
314
+ gap: 24px;
315
+ }
316
+
317
+ @media (min-width: 900px) {
318
+ .main-grid {
319
+ grid-template-columns: 1fr 1fr;
320
+ }
321
+ }
322
+
323
+ .card {
324
+ background: #ffffff;
325
+ border: 1px solid #e1e4e8;
326
+ border-radius: 8px;
327
+ padding: 20px;
328
+ box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
329
+ }
330
+
331
+ .card h2 {
332
+ font-size: 20px;
333
+ margin-bottom: 16px;
334
+ color: #24292f;
335
+ border-bottom: 1px solid #eaecef;
336
+ padding-bottom: 8px;
337
+ }
338
+
339
+ .form {
340
+ display: flex;
341
+ flex-direction: column;
342
+ gap: 12px;
343
+ margin-bottom: 24px;
344
+ }
345
+
346
+ .form-group {
347
+ display: flex;
348
+ flex-direction: column;
349
+ gap: 4px;
350
+ }
351
+
352
+ .form-group label {
353
+ font-size: 13px;
354
+ font-weight: 600;
355
+ color: #444444;
356
+ }
357
+
358
+ .form-group input,
359
+ .form-group select {
360
+ padding: 8px 12px;
361
+ border: 1px solid #d0d7de;
362
+ border-radius: 6px;
363
+ font-size: 14px;
364
+ background-color: #ffffff;
365
+ color: #24292f;
366
+ outline: none;
367
+ }
368
+
369
+ .form-group input:focus,
370
+ .form-group select:focus {
371
+ border-color: #0969da;
372
+ box-shadow: 0 0 0 3px rgba(9, 105, 218, 0.15);
373
+ }
374
+
375
+ .btn {
376
+ display: inline-block;
377
+ padding: 8px 16px;
378
+ font-size: 14px;
379
+ font-weight: 500;
380
+ border-radius: 6px;
381
+ border: 1px solid transparent;
382
+ cursor: pointer;
383
+ text-align: center;
384
+ transition: background-color 0.15s ease-in-out;
385
+ }
386
+
387
+ .btn-primary {
388
+ background-color: #1f883d;
389
+ color: #ffffff;
390
+ }
391
+
392
+ .btn-primary:hover {
393
+ background-color: #1a7f37;
394
+ }
395
+
396
+ .btn-danger {
397
+ background-color: #cf222e;
398
+ color: #ffffff;
399
+ padding: 4px 10px;
400
+ font-size: 12px;
401
+ }
402
+
403
+ .btn-danger:hover {
404
+ background-color: #a40e26;
405
+ }
406
+
407
+ .table-wrapper {
408
+ overflow-x: auto;
409
+ }
410
+
411
+ table {
412
+ width: 100%;
413
+ border-collapse: collapse;
414
+ font-size: 14px;
415
+ text-align: left;
416
+ }
417
+
418
+ th, td {
419
+ padding: 10px 12px;
420
+ border-bottom: 1px solid #e1e4e8;
421
+ }
422
+
423
+ th {
424
+ background-color: #f6f8fa;
425
+ font-weight: 600;
426
+ color: #57606a;
427
+ }
428
+
429
+ td code {
430
+ background-color: #eff1f3;
431
+ padding: 2px 6px;
432
+ border-radius: 4px;
433
+ font-size: 12px;
434
+ }
435
+
436
+ .empty {
437
+ text-align: center;
438
+ color: #8c959f;
439
+ padding: 24px;
440
+ }
441
+ </style>