create-cedro-app 1.0.2 → 1.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (69) hide show
  1. package/bin/index.js +32 -18
  2. package/package.json +1 -1
  3. package/templates/invoice-service-management-system/client/README.md +16 -0
  4. package/templates/invoice-service-management-system/client/eslint.config.js +21 -0
  5. package/templates/invoice-service-management-system/client/index.html +13 -0
  6. package/templates/invoice-service-management-system/client/package.json +35 -0
  7. package/templates/invoice-service-management-system/client/public/favicon.svg +1 -0
  8. package/templates/invoice-service-management-system/client/public/icons.svg +24 -0
  9. package/templates/invoice-service-management-system/client/src/App.jsx +15 -0
  10. package/templates/invoice-service-management-system/client/src/assets/hero.png +0 -0
  11. package/templates/invoice-service-management-system/client/src/assets/react.svg +1 -0
  12. package/templates/invoice-service-management-system/client/src/assets/vite.svg +1 -0
  13. package/templates/invoice-service-management-system/client/src/components/AppRoutes.jsx +39 -0
  14. package/templates/invoice-service-management-system/client/src/components/Customer.jsx +326 -0
  15. package/templates/invoice-service-management-system/client/src/components/Dashboard.jsx +512 -0
  16. package/templates/invoice-service-management-system/client/src/components/Invoice.jsx +523 -0
  17. package/templates/invoice-service-management-system/client/src/components/Login.jsx +170 -0
  18. package/templates/invoice-service-management-system/client/src/components/PageNotFound.jsx +11 -0
  19. package/templates/invoice-service-management-system/client/src/components/Register.jsx +171 -0
  20. package/templates/invoice-service-management-system/client/src/components/Report.jsx +383 -0
  21. package/templates/invoice-service-management-system/client/src/components/Service.jsx +390 -0
  22. package/templates/invoice-service-management-system/client/src/index.css +1 -0
  23. package/templates/invoice-service-management-system/client/src/main.jsx +13 -0
  24. package/templates/invoice-service-management-system/client/vite.config.js +9 -0
  25. package/templates/invoice-service-management-system/server/.env +8 -0
  26. package/templates/invoice-service-management-system/server/Functions/Customer.js +79 -0
  27. package/templates/invoice-service-management-system/server/Functions/Invoice.js +192 -0
  28. package/templates/invoice-service-management-system/server/Functions/Service.js +86 -0
  29. package/templates/invoice-service-management-system/server/Functions/dashboard.js +33 -0
  30. package/templates/invoice-service-management-system/server/Functions/report.js +50 -0
  31. package/templates/invoice-service-management-system/server/Functions/users.js +101 -0
  32. package/templates/invoice-service-management-system/server/db.js +22 -0
  33. package/templates/invoice-service-management-system/server/package.json +23 -0
  34. package/templates/invoice-service-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,523 @@
1
+ import React, { useEffect, useState } from "react";
2
+ import axios from "axios";
3
+ import { toast } from "react-toastify";
4
+ import {
5
+ Receipt,
6
+ Trash2,
7
+ Pencil
8
+ } from "lucide-react";
9
+ import { useNavigate } from "react-router-dom";
10
+
11
+ function Invoices() {
12
+
13
+ const token = localStorage.getItem("token");
14
+
15
+ const navigate = useNavigate();
16
+
17
+ useEffect(() => {
18
+
19
+ const token = localStorage.getItem("token");
20
+
21
+ if (!token) {
22
+ navigate("/");
23
+ }
24
+
25
+ }, [navigate]);
26
+
27
+ const [customers, setCustomers] = useState([]);
28
+
29
+ const [services, setServices] = useState([]);
30
+
31
+ const [invoices, setInvoices] = useState([]);
32
+
33
+ const [editId, setEditId] = useState(null);
34
+
35
+ const [values, setValues] = useState({
36
+ TotalCost: "",
37
+ PaidAmount: "",
38
+ Balance: "",
39
+ PaymentMonth: "",
40
+ CustomerId: "",
41
+ ServiceCode: ""
42
+ });
43
+
44
+ const fetchCustomers = async () => {
45
+
46
+ try {
47
+
48
+ const res = await axios.get(
49
+ "http://localhost:3000/selectcustomers",
50
+ {
51
+ headers: {
52
+ Authorization: `Bearer ${token}`
53
+ }
54
+ }
55
+ );
56
+
57
+ setCustomers(res.data || []);
58
+
59
+ } catch (error) {
60
+
61
+ toast.error("Failed to load customers");
62
+ }
63
+ };
64
+
65
+ const fetchServices = async () => {
66
+
67
+ try {
68
+
69
+ const res = await axios.get(
70
+ "http://localhost:3000/selectservices",
71
+ {
72
+ headers: {
73
+ Authorization: `Bearer ${token}`
74
+ }
75
+ }
76
+ );
77
+
78
+ setServices(res.data || []);
79
+
80
+ } catch (error) {
81
+
82
+ toast.error("Failed to load services");
83
+ }
84
+ };
85
+
86
+ const fetchInvoices = async () => {
87
+
88
+ try {
89
+
90
+ const res = await axios.get(
91
+ "http://localhost:3000/selectinvoices",
92
+ {
93
+ headers: {
94
+ Authorization: `Bearer ${token}`
95
+ }
96
+ }
97
+ );
98
+
99
+ setInvoices(res.data || []);
100
+
101
+ } catch (error) {
102
+
103
+ toast.error("Failed to load invoices");
104
+ }
105
+ };
106
+
107
+ useEffect(() => {
108
+
109
+ fetchCustomers();
110
+
111
+ fetchServices();
112
+
113
+ fetchInvoices();
114
+
115
+ }, []);
116
+
117
+ const handleSubmit = async (e) => {
118
+
119
+ e.preventDefault();
120
+
121
+ try {
122
+
123
+ if (editId) {
124
+
125
+ await axios.put(
126
+ `http://localhost:3000/updateinvoice/${editId}`,
127
+ values,
128
+ {
129
+ headers: {
130
+ Authorization: `Bearer ${token}`
131
+ }
132
+ }
133
+ );
134
+
135
+ toast.success("Invoice updated");
136
+
137
+ setEditId(null);
138
+
139
+ } else {
140
+
141
+ await axios.post(
142
+ "http://localhost:3000/insertinvoice",
143
+ values,
144
+ {
145
+ headers: {
146
+ Authorization: `Bearer ${token}`
147
+ }
148
+ }
149
+ );
150
+
151
+ toast.success("Invoice created");
152
+ }
153
+
154
+ setValues({
155
+ TotalCost: "",
156
+ PaidAmount: "",
157
+ Balance: "",
158
+ PaymentMonth: "",
159
+ CustomerId: "",
160
+ ServiceCode: ""
161
+ });
162
+
163
+ fetchInvoices();
164
+
165
+ } catch (error) {
166
+
167
+ toast.error(
168
+ error.response?.data?.Error ||
169
+ "Error saving invoice"
170
+ );
171
+ }
172
+ };
173
+
174
+ const deleteInvoice = async (id) => {
175
+
176
+ try {
177
+
178
+ await axios.delete(
179
+ `http://localhost:3000/deleteinvoice/${id}`,
180
+ {
181
+ headers: {
182
+ Authorization: `Bearer ${token}`
183
+ }
184
+ }
185
+ );
186
+
187
+ toast.success("Invoice deleted");
188
+
189
+ fetchInvoices();
190
+
191
+ } catch (error) {
192
+
193
+ toast.error("Delete failed");
194
+ }
195
+ };
196
+
197
+ const editInvoice = (invoice) => {
198
+
199
+ setValues({
200
+ TotalCost: invoice.TotalCost,
201
+ PaidAmount: invoice.PaidAmount,
202
+ Balance: invoice.Balance,
203
+ PaymentMonth: invoice.PaymentMonth,
204
+ CustomerId: invoice.CustomerId,
205
+ ServiceCode: invoice.ServiceCode
206
+ });
207
+
208
+ setEditId(invoice.InvoiceId);
209
+ };
210
+
211
+ return (
212
+
213
+ <div className="p-6">
214
+
215
+ <div className="mb-6">
216
+
217
+ <h1 className="text-3xl font-bold text-gray-800">
218
+ Invoices
219
+ </h1>
220
+
221
+ <p className="text-gray-500 mt-1">
222
+ Manage customer invoices
223
+ </p>
224
+
225
+ </div>
226
+
227
+ <div className="bg-white p-8 rounded-2xl shadow-lg mb-8 border">
228
+
229
+ <div className="flex items-center gap-3 mb-6">
230
+
231
+ <Receipt
232
+ className="text-indigo-600"
233
+ size={30}
234
+ />
235
+
236
+ <h2 className="text-2xl font-bold text-indigo-600">
237
+
238
+ {editId
239
+ ? "Update Invoice"
240
+ : "Create Invoice"}
241
+
242
+ </h2>
243
+
244
+ </div>
245
+
246
+ <form
247
+ onSubmit={handleSubmit}
248
+ className="grid grid-cols-1 md:grid-cols-2 gap-5"
249
+ >
250
+
251
+ <input
252
+ type="text"
253
+ placeholder="Total Cost"
254
+ className="border p-3 rounded-xl"
255
+ value={values.TotalCost}
256
+ onChange={(e) =>
257
+ setValues({
258
+ ...values,
259
+ TotalCost: e.target.value
260
+ })
261
+ }
262
+ required
263
+ />
264
+
265
+ <input
266
+ type="text"
267
+ placeholder="Paid Amount"
268
+ className="border p-3 rounded-xl"
269
+ value={values.PaidAmount}
270
+ onChange={(e) =>
271
+ setValues({
272
+ ...values,
273
+ PaidAmount: e.target.value
274
+ })
275
+ }
276
+ required
277
+ />
278
+
279
+ <input
280
+ type="text"
281
+ placeholder="Balance"
282
+ className="border p-3 rounded-xl"
283
+ value={values.Balance}
284
+ onChange={(e) =>
285
+ setValues({
286
+ ...values,
287
+ Balance: e.target.value
288
+ })
289
+ }
290
+ required
291
+ />
292
+
293
+ <input
294
+ type="text"
295
+ placeholder="Payment Month"
296
+ className="border p-3 rounded-xl"
297
+ value={values.PaymentMonth}
298
+ onChange={(e) =>
299
+ setValues({
300
+ ...values,
301
+ PaymentMonth: e.target.value
302
+ })
303
+ }
304
+ required
305
+ />
306
+
307
+ <select
308
+ className="border p-3 rounded-xl"
309
+ value={values.CustomerId}
310
+ onChange={(e) =>
311
+ setValues({
312
+ ...values,
313
+ CustomerId: e.target.value
314
+ })
315
+ }
316
+ required
317
+ >
318
+
319
+ <option value="">
320
+ Select Customer
321
+ </option>
322
+
323
+ {customers.map((customer) => (
324
+
325
+ <option
326
+ key={customer.CustomerId}
327
+ value={customer.CustomerId}
328
+ >
329
+
330
+ {customer.FirstName} {customer.LastName}
331
+
332
+ </option>
333
+
334
+ ))}
335
+
336
+ </select>
337
+
338
+ <select
339
+ className="border p-3 rounded-xl"
340
+ value={values.ServiceCode}
341
+ onChange={(e) =>
342
+ setValues({
343
+ ...values,
344
+ ServiceCode: e.target.value
345
+ })
346
+ }
347
+ required
348
+ >
349
+
350
+ <option value="">
351
+ Select Service
352
+ </option>
353
+
354
+ {services.map((service) => (
355
+
356
+ <option
357
+ key={service.ServiceCode}
358
+ value={service.ServiceCode}
359
+ >
360
+
361
+ {service.ServiceName}
362
+
363
+ </option>
364
+
365
+ ))}
366
+
367
+ </select>
368
+
369
+ <button
370
+ className={`text-white p-3 rounded-xl font-semibold ${
371
+ editId
372
+ ? "bg-green-600 hover:bg-green-700"
373
+ : "bg-indigo-600 hover:bg-indigo-700"
374
+ }`}
375
+ >
376
+
377
+ {editId
378
+ ? "Update Invoice"
379
+ : "Save Invoice"}
380
+
381
+ </button>
382
+
383
+ </form>
384
+
385
+ </div>
386
+
387
+ <div className="bg-white rounded-2xl shadow-lg overflow-hidden border">
388
+
389
+ <div className="p-6 border-b">
390
+
391
+ <h2 className="text-2xl font-bold">
392
+ Invoice List
393
+ </h2>
394
+
395
+ </div>
396
+
397
+ <table className="w-full">
398
+
399
+ <thead className="bg-gray-100">
400
+
401
+ <tr>
402
+
403
+ <th className="p-3">
404
+ Customer
405
+ </th>
406
+
407
+ <th className="p-3">
408
+ Service
409
+ </th>
410
+
411
+ <th className="p-3">
412
+ Total Cost
413
+ </th>
414
+
415
+ <th className="p-3">
416
+ Paid Amount
417
+ </th>
418
+
419
+ <th className="p-3">
420
+ Balance
421
+ </th>
422
+
423
+ <th className="p-3">
424
+ Payment Month
425
+ </th>
426
+
427
+ <th className="p-3 text-center">
428
+ Actions
429
+ </th>
430
+
431
+ </tr>
432
+
433
+ </thead>
434
+
435
+ <tbody>
436
+
437
+ {invoices.length > 0 ? (
438
+
439
+ invoices.map((invoice) => (
440
+
441
+ <tr
442
+ key={invoice.InvoiceId}
443
+ className="text-center border-t"
444
+ >
445
+
446
+ <td className="p-3">
447
+ {invoice.FirstName} {invoice.LastName}
448
+ </td>
449
+
450
+ <td className="p-3">
451
+ {invoice.ServiceName}
452
+ </td>
453
+
454
+ <td className="p-3">
455
+ {invoice.TotalCost}
456
+ </td>
457
+
458
+ <td className="p-3">
459
+ {invoice.PaidAmount}
460
+ </td>
461
+
462
+ <td className="p-3">
463
+ {invoice.Balance}
464
+ </td>
465
+
466
+ <td className="p-3">
467
+ {invoice.PaymentMonth}
468
+ </td>
469
+
470
+ <td className="p-3">
471
+
472
+ <div className="flex justify-center gap-3">
473
+
474
+ <button
475
+ onClick={() => editInvoice(invoice)}
476
+ className="bg-blue-500 text-white p-2 rounded"
477
+ >
478
+ <Pencil size={18} />
479
+ </button>
480
+
481
+ <button
482
+ onClick={() =>
483
+ deleteInvoice(invoice.InvoiceId)
484
+ }
485
+ className="bg-red-500 text-white p-2 rounded"
486
+ >
487
+ <Trash2 size={18} />
488
+ </button>
489
+
490
+ </div>
491
+
492
+ </td>
493
+
494
+ </tr>
495
+
496
+ ))
497
+
498
+ ) : (
499
+
500
+ <tr>
501
+
502
+ <td
503
+ colSpan="7"
504
+ className="text-center p-4 text-gray-500"
505
+ >
506
+ No invoices found
507
+ </td>
508
+
509
+ </tr>
510
+
511
+ )}
512
+
513
+ </tbody>
514
+
515
+ </table>
516
+
517
+ </div>
518
+
519
+ </div>
520
+ );
521
+ }
522
+
523
+ export default Invoices;
@@ -0,0 +1,170 @@
1
+ import axios from "axios";
2
+ import { useState } from "react";
3
+ import { useNavigate, Link } from "react-router-dom";
4
+ import { toast } from "react-toastify";
5
+
6
+ import { Wrench, Mail, Lock } from "lucide-react";
7
+
8
+ function Login() {
9
+
10
+ const navigate = useNavigate();
11
+
12
+ const [error, setError] = useState("");
13
+
14
+ const [values, setValues] = useState({
15
+ Email: "",
16
+ Password: ""
17
+ });
18
+
19
+ // =========================
20
+ // LOGIN HANDLER
21
+ // =========================
22
+ const HandleLogin = async (e) => {
23
+
24
+ e.preventDefault();
25
+
26
+
27
+
28
+ await axios.post(
29
+ "http://localhost:3000/login",
30
+ values
31
+ )
32
+ .then((res)=>{
33
+ // SAVE TOKEN
34
+ localStorage.setItem(
35
+ "token",
36
+ res.data.token
37
+ );
38
+
39
+ console.log(res.data);
40
+
41
+ toast.success(res.data.Message);
42
+
43
+ navigate("/dashboard");
44
+ })
45
+
46
+
47
+
48
+ .catch((error)=>{
49
+ setError(error.response?.data?.Error);
50
+
51
+ toast.error(
52
+ error.response?.data?.Error
53
+ );
54
+ })
55
+
56
+
57
+ }
58
+
59
+
60
+
61
+ return (
62
+
63
+ <div className="min-h-screen flex items-center justify-center bg-gray-100">
64
+
65
+ <form
66
+ onSubmit={HandleLogin}
67
+ className="w-[420px] bg-white rounded-3xl shadow-2xl p-10 border-t-[6px] border-indigo-600"
68
+ >
69
+
70
+ <div className="text-center mb-8">
71
+
72
+ <div className="flex justify-center mb-3">
73
+ <Wrench
74
+ size={45}
75
+ className="text-indigo-600"
76
+ />
77
+ </div>
78
+
79
+ <h2 className="text-3xl font-bold text-gray-800">
80
+ auto fix Login
81
+ </h2>
82
+
83
+ <p className="text-gray-500 mt-2">
84
+ login
85
+ </p>
86
+
87
+ </div>
88
+
89
+
90
+ {/* ERROR */}
91
+ {
92
+ error &&
93
+ <p className="text-red-500 mb-4">
94
+ {error}
95
+ </p>
96
+ }
97
+
98
+
99
+ {/* EMAIL */}
100
+ <div className="mb-4 relative">
101
+
102
+ <Mail className="absolute top-3 left-3 text-gray-400" />
103
+
104
+ <input
105
+ type="email"
106
+ placeholder="Enter Email"
107
+ className="w-full border pl-10 p-3 rounded-xl"
108
+ onChange={(e) =>
109
+ setValues({
110
+ ...values,
111
+ Email: e.target.value
112
+ })
113
+ }
114
+ required
115
+ />
116
+
117
+ </div>
118
+
119
+
120
+ {/* PASSWORD */}
121
+ <div className="mb-6 relative">
122
+
123
+ <Lock className="absolute top-3 left-3 text-gray-400" />
124
+
125
+ <input
126
+ type="password"
127
+ placeholder="Enter Password"
128
+ className="w-full border pl-10 p-3 rounded-xl"
129
+ onChange={(e) =>
130
+ setValues({
131
+ ...values,
132
+ Password: e.target.value
133
+ })
134
+ }
135
+ required
136
+ />
137
+
138
+ </div>
139
+
140
+
141
+ {/* BUTTON */}
142
+ <button
143
+ type="submit"
144
+ className="w-full bg-indigo-600 text-white p-3 rounded-xl"
145
+ >
146
+ Login to System
147
+ </button>
148
+
149
+
150
+ {/* REGISTER */}
151
+ <p className="mt-6 text-center text-gray-600">
152
+
153
+ No account?
154
+
155
+ <Link
156
+ to="/register"
157
+ className="text-indigo-600 font-semibold ml-2"
158
+ >
159
+ Register
160
+ </Link>
161
+
162
+ </p>
163
+
164
+ </form>
165
+
166
+ </div>
167
+ );
168
+ }
169
+
170
+ export default Login;
@@ -0,0 +1,11 @@
1
+ import React from 'react'
2
+
3
+ function PageNotFound() {
4
+ return (
5
+ <div className='flex items-center justify-center min-h-screen bg-gray-200'>
6
+ <h2 className='text-red-700 text-[90px]'>Page Not Found <span>404</span></h2>
7
+ </div>
8
+ )
9
+ }
10
+
11
+ export default PageNotFound