create-cedro-app 1.0.2 → 1.0.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 (69) hide show
  1. package/bin/index.js +32 -18
  2. package/package.json +1 -1
  3. package/templates/inventory-management-system/client/README.md +16 -0
  4. package/templates/inventory-management-system/client/eslint.config.js +21 -0
  5. package/templates/inventory-management-system/client/index.html +13 -0
  6. package/templates/inventory-management-system/client/package.json +35 -0
  7. package/templates/inventory-management-system/client/public/favicon.svg +1 -0
  8. package/templates/inventory-management-system/client/public/icons.svg +24 -0
  9. package/templates/inventory-management-system/client/src/App.jsx +15 -0
  10. package/templates/inventory-management-system/client/src/assets/hero.png +0 -0
  11. package/templates/inventory-management-system/client/src/assets/react.svg +1 -0
  12. package/templates/inventory-management-system/client/src/assets/vite.svg +1 -0
  13. package/templates/inventory-management-system/client/src/components/AppRoutes.jsx +39 -0
  14. package/templates/inventory-management-system/client/src/components/Customer.jsx +326 -0
  15. package/templates/inventory-management-system/client/src/components/Dashboard.jsx +512 -0
  16. package/templates/inventory-management-system/client/src/components/Invoice.jsx +523 -0
  17. package/templates/inventory-management-system/client/src/components/Login.jsx +170 -0
  18. package/templates/inventory-management-system/client/src/components/PageNotFound.jsx +11 -0
  19. package/templates/inventory-management-system/client/src/components/Register.jsx +171 -0
  20. package/templates/inventory-management-system/client/src/components/Report.jsx +383 -0
  21. package/templates/inventory-management-system/client/src/components/Service.jsx +390 -0
  22. package/templates/inventory-management-system/client/src/index.css +1 -0
  23. package/templates/inventory-management-system/client/src/main.jsx +13 -0
  24. package/templates/inventory-management-system/client/vite.config.js +9 -0
  25. package/templates/inventory-management-system/server/.env +8 -0
  26. package/templates/inventory-management-system/server/Functions/Customer.js +79 -0
  27. package/templates/inventory-management-system/server/Functions/Invoice.js +192 -0
  28. package/templates/inventory-management-system/server/Functions/Service.js +86 -0
  29. package/templates/inventory-management-system/server/Functions/dashboard.js +33 -0
  30. package/templates/inventory-management-system/server/Functions/report.js +50 -0
  31. package/templates/inventory-management-system/server/Functions/users.js +101 -0
  32. package/templates/inventory-management-system/server/db.js +22 -0
  33. package/templates/inventory-management-system/server/package.json +23 -0
  34. package/templates/inventory-management-system/server/server.js +294 -0
  35. package/templates/slot-car-management-system/client/README.md +16 -0
  36. package/templates/slot-car-management-system/client/eslint.config.js +21 -0
  37. package/templates/slot-car-management-system/client/index.html +13 -0
  38. package/templates/slot-car-management-system/client/package.json +35 -0
  39. package/templates/slot-car-management-system/client/public/favicon.svg +1 -0
  40. package/templates/slot-car-management-system/client/public/icons.svg +24 -0
  41. package/templates/slot-car-management-system/client/src/App.css +184 -0
  42. package/templates/slot-car-management-system/client/src/App.jsx +49 -0
  43. package/templates/slot-car-management-system/client/src/assets/hero.png +0 -0
  44. package/templates/slot-car-management-system/client/src/assets/react.svg +1 -0
  45. package/templates/slot-car-management-system/client/src/assets/vite.svg +1 -0
  46. package/templates/slot-car-management-system/client/src/components/Cars.jsx +246 -0
  47. package/templates/slot-car-management-system/client/src/components/Dashboard.jsx +629 -0
  48. package/templates/slot-car-management-system/client/src/components/Login.jsx +170 -0
  49. package/templates/slot-car-management-system/client/src/components/PageNotFound.jsx +11 -0
  50. package/templates/slot-car-management-system/client/src/components/ParkingRecord.jsx +553 -0
  51. package/templates/slot-car-management-system/client/src/components/ParkingSlot.jsx +268 -0
  52. package/templates/slot-car-management-system/client/src/components/Payment.jsx +464 -0
  53. package/templates/slot-car-management-system/client/src/components/Register.jsx +171 -0
  54. package/templates/slot-car-management-system/client/src/components/Report.jsx +407 -0
  55. package/templates/slot-car-management-system/client/src/index.css +1 -0
  56. package/templates/slot-car-management-system/client/src/main.jsx +10 -0
  57. package/templates/slot-car-management-system/client/vite.config.js +9 -0
  58. package/templates/slot-car-management-system/parking_slot.sql +218 -0
  59. package/templates/slot-car-management-system/server/.env +8 -0
  60. package/templates/slot-car-management-system/server/Functions/Payment.js +107 -0
  61. package/templates/slot-car-management-system/server/Functions/car.js +93 -0
  62. package/templates/slot-car-management-system/server/Functions/dashboard.js +64 -0
  63. package/templates/slot-car-management-system/server/Functions/parkingRecord.js +220 -0
  64. package/templates/slot-car-management-system/server/Functions/parkingslot.js +58 -0
  65. package/templates/slot-car-management-system/server/Functions/report.js +48 -0
  66. package/templates/slot-car-management-system/server/Functions/users.js +101 -0
  67. package/templates/slot-car-management-system/server/db.js +22 -0
  68. package/templates/slot-car-management-system/server/package.json +23 -0
  69. package/templates/slot-car-management-system/server/server.js +192 -0
@@ -0,0 +1,326 @@
1
+ import React, { useEffect, useState } from "react";
2
+ import axios from "axios";
3
+ import { toast } from "react-toastify";
4
+ import { useNavigate } from "react-router-dom";
5
+
6
+ function Customers() {
7
+
8
+ const token = localStorage.getItem("token");
9
+
10
+ const navigate = useNavigate();
11
+
12
+
13
+ useEffect(() => {
14
+
15
+ const token = localStorage.getItem("token");
16
+
17
+ if (!token) {
18
+ navigate("/");
19
+ }
20
+
21
+ }, []);
22
+
23
+
24
+ const [customers, setCustomers] = useState([]);
25
+
26
+ const [values, setValues] = useState({
27
+ FirstName: "",
28
+ LastName: "",
29
+ Address: "",
30
+ Telephone: "",
31
+ VehiclePlateNumber: "",
32
+ VehicleType: "",
33
+ ServiceDate: ""
34
+ });
35
+
36
+
37
+ const fetchCustomers = async () => {
38
+
39
+ try {
40
+
41
+ const res = await axios.get(
42
+ "http://localhost:3000/selectcustomers",
43
+ {
44
+ headers: {
45
+ Authorization: `Bearer ${token}`
46
+ }
47
+ }
48
+ );
49
+
50
+ setCustomers(res.data || []);
51
+
52
+ } catch (error) {
53
+
54
+ console.log(error);
55
+
56
+ toast.error("Failed to load customers");
57
+ }
58
+ };
59
+
60
+ useEffect(() => {
61
+
62
+ fetchCustomers();
63
+
64
+ }, []);
65
+
66
+ // =========================
67
+ // INSERT CUSTOMER
68
+ // =========================
69
+ const handleSubmit = async (e) => {
70
+
71
+ e.preventDefault();
72
+
73
+ try {
74
+
75
+ await axios.post(
76
+ "http://localhost:3000/addcustomer",
77
+ values,
78
+ {
79
+ headers: {
80
+ Authorization: `Bearer ${token}`
81
+ }
82
+ }
83
+ );
84
+
85
+ toast.success("Customer added successfully");
86
+
87
+ // RESET FORM
88
+ setValues({
89
+ FirstName: "",
90
+ LastName: "",
91
+ Address: "",
92
+ Telephone: "",
93
+ VehiclePlateNumber: "",
94
+ VehicleType: "",
95
+ ServiceDate: ""
96
+ });
97
+
98
+ fetchCustomers();
99
+
100
+ } catch (error) {
101
+
102
+ toast.error(
103
+ error.response?.data?.Error ||
104
+ "Error inserting customer"
105
+ );
106
+ }
107
+ };
108
+
109
+ return (
110
+
111
+ <div className="p-6">
112
+
113
+ {/* FORM */}
114
+ <div className="bg-white p-6 rounded-xl shadow-md mb-6">
115
+
116
+ <h2 className="text-2xl font-bold mb-4 text-indigo-600">
117
+ Customer Registration
118
+ </h2>
119
+
120
+ <form
121
+ onSubmit={handleSubmit}
122
+ className="grid grid-cols-1 md:grid-cols-2 gap-4"
123
+ >
124
+
125
+
126
+ <input
127
+ type="text"
128
+ placeholder="First Name"
129
+ className="border p-3 rounded"
130
+ value={values.FirstName}
131
+ onChange={(e) =>
132
+ setValues({
133
+ ...values,
134
+ FirstName: e.target.value
135
+ })
136
+ }
137
+ />
138
+
139
+
140
+ <input
141
+ type="text"
142
+ placeholder="Last Name"
143
+ className="border p-3 rounded"
144
+ value={values.LastName}
145
+ onChange={(e) =>
146
+ setValues({
147
+ ...values,
148
+ LastName: e.target.value
149
+ })
150
+ }
151
+ />
152
+
153
+
154
+ <input
155
+ type="text"
156
+ placeholder="Address"
157
+ className="border p-3 rounded"
158
+ value={values.Address}
159
+ onChange={(e) =>
160
+ setValues({
161
+ ...values,
162
+ Address: e.target.value
163
+ })
164
+ }
165
+ />
166
+
167
+
168
+ <input
169
+ type="text"
170
+ placeholder="Telephone"
171
+ className="border p-3 rounded"
172
+ value={values.Telephone}
173
+ onChange={(e) =>
174
+ setValues({
175
+ ...values,
176
+ Telephone: e.target.value
177
+ })
178
+ }
179
+ />
180
+
181
+
182
+ <input
183
+ type="text"
184
+ placeholder="Vehicle Plate Number"
185
+ className="border p-3 rounded"
186
+ value={values.VehiclePlateNumber}
187
+ onChange={(e) =>
188
+ setValues({
189
+ ...values,
190
+ VehiclePlateNumber: e.target.value
191
+ })
192
+ }
193
+ />
194
+
195
+
196
+ <input
197
+ type="text"
198
+ placeholder="Vehicle Type"
199
+ className="border p-3 rounded"
200
+ value={values.VehicleType}
201
+ onChange={(e) =>
202
+ setValues({
203
+ ...values,
204
+ VehicleType: e.target.value
205
+ })
206
+ }
207
+ />
208
+
209
+
210
+ <input
211
+ type="date"
212
+ className="border p-3 rounded"
213
+ value={values.ServiceDate}
214
+ onChange={(e) =>
215
+ setValues({
216
+ ...values,
217
+ ServiceDate: e.target.value
218
+ })
219
+ }
220
+ />
221
+
222
+
223
+ <button
224
+ className="bg-indigo-600 text-white p-3 rounded hover:bg-indigo-700 md:col-span-2"
225
+ >
226
+ Save Customer
227
+ </button>
228
+
229
+ </form>
230
+
231
+ </div>
232
+
233
+
234
+ <div className="bg-white p-6 rounded-xl shadow-md">
235
+
236
+ <h2 className="text-xl font-bold mb-4">
237
+ Customer List
238
+ </h2>
239
+
240
+ <table className="w-full border">
241
+
242
+ <thead className="bg-gray-100">
243
+
244
+ <tr>
245
+
246
+ <th className="p-2">First Name</th>
247
+
248
+ <th className="p-2">Last Name</th>
249
+
250
+ <th className="p-2">Telephone</th>
251
+
252
+ <th className="p-2">Plate Number</th>
253
+
254
+ <th className="p-2">Vehicle Type</th>
255
+
256
+ <th className="p-2">Service Date</th>
257
+
258
+ </tr>
259
+
260
+ </thead>
261
+
262
+ <tbody>
263
+
264
+ {customers.length > 0 ? (
265
+
266
+ customers.map((customer) => (
267
+
268
+ <tr
269
+ key={customer.CustomerId}
270
+ className="text-center border-t"
271
+ >
272
+
273
+ <td className="p-2">
274
+ {customer.FirstName}
275
+ </td>
276
+
277
+ <td className="p-2">
278
+ {customer.LastName}
279
+ </td>
280
+
281
+ <td className="p-2">
282
+ {customer.Telephone}
283
+ </td>
284
+
285
+ <td className="p-2">
286
+ {customer.VehiclePlateNumber}
287
+ </td>
288
+
289
+ <td className="p-2">
290
+ {customer.VehicleType}
291
+ </td>
292
+
293
+ <td className="p-2">
294
+ {customer.ServiceDate}
295
+ </td>
296
+
297
+ </tr>
298
+
299
+ ))
300
+
301
+ ) : (
302
+
303
+ <tr>
304
+
305
+ <td
306
+ colSpan="6"
307
+ className="text-center p-4 text-gray-500"
308
+ >
309
+ No customers found
310
+ </td>
311
+
312
+ </tr>
313
+
314
+ )}
315
+
316
+ </tbody>
317
+
318
+ </table>
319
+
320
+ </div>
321
+
322
+ </div>
323
+ );
324
+ }
325
+
326
+ export default Customers;