wad-lab 1.2.2 → 1.2.4

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 +477 -627
  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
@@ -7,14 +7,14 @@ export const useBankStore = defineStore('bank', {
7
7
  accountType: 'Savings Account',
8
8
  balance: 5000,
9
9
  transactions: [
10
- { id: 1, type: 'DEPOSIT', amount: 5000, balanceAfter: 5000, date: new Date().toLocaleDateString() }
10
+ { id: 1, type: 'DEPOSIT', amount: 5000, balanceAfter: 5000, note: 'Initial deposit', date: new Date().toLocaleDateString() }
11
11
  ]
12
12
  }),
13
13
  getters: {
14
14
  transactionCount: (state) => state.transactions.length
15
15
  },
16
16
  actions: {
17
- deposit(amount) {
17
+ deposit(amount, note = '') {
18
18
  const val = parseFloat(amount)
19
19
  if (isNaN(val) || val <= 0) return { success: false, message: 'Invalid deposit amount' }
20
20
 
@@ -24,12 +24,13 @@ export const useBankStore = defineStore('bank', {
24
24
  type: 'DEPOSIT',
25
25
  amount: val,
26
26
  balanceAfter: this.balance,
27
+ note: note || 'Deposit',
27
28
  date: new Date().toLocaleDateString()
28
29
  })
29
30
  return { success: true, message: 'Deposit successful!' }
30
31
  },
31
32
 
32
- withdraw(amount) {
33
+ withdraw(amount, note = '') {
33
34
  const val = parseFloat(amount)
34
35
  if (isNaN(val) || val <= 0) return { success: false, message: 'Invalid withdrawal amount' }
35
36
  if (val > this.balance) return { success: false, message: 'Insufficient balance!' }
@@ -40,9 +41,21 @@ export const useBankStore = defineStore('bank', {
40
41
  type: 'WITHDRAWAL',
41
42
  amount: val,
42
43
  balanceAfter: this.balance,
44
+ note: note || 'Withdrawal',
43
45
  date: new Date().toLocaleDateString()
44
46
  })
45
47
  return { success: true, message: 'Withdrawal successful!' }
48
+ },
49
+
50
+ patchTransaction(id, partial) {
51
+ const item = this.transactions.find(t => t.id === id)
52
+ if (item) {
53
+ Object.assign(item, partial)
54
+ }
55
+ },
56
+
57
+ deleteTransaction(id) {
58
+ this.transactions = this.transactions.filter(t => t.id !== id)
46
59
  }
47
60
  }
48
61
  })
@@ -1,88 +1,40 @@
1
1
  <script setup>
2
2
  import { useBankStore } from '../stores/bankStore'
3
+ import AccountOverview from '../components/AccountOverview.vue'
4
+ import TransactionTable from '../components/TransactionTable.vue'
3
5
 
4
6
  const bank = useBankStore()
5
7
  </script>
6
8
 
7
9
  <template>
8
- <div class="dashboard-card">
9
- <h2>Account Overview</h2>
10
- <div class="info-row">
11
- <span>Account Holder:</span>
12
- <strong>{{ bank.accountHolder }}</strong>
13
- </div>
14
- <div class="info-row">
15
- <span>Account Number:</span>
16
- <strong>{{ bank.accountNumber }}</strong>
17
- </div>
18
- <div class="info-row">
19
- <span>Account Type:</span>
20
- <strong>{{ bank.accountType }}</strong>
21
- </div>
22
- <div class="balance-box">
23
- <span>Available Balance</span>
24
- <h3 class="balance-val">${{ bank.balance.toFixed(2) }}</h3>
25
- </div>
26
-
27
- <div class="quick-actions">
28
- <router-link to="/transaction" class="btn btn-primary">Deposit / Withdraw</router-link>
29
- <router-link to="/statement" class="btn btn-secondary">View Statement ({{ bank.transactionCount }})</router-link>
10
+ <div class="dashboard-grid">
11
+ <AccountOverview
12
+ :account-holder="bank.accountHolder"
13
+ :account-number="bank.accountNumber"
14
+ :account-type="bank.accountType"
15
+ :balance="bank.balance"
16
+ />
17
+
18
+ <div class="recent-tx">
19
+ <h3>Recent Transactions</h3>
20
+ <TransactionTable
21
+ :transactions="bank.transactions.slice(0, 5)"
22
+ @patch="({ id, note }) => bank.patchTransaction(id, { note })"
23
+ @delete="(id) => bank.deleteTransaction(id)"
24
+ />
30
25
  </div>
31
26
  </div>
32
27
  </template>
33
28
 
34
29
  <style scoped>
35
- .dashboard-card {
36
- border: 1px solid #ddd;
37
- border-radius: 8px;
38
- padding: 20px;
39
- background-color: #fafafa;
40
- }
41
-
42
- .info-row {
43
- display: flex;
44
- justify-content: space-between;
45
- padding: 8px 0;
46
- border-bottom: 1px solid #eee;
47
- }
48
-
49
- .balance-box {
50
- margin: 20px 0;
51
- padding: 15px;
52
- background-color: #e8f8f5;
53
- border: 1px solid #a3e4d7;
54
- border-radius: 6px;
55
- text-align: center;
56
- }
57
-
58
- .balance-val {
59
- color: #16a085;
60
- font-size: 28px;
61
- margin: 5px 0 0 0;
62
- }
63
-
64
- .quick-actions {
30
+ .dashboard-grid {
65
31
  display: flex;
66
- gap: 10px;
67
- margin-top: 15px;
68
- }
69
-
70
- .btn {
71
- flex: 1;
72
- text-align: center;
73
- padding: 10px;
74
- border-radius: 4px;
75
- text-decoration: none;
76
- font-weight: bold;
77
- }
78
-
79
- .btn-primary {
80
- background-color: #2980b9;
81
- color: white;
32
+ flex-direction: column;
33
+ gap: 20px;
82
34
  }
83
35
 
84
- .btn-secondary {
85
- background-color: #7f8c8d;
86
- color: white;
36
+ .recent-tx h3 {
37
+ font-size: 16px;
38
+ margin-bottom: 10px;
87
39
  }
88
40
  </style>
@@ -1,171 +1,24 @@
1
1
  <script setup>
2
- import { computed } from 'vue'
3
2
  import { useBankStore } from '../stores/bankStore'
3
+ import TransactionTable from '../components/TransactionTable.vue'
4
4
 
5
5
  const bank = useBankStore()
6
-
7
- const totalDeposits = computed(() => {
8
- return bank.transactions
9
- .filter(tx => tx.type === 'DEPOSIT')
10
- .reduce((sum, tx) => sum + tx.amount, 0)
11
- })
12
-
13
- const totalWithdrawals = computed(() => {
14
- return bank.transactions
15
- .filter(tx => tx.type === 'WITHDRAWAL')
16
- .reduce((sum, tx) => sum + tx.amount, 0)
17
- })
18
6
  </script>
19
7
 
20
8
  <template>
21
- <div class="statement-card">
22
- <div class="header-row">
23
- <h2>Account Statement</h2>
24
- <router-link to="/" class="btn btn-back">Back to Dashboard</router-link>
25
- </div>
26
-
27
- <div class="summary-cards">
28
- <div class="summary-box deposits">
29
- <span>Total Deposits</span>
30
- <strong>${{ totalDeposits.toFixed(2) }}</strong>
31
- </div>
32
- <div class="summary-box withdrawals">
33
- <span>Total Withdrawals</span>
34
- <strong>${{ totalWithdrawals.toFixed(2) }}</strong>
35
- </div>
36
- <div class="summary-box balance">
37
- <span>Current Balance</span>
38
- <strong>${{ bank.balance.toFixed(2) }}</strong>
39
- </div>
40
- </div>
41
-
42
- <div class="table-container">
43
- <table class="statement-table" v-if="bank.transactions.length">
44
- <thead>
45
- <tr>
46
- <th>Date</th>
47
- <th>Type</th>
48
- <th>Amount</th>
49
- <th>Balance After</th>
50
- </tr>
51
- </thead>
52
- <tbody>
53
- <tr v-for="tx in bank.transactions" :key="tx.id">
54
- <td>{{ tx.date }}</td>
55
- <td :class="tx.type === 'DEPOSIT' ? 'type-deposit' : 'type-withdrawal'">{{ tx.type }}</td>
56
- <td>${{ tx.amount.toFixed(2) }}</td>
57
- <td>${{ tx.balanceAfter.toFixed(2) }}</td>
58
- </tr>
59
- </tbody>
60
- </table>
61
- <p v-else class="empty-state">No transactions recorded yet.</p>
62
- </div>
9
+ <div class="statement-view">
10
+ <h2>Account Statement</h2>
11
+ <TransactionTable
12
+ :transactions="bank.transactions"
13
+ @patch="({ id, note }) => bank.patchTransaction(id, { note })"
14
+ @delete="(id) => bank.deleteTransaction(id)"
15
+ />
63
16
  </div>
64
17
  </template>
65
18
 
66
19
  <style scoped>
67
- .statement-card {
68
- border: 1px solid #ddd;
69
- border-radius: 8px;
70
- padding: 20px;
71
- background-color: #fafafa;
72
- }
73
-
74
- .header-row {
75
- display: flex;
76
- justify-content: space-between;
77
- align-items: center;
78
- margin-bottom: 20px;
79
- }
80
-
81
- .summary-cards {
82
- display: grid;
83
- grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
84
- gap: 12px;
85
- margin-bottom: 20px;
86
- }
87
-
88
- .summary-box {
89
- padding: 12px;
90
- border-radius: 6px;
91
- display: flex;
92
- flex-direction: column;
93
- gap: 4px;
94
- }
95
-
96
- .summary-box.deposits {
97
- background-color: #e8f8f5;
98
- border: 1px solid #a3e4d7;
99
- color: #16a085;
100
- }
101
-
102
- .summary-box.withdrawals {
103
- background-color: #fdebd0;
104
- border: 1px solid #f8c471;
105
- color: #d35400;
106
- }
107
-
108
- .summary-box.balance {
109
- background-color: #ebf5fb;
110
- border: 1px solid #aed6f1;
111
- color: #2980b9;
112
- }
113
-
114
- .summary-box span {
115
- font-size: 13px;
116
- color: #555;
117
- }
118
-
119
- .summary-box strong {
120
- font-size: 18px;
121
- }
122
-
123
- .table-container {
124
- overflow-x: auto;
125
- }
126
-
127
- .statement-table {
128
- width: 100%;
129
- border-collapse: collapse;
130
- }
131
-
132
- .statement-table th,
133
- .statement-table td {
134
- padding: 10px;
135
- text-align: left;
136
- border-bottom: 1px solid #eee;
137
- }
138
-
139
- .statement-table th {
140
- background-color: #f2f2f2;
141
- }
142
-
143
- .type-deposit {
144
- color: #27ae60;
145
- font-weight: bold;
146
- }
147
-
148
- .type-withdrawal {
149
- color: #c0392b;
150
- font-weight: bold;
151
- }
152
-
153
- .btn {
154
- padding: 8px 14px;
155
- border-radius: 4px;
156
- text-decoration: none;
157
- font-weight: bold;
158
- font-size: 14px;
159
- }
160
-
161
- .btn-back {
162
- background-color: #7f8c8d;
163
- color: white;
164
- }
165
-
166
- .empty-state {
167
- text-align: center;
168
- color: #777;
169
- padding: 20px;
20
+ .statement-view h2 {
21
+ font-size: 20px;
22
+ margin-bottom: 16px;
170
23
  }
171
24
  </style>
@@ -1,144 +1,46 @@
1
1
  <script setup>
2
2
  import { ref } from 'vue'
3
- import { useRouter } from 'vue-router'
4
3
  import { useBankStore } from '../stores/bankStore'
4
+ import TransactionForm from '../components/TransactionForm.vue'
5
5
 
6
6
  const bank = useBankStore()
7
- const router = useRouter()
8
-
9
- const txType = ref('DEPOSIT')
10
- const amount = ref('')
11
- const feedback = ref({ text: '', isError: false })
12
-
13
- function handleSubmit() {
14
- feedback.value = { text: '', isError: false }
7
+ const statusMessage = ref('')
15
8
 
9
+ function handleTransaction({ type, amount, note }) {
16
10
  let res
17
- if (txType.value === 'DEPOSIT') {
18
- res = bank.deposit(amount.value)
11
+ if (type === 'DEPOSIT') {
12
+ res = bank.deposit(amount, note)
19
13
  } else {
20
- res = bank.withdraw(amount.value)
21
- }
22
-
23
- if (res.success) {
24
- feedback.value = { text: res.message, isError: false }
25
- amount.value = ''
26
- setTimeout(() => {
27
- router.push('/statement')
28
- }, 1000)
29
- } else {
30
- feedback.value = { text: res.message, isError: true }
14
+ res = bank.withdraw(amount, note)
31
15
  }
16
+ statusMessage.value = res.message
32
17
  }
33
18
  </script>
34
19
 
35
20
  <template>
36
- <div class="tx-card">
37
- <h2>Make a Transaction</h2>
38
- <p>Current Balance: <strong>${{ bank.balance.toFixed(2) }}</strong></p>
39
-
40
- <div v-if="feedback.text" :class="['alert', feedback.isError ? 'alert-danger' : 'alert-success']">
41
- {{ feedback.text }}
42
- </div>
43
-
44
- <form @submit.prevent="handleSubmit" class="tx-form">
45
- <div class="form-group">
46
- <label>Transaction Type:</label>
47
- <div class="radio-row">
48
- <label>
49
- <input type="radio" value="DEPOSIT" v-model="txType" /> Deposit
50
- </label>
51
- <label>
52
- <input type="radio" value="WITHDRAWAL" v-model="txType" /> Withdrawal
53
- </label>
54
- </div>
55
- </div>
56
-
57
- <div class="form-group">
58
- <label for="amt">Amount ($):</label>
59
- <input id="amt" type="number" step="0.01" min="1" v-model="amount" placeholder="e.g. 250.00" required />
60
- </div>
61
-
62
- <div class="btn-row">
63
- <button type="submit" class="btn btn-submit">Confirm {{ txType }}</button>
64
- <router-link to="/" class="btn btn-back">Cancel</router-link>
65
- </div>
66
- </form>
21
+ <div class="tx-view">
22
+ <h2>Record New Transaction</h2>
23
+ <div v-if="statusMessage" class="status-box">{{ statusMessage }}</div>
24
+ <TransactionForm @submit-transaction="handleTransaction" />
67
25
  </div>
68
26
  </template>
69
27
 
70
28
  <style scoped>
71
- .tx-card {
72
- border: 1px solid #ddd;
73
- border-radius: 8px;
74
- padding: 20px;
75
- background-color: #fafafa;
76
- }
77
-
78
- .alert {
79
- padding: 10px;
80
- border-radius: 4px;
81
- margin-bottom: 15px;
82
- }
83
-
84
- .alert-success {
85
- background-color: #d4edda;
86
- color: #155724;
87
- }
88
-
89
- .alert-danger {
90
- background-color: #f8d7da;
91
- color: #721c24;
92
- }
93
-
94
- .tx-form {
95
- display: flex;
96
- flex-direction: column;
97
- gap: 15px;
98
- }
99
-
100
- .form-group {
101
- display: flex;
102
- flex-direction: column;
103
- gap: 5px;
104
- }
105
-
106
- .radio-row {
107
- display: flex;
108
- gap: 20px;
109
- }
110
-
111
- input[type="number"] {
112
- padding: 8px;
113
- font-size: 16px;
114
- border: 1px solid #ccc;
115
- border-radius: 4px;
116
- }
117
-
118
- .btn-row {
119
- display: flex;
120
- gap: 10px;
121
- margin-top: 10px;
122
- }
123
-
124
- .btn {
125
- padding: 10px 16px;
126
- border: none;
127
- border-radius: 4px;
128
- cursor: pointer;
129
- text-decoration: none;
130
- font-weight: bold;
29
+ .tx-view {
30
+ max-width: 480px;
131
31
  }
132
32
 
133
- .btn-submit {
134
- background-color: #27ae60;
135
- color: white;
33
+ .tx-view h2 {
34
+ font-size: 20px;
35
+ margin-bottom: 16px;
136
36
  }
137
37
 
138
- .btn-back {
139
- background-color: #95a5a6;
140
- color: white;
141
- display: inline-flex;
142
- align-items: center;
38
+ .status-box {
39
+ padding: 10px 14px;
40
+ background: #f0fdf4;
41
+ color: #166534;
42
+ border-radius: 6px;
43
+ margin-bottom: 16px;
44
+ border: 1px solid #bbf7d0;
143
45
  }
144
46
  </style>