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.
- package/bin/index.js +477 -627
- package/package.json +1 -1
- package/templates/fullstack-springboot-vue/frontend/vue-axios-basic/src/App.vue +241 -429
- package/templates/fullstack-springboot-vue/frontend/vue-axios-basic/src/components/ItemFormModal.vue +183 -0
- package/templates/fullstack-springboot-vue/frontend/vue-axios-basic/src/components/ItemPatchModal.vue +193 -0
- package/templates/fullstack-springboot-vue/frontend/vue-axios-basic/src/components/ItemTable.vue +177 -0
- package/templates/fullstack-springboot-vue/frontend/vue-axios-pinia/src/App.vue +150 -441
- package/templates/fullstack-springboot-vue/frontend/vue-axios-pinia/src/components/ItemFormModal.vue +207 -0
- package/templates/fullstack-springboot-vue/frontend/vue-axios-pinia/src/components/ItemStats.vue +64 -0
- package/templates/fullstack-springboot-vue/frontend/vue-axios-pinia/src/components/ItemTable.vue +195 -0
- package/templates/fullstack-springboot-vue/frontend/vue-axios-router/src/App.vue +41 -90
- package/templates/fullstack-springboot-vue/frontend/vue-axios-router/src/components/ItemFormModal.vue +173 -0
- package/templates/fullstack-springboot-vue/frontend/vue-axios-router/src/components/ItemTable.vue +102 -0
- package/templates/fullstack-springboot-vue/frontend/vue-axios-router/src/components/NavBar.vue +57 -0
- package/templates/fullstack-springboot-vue/frontend/vue-axios-router/src/views/DepartmentView.vue +132 -296
- package/templates/fullstack-springboot-vue/frontend/vue-axios-router/src/views/EmployeeView.vue +126 -219
- package/templates/fullstack-springboot-vue/frontend/vue-axios-router-children/src/components/ItemDetail.vue +115 -0
- package/templates/fullstack-springboot-vue/frontend/vue-axios-router-children/src/components/ItemTable.vue +104 -0
- package/templates/fullstack-springboot-vue/frontend/vue-axios-router-children/src/components/SideBar.vue +59 -0
- package/templates/fullstack-springboot-vue/frontend/vue-axios-router-children/src/views/CompanyLayout.vue +2 -51
- package/templates/fullstack-springboot-vue/frontend/vue-axios-router-children/src/views/DepartmentListView.vue +92 -250
- package/templates/fullstack-springboot-vue/frontend/vue-axios-router-children/src/views/EmployeeDetailView.vue +59 -181
- package/templates/fullstack-springboot-vue/frontend/vue-axios-router-children/src/views/EmployeeListView.vue +67 -315
- package/templates/fullstack-springboot-vue/frontend/vue-axios-router-pinia/src/App.vue +19 -70
- package/templates/fullstack-springboot-vue/frontend/vue-axios-router-pinia/src/components/ItemFormModal.vue +173 -0
- package/templates/fullstack-springboot-vue/frontend/vue-axios-router-pinia/src/components/ItemPatchModal.vue +144 -0
- package/templates/fullstack-springboot-vue/frontend/vue-axios-router-pinia/src/components/ItemTable.vue +102 -0
- package/templates/fullstack-springboot-vue/frontend/vue-axios-router-pinia/src/components/NavBar.vue +53 -0
- package/templates/fullstack-springboot-vue/frontend/vue-axios-router-pinia/src/views/DepartmentView.vue +107 -229
- package/templates/fullstack-springboot-vue/frontend/vue-axios-router-pinia/src/views/EmployeeView.vue +143 -257
- package/templates/game-bingo/script.js +1 -1
- package/templates/game-memory-cards/script.js +2 -2
- package/templates/game-rock-paper-scissors/index.html +3 -3
- package/templates/game-rock-paper-scissors/script.js +2 -2
- package/templates/game-tic-tac-toe/script.js +2 -2
- package/templates/game-whack-a-mole/index.html +9 -9
- package/templates/servlet-basic/WEB-INF/ItemServlet.java +13 -0
- package/templates/servlet-basic/WEB-INF/classes/ItemServlet.class +0 -0
- package/templates/servlet-flow/WEB-INF/HelloServlet.java +34 -25
- package/templates/servlet-flow/WEB-INF/classes/HelloServlet.class +0 -0
- package/templates/servlet-jdbc/WEB-INF/JdbcItemServlet.java +13 -0
- package/templates/servlet-jdbc/WEB-INF/classes/JdbcItemServlet.class +0 -0
- package/templates/snippets/mongo-queries-cheatsheet.txt +105 -0
- package/templates/springboot-2model-aggregation-join/.mvn/wrapper/maven-wrapper.properties +3 -0
- package/templates/springboot-2model-aggregation-join/mvnw +295 -0
- package/templates/springboot-2model-aggregation-join/mvnw.cmd +189 -0
- package/templates/springboot-2model-aggregation-join/pom.xml +54 -0
- package/templates/springboot-2model-aggregation-join/src/main/java/com/example/aggregation/AggregationApplication.java +11 -0
- package/templates/springboot-2model-aggregation-join/src/main/java/com/example/aggregation/controller/DepartmentController.java +65 -0
- package/templates/springboot-2model-aggregation-join/src/main/java/com/example/aggregation/controller/EmployeeController.java +65 -0
- package/templates/springboot-2model-aggregation-join/src/main/java/com/example/aggregation/dto/DepartmentStatsDTO.java +15 -0
- package/templates/springboot-2model-aggregation-join/src/main/java/com/example/aggregation/dto/EmployeeJoinDTO.java +19 -0
- package/templates/springboot-2model-aggregation-join/src/main/java/com/example/aggregation/model/Department.java +20 -0
- package/templates/springboot-2model-aggregation-join/src/main/java/com/example/aggregation/model/Employee.java +21 -0
- package/templates/springboot-2model-aggregation-join/src/main/java/com/example/aggregation/repository/DepartmentRepository.java +9 -0
- package/templates/springboot-2model-aggregation-join/src/main/java/com/example/aggregation/repository/EmployeeRepository.java +9 -0
- package/templates/springboot-2model-aggregation-join/src/main/java/com/example/aggregation/service/DepartmentService.java +81 -0
- package/templates/springboot-2model-aggregation-join/src/main/java/com/example/aggregation/service/EmployeeService.java +80 -0
- package/templates/springboot-2model-aggregation-join/src/main/resources/application.properties +2 -0
- package/templates/springboot-2model-aggregation-join/src/test/java/com/example/aggregation/AggregationApplicationTests.java +13 -0
- package/templates/vue-2model-crud-patch/README.md +64 -0
- package/templates/vue-2model-crud-patch/index.html +12 -0
- package/templates/vue-2model-crud-patch/package-lock.json +1785 -0
- package/templates/vue-2model-crud-patch/package.json +21 -0
- package/templates/vue-2model-crud-patch/src/App.vue +63 -0
- package/templates/vue-2model-crud-patch/src/components/AnalyticsBoard.vue +291 -0
- package/templates/vue-2model-crud-patch/src/components/DepartmentFormModal.vue +138 -0
- package/templates/vue-2model-crud-patch/src/components/DepartmentPatchModal.vue +210 -0
- package/templates/vue-2model-crud-patch/src/components/DepartmentTable.vue +133 -0
- package/templates/vue-2model-crud-patch/src/components/EmployeeFormModal.vue +177 -0
- package/templates/vue-2model-crud-patch/src/components/EmployeePatchModal.vue +221 -0
- package/templates/vue-2model-crud-patch/src/components/EmployeeTable.vue +171 -0
- package/templates/vue-2model-crud-patch/src/components/NavBar.vue +156 -0
- package/templates/vue-2model-crud-patch/src/main.js +12 -0
- package/templates/vue-2model-crud-patch/src/router/index.js +33 -0
- package/templates/vue-2model-crud-patch/src/services/api.js +64 -0
- package/templates/vue-2model-crud-patch/src/stores/departmentStore.js +149 -0
- package/templates/vue-2model-crud-patch/src/stores/employeeStore.js +143 -0
- package/templates/vue-2model-crud-patch/src/style.css +415 -0
- package/templates/vue-2model-crud-patch/src/views/AnalyticsView.vue +59 -0
- package/templates/vue-2model-crud-patch/src/views/DepartmentsView.vue +135 -0
- package/templates/vue-2model-crud-patch/src/views/EmployeesView.vue +143 -0
- package/templates/vue-2model-crud-patch/vite.config.js +9 -0
- package/templates/vue-axios/src/App.vue +255 -264
- package/templates/vue-axios/src/components/ItemFormModal.vue +183 -0
- package/templates/vue-axios/src/components/ItemPatchModal.vue +193 -0
- package/templates/vue-axios/src/components/ItemTable.vue +177 -0
- package/templates/vue-axios-basic/src/App.vue +241 -429
- package/templates/vue-axios-basic/src/components/ItemFormModal.vue +183 -0
- package/templates/vue-axios-basic/src/components/ItemPatchModal.vue +193 -0
- package/templates/vue-axios-basic/src/components/ItemTable.vue +177 -0
- package/templates/vue-axios-pinia/src/App.vue +150 -441
- package/templates/vue-axios-pinia/src/components/ItemFormModal.vue +207 -0
- package/templates/vue-axios-pinia/src/components/ItemStats.vue +64 -0
- package/templates/vue-axios-pinia/src/components/ItemTable.vue +195 -0
- package/templates/vue-axios-router/src/App.vue +41 -90
- package/templates/vue-axios-router/src/components/ItemFormModal.vue +173 -0
- package/templates/vue-axios-router/src/components/ItemTable.vue +102 -0
- package/templates/vue-axios-router/src/components/NavBar.vue +57 -0
- package/templates/vue-axios-router/src/views/DepartmentView.vue +132 -296
- package/templates/vue-axios-router/src/views/EmployeeView.vue +126 -219
- package/templates/vue-axios-router-children/src/components/ItemDetail.vue +115 -0
- package/templates/vue-axios-router-children/src/components/ItemTable.vue +104 -0
- package/templates/vue-axios-router-children/src/components/SideBar.vue +59 -0
- package/templates/vue-axios-router-children/src/views/CompanyLayout.vue +2 -51
- package/templates/vue-axios-router-children/src/views/DepartmentListView.vue +92 -250
- package/templates/vue-axios-router-children/src/views/EmployeeDetailView.vue +59 -181
- package/templates/vue-axios-router-children/src/views/EmployeeListView.vue +67 -315
- package/templates/vue-axios-router-pinia/src/App.vue +19 -70
- package/templates/vue-axios-router-pinia/src/components/ItemFormModal.vue +173 -0
- package/templates/vue-axios-router-pinia/src/components/ItemPatchModal.vue +144 -0
- package/templates/vue-axios-router-pinia/src/components/ItemTable.vue +102 -0
- package/templates/vue-axios-router-pinia/src/components/NavBar.vue +53 -0
- package/templates/vue-axios-router-pinia/src/views/DepartmentView.vue +107 -229
- package/templates/vue-axios-router-pinia/src/views/EmployeeView.vue +143 -257
- package/templates/vue-banking-app/src/components/AccountOverview.vue +75 -0
- package/templates/vue-banking-app/src/components/TransactionForm.vue +89 -0
- package/templates/vue-banking-app/src/components/TransactionTable.vue +113 -0
- package/templates/vue-banking-app/src/stores/bankStore.js +16 -3
- package/templates/vue-banking-app/src/views/DashboardView.vue +23 -71
- package/templates/vue-banking-app/src/views/StatementView.vue +11 -158
- package/templates/vue-banking-app/src/views/TransactionFormView.vue +23 -121
- package/templates/vue-basics/src/App.vue +105 -76
- package/templates/vue-basics/src/components/CounterCard.vue +107 -0
- package/templates/vue-basics/src/components/ItemList.vue +99 -0
- package/templates/vue-basics/src/components/UserForm.vue +138 -0
- package/templates/vue-cart-router-pinia/src/components/CartSummary.vue +139 -0
- package/templates/vue-cart-router-pinia/src/components/CheckoutModal.vue +149 -0
- package/templates/vue-cart-router-pinia/src/components/ProductCard.vue +63 -0
- package/templates/vue-cart-router-pinia/src/stores/cartStore.js +11 -0
- package/templates/vue-cart-router-pinia/src/views/CartView.vue +52 -118
- package/templates/vue-cart-router-pinia/src/views/CheckoutView.vue +2 -5
- package/templates/vue-cart-router-pinia/src/views/ProductCatalogView.vue +20 -56
- package/templates/vue-employee-system/src/App.vue +75 -344
- package/templates/vue-employee-system/src/components/DepartmentFilter.vue +108 -0
- package/templates/vue-employee-system/src/components/EmployeeModal.vue +183 -0
- package/templates/vue-employee-system/src/components/EmployeeTable.vue +91 -0
- package/templates/vue-employee-system/src/stores/employeeStore.js +12 -0
- package/templates/vue-fetch/src/App.vue +261 -285
- package/templates/vue-fetch/src/components/FetchFormModal.vue +183 -0
- package/templates/vue-fetch/src/components/FetchPatchModal.vue +193 -0
- package/templates/vue-fetch/src/components/FetchTable.vue +177 -0
- package/templates/vue-food-ordering/src/components/CartSummary.vue +134 -0
- package/templates/vue-food-ordering/src/components/FoodMenu.vue +126 -0
- package/templates/vue-food-ordering/src/components/OrderModal.vue +150 -0
- package/templates/vue-food-ordering/src/views/MenuView.vue +11 -132
- package/templates/vue-food-ordering/src/views/OrderCartView.vue +31 -164
- package/templates/vue-game-rps/src/App.vue +29 -88
- package/templates/vue-game-tictactoe/src/App.vue +23 -53
- package/templates/vue-game-whackamole/src/App.vue +44 -63
- package/templates/vue-hospital-portal/src/components/AppointmentForm.vue +144 -0
- package/templates/vue-hospital-portal/src/components/DoctorCard.vue +73 -0
- package/templates/vue-hospital-portal/src/components/PatientTable.vue +123 -0
- package/templates/vue-hospital-portal/src/stores/hospitalStore.js +10 -1
- package/templates/vue-hospital-portal/src/views/OPDRegistrationView.vue +40 -416
- package/templates/vue-hospital-portal/src/views/PatientListView.vue +11 -301
- package/templates/vue-library-system/src/components/BookForm.vue +125 -0
- package/templates/vue-library-system/src/components/BookTable.vue +112 -0
- package/templates/vue-library-system/src/components/BorrowModal.vue +131 -0
- package/templates/vue-library-system/src/stores/libraryStore.js +26 -1
- package/templates/vue-library-system/src/views/BookCatalogView.vue +34 -415
- package/templates/vue-memory-game/src/App.vue +36 -40
- package/templates/vue-memory-game/src/stores/memoryStore.js +32 -37
- package/templates/vue-router/src/App.vue +24 -14
- package/templates/vue-router/src/components/AboutCard.vue +38 -0
- package/templates/vue-router/src/components/HomeHero.vue +75 -0
- package/templates/vue-router/src/components/NavBar.vue +54 -0
- package/templates/vue-router/src/views/ItemsLayout.vue +17 -9
- package/templates/vue-router/src/views/ListView.vue +106 -18
- package/templates/vue-router-pinia/src/App.vue +24 -14
- package/templates/vue-router-pinia/src/components/ItemFormModal.vue +163 -0
- package/templates/vue-router-pinia/src/components/ItemTable.vue +90 -0
- package/templates/vue-router-pinia/src/components/NavBar.vue +54 -0
- package/templates/vue-router-pinia/src/stores/itemStore.js +8 -1
- package/templates/vue-router-pinia/src/views/ListView.vue +78 -14
- package/templates/vue-router-pinia-springboot/frontend/src/App.vue +25 -8
- package/templates/vue-router-pinia-springboot/frontend/src/components/ItemFormModal.vue +183 -0
- package/templates/vue-router-pinia-springboot/frontend/src/components/ItemPatchModal.vue +193 -0
- package/templates/vue-router-pinia-springboot/frontend/src/components/ItemTable.vue +177 -0
- package/templates/vue-router-pinia-springboot/frontend/src/components/NavBar.vue +54 -0
- package/templates/vue-router-pinia-springboot/frontend/src/views/ListView.vue +92 -76
- package/templates/vue-springboot-mongo-aggregation/frontend/src/App.vue +184 -193
- package/templates/vue-springboot-mongo-aggregation/frontend/src/components/AnalyticsCards.vue +56 -0
- package/templates/vue-springboot-mongo-aggregation/frontend/src/components/CategorySummaryTable.vue +71 -0
- package/templates/vue-springboot-mongo-aggregation/frontend/src/components/ItemTable.vue +114 -0
- package/templates/vue-springboot-mongo-crud/frontend/src/App.vue +228 -158
- package/templates/vue-springboot-mongo-crud/frontend/src/components/ItemFormModal.vue +183 -0
- package/templates/vue-springboot-mongo-crud/frontend/src/components/ItemPatchModal.vue +193 -0
- package/templates/vue-springboot-mongo-crud/frontend/src/components/ItemTable.vue +177 -0
- package/templates/vue-symposium-system/src/App.vue +41 -256
- package/templates/vue-symposium-system/src/components/AttendeeTable.vue +100 -0
- package/templates/vue-symposium-system/src/components/EventCard.vue +67 -0
- package/templates/vue-symposium-system/src/components/RegistrationForm.vue +118 -0
- package/templates/vue-symposium-system/src/stores/symposiumStore.js +10 -0
- package/templates/vue-todo-pinia/src/App.vue +40 -138
- package/templates/vue-todo-pinia/src/components/TodoFilter.vue +74 -0
- package/templates/vue-todo-pinia/src/components/TodoInput.vue +53 -0
- package/templates/vue-todo-pinia/src/components/TodoList.vue +101 -0
- package/templates/vue-todo-pinia/src/stores/todoStore.js +6 -0
- package/templates/vue-todo-router/src/App.vue +5 -36
- package/templates/vue-todo-router/src/components/TodoForm.vue +78 -0
- package/templates/vue-todo-router/src/components/TodoList.vue +84 -0
- package/templates/vue-todo-router/src/components/TodoNavBar.vue +47 -0
- package/templates/vue-todo-router/src/data/todoState.js +7 -0
- package/templates/vue-todo-router/src/views/AddTodoView.vue +7 -66
- package/templates/vue-todo-router/src/views/TodoDetailView.vue +15 -1
- package/templates/vue-todo-router/src/views/TodoListView.vue +22 -64
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
<script setup>
|
|
2
|
+
import { reactive } from 'vue'
|
|
3
|
+
|
|
4
|
+
defineProps({
|
|
5
|
+
show: {
|
|
6
|
+
type: Boolean,
|
|
7
|
+
default: false
|
|
8
|
+
},
|
|
9
|
+
total: {
|
|
10
|
+
type: Number,
|
|
11
|
+
required: true
|
|
12
|
+
}
|
|
13
|
+
})
|
|
14
|
+
|
|
15
|
+
const emit = defineEmits(['close', 'confirm'])
|
|
16
|
+
|
|
17
|
+
const form = reactive({
|
|
18
|
+
name: '',
|
|
19
|
+
address: ''
|
|
20
|
+
})
|
|
21
|
+
|
|
22
|
+
function handleConfirm() {
|
|
23
|
+
if (!form.name.trim() || !form.address.trim()) return
|
|
24
|
+
emit('confirm', { name: form.name.trim(), address: form.address.trim() })
|
|
25
|
+
}
|
|
26
|
+
</script>
|
|
27
|
+
|
|
28
|
+
<template>
|
|
29
|
+
<div v-if="show" class="modal-overlay" @click.self="emit('close')">
|
|
30
|
+
<div class="modal-card">
|
|
31
|
+
<div class="modal-header">
|
|
32
|
+
<h3>Confirm Checkout</h3>
|
|
33
|
+
<button type="button" class="btn-close" @click="emit('close')">x</button>
|
|
34
|
+
</div>
|
|
35
|
+
|
|
36
|
+
<form @submit.prevent="handleConfirm" class="modal-form">
|
|
37
|
+
<div class="total-notice">
|
|
38
|
+
Order Amount: <strong>${{ total }}</strong>
|
|
39
|
+
</div>
|
|
40
|
+
|
|
41
|
+
<div class="form-group">
|
|
42
|
+
<label for="ch-name">Full Name</label>
|
|
43
|
+
<input id="ch-name" v-model="form.name" required placeholder="John Doe" />
|
|
44
|
+
</div>
|
|
45
|
+
|
|
46
|
+
<div class="form-group">
|
|
47
|
+
<label for="ch-addr">Delivery Address</label>
|
|
48
|
+
<textarea id="ch-addr" v-model="form.address" required rows="3" placeholder="123 Main St, City"></textarea>
|
|
49
|
+
</div>
|
|
50
|
+
|
|
51
|
+
<div class="modal-actions">
|
|
52
|
+
<button type="button" class="btn btn-secondary" @click="emit('close')">Cancel</button>
|
|
53
|
+
<button type="submit" class="btn btn-primary">Confirm and Place Order</button>
|
|
54
|
+
</div>
|
|
55
|
+
</form>
|
|
56
|
+
</div>
|
|
57
|
+
</div>
|
|
58
|
+
</template>
|
|
59
|
+
|
|
60
|
+
<style scoped>
|
|
61
|
+
.modal-overlay {
|
|
62
|
+
position: fixed;
|
|
63
|
+
inset: 0;
|
|
64
|
+
background: rgba(0, 0, 0, 0.4);
|
|
65
|
+
display: flex;
|
|
66
|
+
align-items: center;
|
|
67
|
+
justify-content: center;
|
|
68
|
+
z-index: 1000;
|
|
69
|
+
padding: 16px;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
.modal-card {
|
|
73
|
+
background: #ffffff;
|
|
74
|
+
border-radius: 8px;
|
|
75
|
+
width: 100%;
|
|
76
|
+
max-width: 440px;
|
|
77
|
+
box-shadow: 0 8px 24px rgba(0,0,0,0.15);
|
|
78
|
+
overflow: hidden;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
.modal-header {
|
|
82
|
+
padding: 16px 20px;
|
|
83
|
+
border-bottom: 1px solid #e1e4e8;
|
|
84
|
+
display: flex;
|
|
85
|
+
justify-content: space-between;
|
|
86
|
+
align-items: center;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
.modal-header h3 {
|
|
90
|
+
font-size: 16px;
|
|
91
|
+
margin: 0;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
.btn-close {
|
|
95
|
+
background: none;
|
|
96
|
+
border: none;
|
|
97
|
+
font-size: 16px;
|
|
98
|
+
cursor: pointer;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
.modal-form {
|
|
102
|
+
padding: 20px;
|
|
103
|
+
display: flex;
|
|
104
|
+
flex-direction: column;
|
|
105
|
+
gap: 12px;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
.total-notice {
|
|
109
|
+
background: #eff6ff;
|
|
110
|
+
padding: 10px;
|
|
111
|
+
border-radius: 6px;
|
|
112
|
+
font-size: 14px;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
.form-group {
|
|
116
|
+
display: flex;
|
|
117
|
+
flex-direction: column;
|
|
118
|
+
gap: 4px;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
.form-group label {
|
|
122
|
+
font-size: 13px;
|
|
123
|
+
font-weight: 600;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
.form-group input,
|
|
127
|
+
.form-group textarea {
|
|
128
|
+
padding: 8px;
|
|
129
|
+
border: 1px solid #ccc;
|
|
130
|
+
border-radius: 4px;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
.modal-actions {
|
|
134
|
+
display: flex;
|
|
135
|
+
justify-content: flex-end;
|
|
136
|
+
gap: 10px;
|
|
137
|
+
margin-top: 10px;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
.btn {
|
|
141
|
+
padding: 8px 14px;
|
|
142
|
+
border-radius: 4px;
|
|
143
|
+
cursor: pointer;
|
|
144
|
+
border: 1px solid transparent;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
.btn-primary { background: #16a34a; color: #fff; }
|
|
148
|
+
.btn-secondary { background: #f1f5f9; color: #475569; }
|
|
149
|
+
</style>
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
<script setup>
|
|
2
|
+
defineProps({
|
|
3
|
+
product: {
|
|
4
|
+
type: Object,
|
|
5
|
+
required: true
|
|
6
|
+
}
|
|
7
|
+
})
|
|
8
|
+
|
|
9
|
+
const emit = defineEmits(['add-to-cart'])
|
|
10
|
+
</script>
|
|
11
|
+
|
|
12
|
+
<template>
|
|
13
|
+
<div class="product-card">
|
|
14
|
+
<div class="product-badge">{{ product.category }}</div>
|
|
15
|
+
<h3 class="product-title">{{ product.name }}</h3>
|
|
16
|
+
<div class="product-price">${{ Number(product.price).toFixed(2) }}</div>
|
|
17
|
+
<button type="button" class="btn btn-add" @click="emit('add-to-cart', product)">
|
|
18
|
+
Add to Cart
|
|
19
|
+
</button>
|
|
20
|
+
</div>
|
|
21
|
+
</template>
|
|
22
|
+
|
|
23
|
+
<style scoped>
|
|
24
|
+
.product-card {
|
|
25
|
+
border: 1px solid #ddd;
|
|
26
|
+
border-radius: 8px;
|
|
27
|
+
padding: 16px;
|
|
28
|
+
background: #ffffff;
|
|
29
|
+
display: flex;
|
|
30
|
+
flex-direction: column;
|
|
31
|
+
gap: 8px;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
.product-badge {
|
|
35
|
+
font-size: 11px;
|
|
36
|
+
text-transform: uppercase;
|
|
37
|
+
color: #64748b;
|
|
38
|
+
font-weight: 600;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
.product-title {
|
|
42
|
+
font-size: 16px;
|
|
43
|
+
margin: 0;
|
|
44
|
+
color: #1e293b;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
.product-price {
|
|
48
|
+
font-size: 18px;
|
|
49
|
+
font-weight: 700;
|
|
50
|
+
color: #0f172a;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
.btn-add {
|
|
54
|
+
margin-top: auto;
|
|
55
|
+
padding: 8px 12px;
|
|
56
|
+
background: #2563eb;
|
|
57
|
+
color: #fff;
|
|
58
|
+
border: none;
|
|
59
|
+
border-radius: 6px;
|
|
60
|
+
cursor: pointer;
|
|
61
|
+
font-weight: 500;
|
|
62
|
+
}
|
|
63
|
+
</style>
|
|
@@ -48,6 +48,17 @@ export const useCartStore = defineStore('cart', {
|
|
|
48
48
|
}
|
|
49
49
|
}
|
|
50
50
|
},
|
|
51
|
+
patchQuantity(id, quantity) {
|
|
52
|
+
const item = this.items.find((i) => i.id === id)
|
|
53
|
+
if (item) {
|
|
54
|
+
const q = Number(quantity)
|
|
55
|
+
if (q <= 0) {
|
|
56
|
+
this.removeFromCart(id)
|
|
57
|
+
} else {
|
|
58
|
+
item.quantity = q
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
},
|
|
51
62
|
removeFromCart(id) {
|
|
52
63
|
this.items = this.items.filter((item) => item.id !== id)
|
|
53
64
|
},
|
|
@@ -1,139 +1,73 @@
|
|
|
1
1
|
<script setup>
|
|
2
|
+
import { ref } from 'vue'
|
|
3
|
+
import { useRouter } from 'vue-router'
|
|
2
4
|
import { useCartStore } from '../stores/cartStore'
|
|
5
|
+
import CartSummary from '../components/CartSummary.vue'
|
|
6
|
+
import CheckoutModal from '../components/CheckoutModal.vue'
|
|
3
7
|
|
|
4
8
|
const cartStore = useCartStore()
|
|
9
|
+
const router = useRouter()
|
|
10
|
+
const isModalOpen = ref(false)
|
|
11
|
+
|
|
12
|
+
function handlePatch({ id, quantity }) {
|
|
13
|
+
cartStore.patchQuantity(id, quantity)
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
function handleCheckoutConfirm() {
|
|
17
|
+
cartStore.clearCart()
|
|
18
|
+
isModalOpen.value = false
|
|
19
|
+
router.push('/checkout')
|
|
20
|
+
}
|
|
5
21
|
</script>
|
|
6
22
|
|
|
7
23
|
<template>
|
|
8
|
-
<div>
|
|
9
|
-
<
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
24
|
+
<div class="cart-view">
|
|
25
|
+
<div class="cart-header">
|
|
26
|
+
<h2>Shopping Cart</h2>
|
|
27
|
+
<button
|
|
28
|
+
v-if="cartStore.items.length > 0"
|
|
29
|
+
type="button"
|
|
30
|
+
class="btn btn-primary"
|
|
31
|
+
@click="isModalOpen = true"
|
|
32
|
+
>
|
|
33
|
+
Proceed to Checkout
|
|
34
|
+
</button>
|
|
14
35
|
</div>
|
|
15
36
|
|
|
16
|
-
<
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
<button type="button" class="btn-qty" @click="cartStore.decrementQuantity(item.id)">-</button>
|
|
33
|
-
<span>{{ item.quantity }}</span>
|
|
34
|
-
<button type="button" class="btn-qty" @click="cartStore.incrementQuantity(item.id)">+</button>
|
|
35
|
-
</td>
|
|
36
|
-
<td>${{ item.price * item.quantity }}</td>
|
|
37
|
-
<td>
|
|
38
|
-
<button type="button" class="btn-remove" @click="cartStore.removeFromCart(item.id)">Remove</button>
|
|
39
|
-
</td>
|
|
40
|
-
</tr>
|
|
41
|
-
</tbody>
|
|
42
|
-
<tfoot>
|
|
43
|
-
<tr>
|
|
44
|
-
<td colspan="3" class="total-label">Grand Total:</td>
|
|
45
|
-
<td colspan="2" class="total-value">${{ cartStore.cartTotal }}</td>
|
|
46
|
-
</tr>
|
|
47
|
-
</tfoot>
|
|
48
|
-
</table>
|
|
49
|
-
|
|
50
|
-
<div class="cart-actions">
|
|
51
|
-
<button type="button" class="btn btn-clear" @click="cartStore.clearCart()">Clear Cart</button>
|
|
52
|
-
<router-link to="/checkout" class="btn btn-checkout">Proceed to Checkout</router-link>
|
|
53
|
-
</div>
|
|
54
|
-
</div>
|
|
37
|
+
<CartSummary
|
|
38
|
+
:items="cartStore.items"
|
|
39
|
+
:total="cartStore.cartTotal"
|
|
40
|
+
@increment="cartStore.incrementQuantity"
|
|
41
|
+
@decrement="cartStore.decrementQuantity"
|
|
42
|
+
@patch="handlePatch"
|
|
43
|
+
@remove="cartStore.removeFromCart"
|
|
44
|
+
@clear="cartStore.clearCart"
|
|
45
|
+
/>
|
|
46
|
+
|
|
47
|
+
<CheckoutModal
|
|
48
|
+
:show="isModalOpen"
|
|
49
|
+
:total="cartStore.cartTotal"
|
|
50
|
+
@close="isModalOpen = false"
|
|
51
|
+
@confirm="handleCheckoutConfirm"
|
|
52
|
+
/>
|
|
55
53
|
</div>
|
|
56
54
|
</template>
|
|
57
55
|
|
|
58
56
|
<style scoped>
|
|
59
|
-
.
|
|
60
|
-
padding: 30px;
|
|
61
|
-
text-align: center;
|
|
62
|
-
color: #777;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
.cart-table {
|
|
66
|
-
width: 100%;
|
|
67
|
-
border-collapse: collapse;
|
|
68
|
-
margin: 15px 0;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
.cart-table th, .cart-table td {
|
|
72
|
-
border: 1px solid #ddd;
|
|
73
|
-
padding: 10px;
|
|
74
|
-
text-align: left;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
.cart-table th {
|
|
78
|
-
background-color: #f2f2f2;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
.qty-cell {
|
|
57
|
+
.cart-header {
|
|
82
58
|
display: flex;
|
|
59
|
+
justify-content: space-between;
|
|
83
60
|
align-items: center;
|
|
84
|
-
|
|
61
|
+
margin-bottom: 16px;
|
|
85
62
|
}
|
|
86
63
|
|
|
87
|
-
.btn-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
background-color: #eee;
|
|
91
|
-
border: 1px solid #ccc;
|
|
92
|
-
cursor: pointer;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
.btn-remove {
|
|
96
|
-
background-color: #e74c3c;
|
|
97
|
-
color: white;
|
|
64
|
+
.btn-primary {
|
|
65
|
+
background: #16a34a;
|
|
66
|
+
color: #fff;
|
|
98
67
|
border: none;
|
|
99
|
-
padding:
|
|
100
|
-
border-radius:
|
|
68
|
+
padding: 8px 14px;
|
|
69
|
+
border-radius: 6px;
|
|
101
70
|
cursor: pointer;
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
.total-label {
|
|
105
|
-
text-align: right;
|
|
106
|
-
font-weight: bold;
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
.total-value {
|
|
110
|
-
font-weight: bold;
|
|
111
|
-
color: #27ae60;
|
|
112
|
-
font-size: 16px;
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
.cart-actions {
|
|
116
|
-
display: flex;
|
|
117
|
-
justify-content: space-between;
|
|
118
|
-
margin-top: 15px;
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
.btn {
|
|
122
|
-
padding: 10px 18px;
|
|
123
|
-
border-radius: 4px;
|
|
124
|
-
text-decoration: none;
|
|
125
|
-
font-size: 14px;
|
|
126
|
-
cursor: pointer;
|
|
127
|
-
border: none;
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
.btn-clear {
|
|
131
|
-
background-color: #95a5a6;
|
|
132
|
-
color: white;
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
.btn-checkout {
|
|
136
|
-
background-color: #27ae60;
|
|
137
|
-
color: white;
|
|
71
|
+
font-weight: 500;
|
|
138
72
|
}
|
|
139
73
|
</style>
|
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
<script setup>
|
|
2
2
|
import { ref } from 'vue'
|
|
3
|
-
import { useRouter } from 'vue-router'
|
|
4
3
|
import { useCartStore } from '../stores/cartStore'
|
|
5
4
|
|
|
6
5
|
const cartStore = useCartStore()
|
|
7
|
-
const router = useRouter()
|
|
8
|
-
|
|
9
6
|
const name = ref('')
|
|
10
7
|
const address = ref('')
|
|
11
8
|
const orderPlaced = ref(false)
|
|
@@ -21,7 +18,7 @@ function handleCheckout() {
|
|
|
21
18
|
<h2>Checkout & Order Summary</h2>
|
|
22
19
|
|
|
23
20
|
<div v-if="orderPlaced" class="success-banner">
|
|
24
|
-
<h3>Thank you for your order
|
|
21
|
+
<h3>Thank you for your order!</h3>
|
|
25
22
|
<p>Your order has been placed successfully.</p>
|
|
26
23
|
<router-link to="/" class="btn btn-shop">Continue Shopping</router-link>
|
|
27
24
|
</div>
|
|
@@ -36,7 +33,7 @@ function handleCheckout() {
|
|
|
36
33
|
<h3>Order Items:</h3>
|
|
37
34
|
<ul>
|
|
38
35
|
<li v-for="item in cartStore.items" :key="item.id">
|
|
39
|
-
{{ item.name }} x {{ item.quantity }}
|
|
36
|
+
{{ item.name }} x {{ item.quantity }} - ${{ item.price * item.quantity }}
|
|
40
37
|
</li>
|
|
41
38
|
</ul>
|
|
42
39
|
<p class="summary-total">Total Amount: <strong>${{ cartStore.cartTotal }}</strong></p>
|
|
@@ -1,73 +1,37 @@
|
|
|
1
1
|
<script setup>
|
|
2
2
|
import { useCartStore } from '../stores/cartStore'
|
|
3
|
+
import ProductCard from '../components/ProductCard.vue'
|
|
3
4
|
|
|
4
5
|
const cartStore = useCartStore()
|
|
6
|
+
|
|
7
|
+
function handleAddToCart(product) {
|
|
8
|
+
cartStore.addToCart(product)
|
|
9
|
+
}
|
|
5
10
|
</script>
|
|
6
11
|
|
|
7
12
|
<template>
|
|
8
|
-
<div>
|
|
9
|
-
<h2>
|
|
13
|
+
<div class="catalog-view">
|
|
14
|
+
<h2>Product Catalog</h2>
|
|
10
15
|
<div class="product-grid">
|
|
11
|
-
<
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
class="btn btn-add"
|
|
18
|
-
@click="cartStore.addToCart(product)"
|
|
19
|
-
>
|
|
20
|
-
Add to Cart
|
|
21
|
-
</button>
|
|
22
|
-
</div>
|
|
16
|
+
<ProductCard
|
|
17
|
+
v-for="p in cartStore.products"
|
|
18
|
+
:key="p.id"
|
|
19
|
+
:product="p"
|
|
20
|
+
@add-to-cart="handleAddToCart"
|
|
21
|
+
/>
|
|
23
22
|
</div>
|
|
24
23
|
</div>
|
|
25
24
|
</template>
|
|
26
25
|
|
|
27
26
|
<style scoped>
|
|
28
|
-
.
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
gap: 15px;
|
|
32
|
-
margin-top: 15px;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
.product-card {
|
|
36
|
-
border: 1px solid #ddd;
|
|
37
|
-
border-radius: 6px;
|
|
38
|
-
padding: 15px;
|
|
39
|
-
text-align: center;
|
|
40
|
-
background-color: #fafafa;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
.product-card h3 {
|
|
44
|
-
font-size: 16px;
|
|
45
|
-
margin: 5px 0;
|
|
27
|
+
.catalog-view h2 {
|
|
28
|
+
font-size: 20px;
|
|
29
|
+
margin-bottom: 16px;
|
|
46
30
|
}
|
|
47
31
|
|
|
48
|
-
.
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
.price {
|
|
55
|
-
font-size: 18px;
|
|
56
|
-
font-weight: bold;
|
|
57
|
-
color: #27ae60;
|
|
58
|
-
margin-bottom: 12px;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
.btn-add {
|
|
62
|
-
background-color: #2980b9;
|
|
63
|
-
color: white;
|
|
64
|
-
border: none;
|
|
65
|
-
padding: 8px 12px;
|
|
66
|
-
border-radius: 4px;
|
|
67
|
-
cursor: pointer;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
.btn-add:hover {
|
|
71
|
-
background-color: #1f618d;
|
|
32
|
+
.product-grid {
|
|
33
|
+
display: grid;
|
|
34
|
+
grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
|
|
35
|
+
gap: 16px;
|
|
72
36
|
}
|
|
73
37
|
</style>
|