create-jinmankn-app 1.0.11 → 1.0.13
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/package.json +1 -1
- package/templates/EPMS(Employee Payroll Managment System)/backend/routes/protectedRoutes.js +10 -0
- package/templates/EPMS(Employee Payroll Managment System)/backend/server.js +2 -0
- package/templates/EPMS(Employee Payroll Managment System)/frontend/src/App.jsx +2 -1
- package/templates/EPMS(Employee Payroll Managment System)/frontend/src/components/ProtectedRoute.jsx +8 -0
- package/templates/EPMS(Employee Payroll Managment System)/package-lock.json +13 -0
- package/templates/Faisal Hospital Managment System (FHMS) mysql/backend/routes/secureRoutes.js +14 -0
- package/templates/Faisal Hospital Managment System (FHMS) mysql/backend/server.js +2 -0
- package/templates/Faisal Hospital Managment System (FHMS) mysql/frontend/src/components/ProtectedRoute.jsx +2 -3
- package/templates/Faisal Hospital Managment System (FHMS) mysql/frontend/src/utils/auth.js +13 -0
- package/templates/LMS(Library Managment System)/backend/controllers/authController.js +32 -0
- package/templates/LMS(Library Managment System)/backend/routes/authRoutes.js +2 -1
- package/templates/LMS(Library Managment System)/backend/routes/protectedRoutes.js +19 -0
- package/templates/LMS(Library Managment System)/backend/server.js +2 -0
- package/templates/LMS(Library Managment System)/frontend/src/App.jsx +74 -15
- package/templates/LMS(Library Managment System)/frontend/src/ProtectedRoute.jsx +13 -0
- package/templates/LMS(Library Managment System)/frontend/src/pages/Login.jsx +4 -1
- package/templates/LMS(Library Managment System)/frontend/src/pages/Register.jsx +87 -0
- package/templates/SCMS(Supply Chain Managment System)/backend/routes/protectedRoutes.js +10 -0
- package/templates/SCMS(Supply Chain Managment System)/backend/server.js +2 -0
- package/templates/SCMS(Supply Chain Managment System)/frontend/src/App.jsx +2 -1
- package/templates/SCMS(Supply Chain Managment System)/frontend/src/components/ProtectedRoute.jsx +30 -0
- package/templates/SFM(School Fee Managment)/backend/middleware/protectedRoutes.js +10 -0
- package/templates/SFM(School Fee Managment)/frontend/src/App.jsx +7 -5
- package/templates/SFM(School Fee Managment)/frontend/src/components/ProtectedRoute.jsx +13 -0
- package/templates/SIMS(Stock Inventory Managment System)/backend/controllers/protectedController.js +14 -0
- package/templates/SIMS(Stock Inventory Managment System)/backend/routes/protectedRoutes.js +10 -0
- package/templates/SIMS(Stock Inventory Managment System)/backend/server.js +2 -1
- package/templates/SIMS(Stock Inventory Managment System)/frontend/src/App.jsx +57 -7
- package/templates/SIMS(Stock Inventory Managment System)/frontend/src/components/ProtectedRoute.jsx +8 -0
- package/templates/SMS(Stock Managment System)/backend-project/routes/protectedRoutes.js +18 -0
- package/templates/SMS(Stock Managment System)/backend-project/server.js +3 -1
- package/templates/SMS(Stock Managment System)/frontend-project/src/App.jsx +36 -7
- package/templates/SMS(Stock Managment System)/frontend-project/src/components/AppLayout.jsx +1 -1
- package/templates/SMS(Stock Managment System)/frontend-project/src/components/ProtectedRoute.jsx +13 -0
- package/templates/SMS(Stock Managment System)/frontend-project/src/pages/Login.jsx +1 -1
- package/templates/SMS(Stock Managment System)/frontend-project/src/pages/Product.jsx +211 -78
- package/templates/SMS(Stock Managment System)/frontend-project/src/pages/Profile.jsx +1 -1
- package/templates/SMS(Stock Managment System)/frontend-project/src/pages/Register.jsx +1 -1
- package/templates/SMS(Stock Managment System)/frontend-project/src/pages/Reports.jsx +1 -1
- package/templates/SMS(Stock Managment System)/frontend-project/src/pages/Sales.jsx +6 -6
- package/templates/SMS(Stock Managment System)/frontend-project/src/pages/Warehouse.jsx +150 -44
- package/templates/SMS(Stock Managment System)/package-lock.json +13 -0
- package/templates/SRMS(Sales Record Management System)/backend/routes/protectedRoutes.js +13 -0
- package/templates/SRMS(Sales Record Management System)/backend/server.js +2 -0
- package/templates/SRMS(Sales Record Management System)/frontend/src/App.jsx +2 -1
- package/templates/SRMS(Sales Record Management System)/frontend/src/components/ProtectedRoute.jsx +22 -0
- package/templates/index/README.md +34 -0
- package/templates/index/backend/config/db.js +12 -0
- package/templates/index/backend/controllers/authController.js +88 -0
- package/templates/index/backend/controllers/departmentController.js +74 -0
- package/templates/index/backend/controllers/employeeController.js +204 -0
- package/templates/index/backend/controllers/positionController.js +78 -0
- package/templates/index/backend/controllers/reportController.js +45 -0
- package/templates/index/backend/middleware/auth.js +27 -0
- package/templates/index/backend/models/Department.js +15 -0
- package/templates/index/backend/models/Employee.js +73 -0
- package/templates/index/backend/models/Position.js +20 -0
- package/templates/index/backend/models/User.js +32 -0
- package/templates/index/backend/package-lock.json +2190 -0
- package/templates/index/backend/package.json +22 -0
- package/templates/index/backend/routes/authRoutes.js +11 -0
- package/templates/index/backend/routes/departmentRoutes.js +17 -0
- package/templates/index/backend/routes/employeeRoutes.js +19 -0
- package/templates/index/backend/routes/positionRoutes.js +17 -0
- package/templates/index/backend/routes/protectedRoutes.js +10 -0
- package/templates/index/backend/routes/reportRoutes.js +9 -0
- package/templates/index/backend/server.js +30 -0
- package/templates/index/frontend/README.md +16 -0
- package/templates/index/frontend/eslint.config.js +21 -0
- package/templates/index/frontend/index.html +13 -0
- package/templates/index/frontend/package-lock.json +3095 -0
- package/templates/index/frontend/package.json +31 -0
- package/templates/index/frontend/public/favicon.svg +1 -0
- package/templates/index/frontend/src/App.css +0 -0
- package/templates/index/frontend/src/App.jsx +35 -0
- package/templates/index/frontend/src/assets/hero.png +0 -0
- package/templates/index/frontend/src/components/DashboardLayout.jsx +90 -0
- package/templates/index/frontend/src/components/ProtectedRoute.jsx +9 -0
- package/templates/index/frontend/src/index.css +59 -0
- package/templates/index/frontend/src/main.jsx +11 -0
- package/templates/index/frontend/src/pages/DashboardHome.jsx +58 -0
- package/templates/index/frontend/src/pages/Department.jsx +150 -0
- package/templates/index/frontend/src/pages/Employee.jsx +366 -0
- package/templates/index/frontend/src/pages/Login.jsx +81 -0
- package/templates/index/frontend/src/pages/Position.jsx +169 -0
- package/templates/index/frontend/src/pages/Register.jsx +102 -0
- package/templates/index/frontend/src/pages/Reports.jsx +94 -0
- package/templates/index/frontend/vite.config.js +7 -0
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { useState } from 'react';
|
|
2
|
+
import axios from 'axios';
|
|
3
|
+
import { Link, useNavigate } from 'react-router-dom';
|
|
4
|
+
|
|
5
|
+
function Register() {
|
|
6
|
+
const navigate = useNavigate();
|
|
7
|
+
const [name, setName] = useState('');
|
|
8
|
+
const [email, setEmail] = useState('');
|
|
9
|
+
const [password, setPassword] = useState('');
|
|
10
|
+
const [error, setError] = useState('');
|
|
11
|
+
const [message, setMessage] = useState('');
|
|
12
|
+
const [loading, setLoading] = useState(false);
|
|
13
|
+
|
|
14
|
+
const handleSubmit = async (e) => {
|
|
15
|
+
e.preventDefault();
|
|
16
|
+
setError('');
|
|
17
|
+
setMessage('');
|
|
18
|
+
setLoading(true);
|
|
19
|
+
|
|
20
|
+
try {
|
|
21
|
+
const response = await axios.post('http://localhost:5006/api/auth/register', {
|
|
22
|
+
name,
|
|
23
|
+
email,
|
|
24
|
+
password,
|
|
25
|
+
});
|
|
26
|
+
localStorage.setItem('token', response.data.token);
|
|
27
|
+
localStorage.setItem('user', JSON.stringify(response.data.user));
|
|
28
|
+
setMessage('Account created successfully');
|
|
29
|
+
navigate('/dashboard');
|
|
30
|
+
} catch (err) {
|
|
31
|
+
setError(err.response?.data?.message || 'Registration failed');
|
|
32
|
+
console.error('Server Error:', err.response?.data || err.message);
|
|
33
|
+
} finally {
|
|
34
|
+
setLoading(false);
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
return (
|
|
39
|
+
<div className="flex min-h-screen items-center justify-center bg-gray-100 px-4">
|
|
40
|
+
<div className="w-full max-w-md box p-6">
|
|
41
|
+
<h1 className="mb-1 text-2xl font-bold text-teal-900">DAB HRMS</h1>
|
|
42
|
+
<p className="mb-6 text-sm text-gray-600">Create a new account</p>
|
|
43
|
+
|
|
44
|
+
{message && <p className="alert-success">{message}</p>}
|
|
45
|
+
{error && <p className="alert-error">{error}</p>}
|
|
46
|
+
|
|
47
|
+
<form onSubmit={handleSubmit} className="space-y-4">
|
|
48
|
+
<div>
|
|
49
|
+
<label htmlFor="name" className="mb-1 block text-sm font-medium">Name</label>
|
|
50
|
+
<input
|
|
51
|
+
id="name"
|
|
52
|
+
type="text"
|
|
53
|
+
required
|
|
54
|
+
placeholder="Enter your full name"
|
|
55
|
+
value={name}
|
|
56
|
+
onChange={(e) => setName(e.target.value)}
|
|
57
|
+
className="input-field"
|
|
58
|
+
/>
|
|
59
|
+
</div>
|
|
60
|
+
|
|
61
|
+
<div>
|
|
62
|
+
<label htmlFor="email" className="mb-1 block text-sm font-medium">Email</label>
|
|
63
|
+
<input
|
|
64
|
+
id="email"
|
|
65
|
+
type="email"
|
|
66
|
+
required
|
|
67
|
+
placeholder="Enter your email address"
|
|
68
|
+
value={email}
|
|
69
|
+
onChange={(e) => setEmail(e.target.value)}
|
|
70
|
+
className="input-field"
|
|
71
|
+
/>
|
|
72
|
+
</div>
|
|
73
|
+
|
|
74
|
+
<div>
|
|
75
|
+
<label htmlFor="password" className="mb-1 block text-sm font-medium">Password</label>
|
|
76
|
+
<input
|
|
77
|
+
id="password"
|
|
78
|
+
type="password"
|
|
79
|
+
required
|
|
80
|
+
minLength={6}
|
|
81
|
+
placeholder="Create a secure password"
|
|
82
|
+
value={password}
|
|
83
|
+
onChange={(e) => setPassword(e.target.value)}
|
|
84
|
+
className="input-field"
|
|
85
|
+
/>
|
|
86
|
+
</div>
|
|
87
|
+
|
|
88
|
+
<button type="submit" disabled={loading} className="btn-primary w-full">
|
|
89
|
+
{loading ? 'Creating account...' : 'Register'}
|
|
90
|
+
</button>
|
|
91
|
+
</form>
|
|
92
|
+
|
|
93
|
+
<p className="mt-4 text-center text-sm text-gray-600">
|
|
94
|
+
Already have an account? <Link to="/login" className="text-blue-600 hover:underline">Sign in</Link>
|
|
95
|
+
</p>
|
|
96
|
+
</div>
|
|
97
|
+
</div>
|
|
98
|
+
);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
export default Register;
|
|
102
|
+
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { useEffect, useState } from 'react';
|
|
2
|
+
import axios from 'axios';
|
|
3
|
+
|
|
4
|
+
function Reports() {
|
|
5
|
+
const [report, setReport] = useState(null);
|
|
6
|
+
const [loading, setLoading] = useState(true);
|
|
7
|
+
const [error, setError] = useState('');
|
|
8
|
+
|
|
9
|
+
const headers = { Authorization: `Bearer ${localStorage.getItem('token')}` };
|
|
10
|
+
|
|
11
|
+
useEffect(() => {
|
|
12
|
+
axios
|
|
13
|
+
.get('http://localhost:5006/api/reports/on-leave-by-department', { headers })
|
|
14
|
+
.then((res) => setReport(res.data))
|
|
15
|
+
.catch((err) => setError(err.response?.data?.message || 'Failed to load report'))
|
|
16
|
+
.finally(() => setLoading(false));
|
|
17
|
+
}, []);
|
|
18
|
+
|
|
19
|
+
if (loading) {
|
|
20
|
+
return <p className="text-gray-600">Loading report...</p>;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
if (error) {
|
|
24
|
+
return <p className="alert-error">{error}</p>;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
return (
|
|
28
|
+
<div>
|
|
29
|
+
<h1 className="mb-2 text-2xl font-bold">Employee Status Report</h1>
|
|
30
|
+
<p className="mb-6 text-sm text-gray-600">
|
|
31
|
+
Employees currently on leave, organized by department
|
|
32
|
+
</p>
|
|
33
|
+
|
|
34
|
+
<div className="mb-6 box border-l-4 border-teal-700">
|
|
35
|
+
<p className="text-sm text-gray-600">Total employees on leave</p>
|
|
36
|
+
<p className="text-3xl font-bold text-teal-900">{report.totalOnLeave}</p>
|
|
37
|
+
</div>
|
|
38
|
+
|
|
39
|
+
{report.departments.length === 0 ? (
|
|
40
|
+
<div className="box">
|
|
41
|
+
<p className="text-gray-600">
|
|
42
|
+
No employees are currently on leave. Set an employee's status to{' '}
|
|
43
|
+
<strong>on leave</strong> on the Employees page to include them in this report.
|
|
44
|
+
</p>
|
|
45
|
+
</div>
|
|
46
|
+
) : (
|
|
47
|
+
report.departments.map((dept) => (
|
|
48
|
+
<div key={dept.departmentName} className="mb-6 box">
|
|
49
|
+
<div className="mb-3 flex flex-wrap items-center justify-between gap-2">
|
|
50
|
+
<h2 className="text-lg font-semibold">{dept.departmentName}</h2>
|
|
51
|
+
<span className="rounded-full bg-teal-100 px-3 py-1 text-sm font-medium text-teal-900">
|
|
52
|
+
{dept.count} on leave
|
|
53
|
+
</span>
|
|
54
|
+
</div>
|
|
55
|
+
|
|
56
|
+
<div className="overflow-x-auto">
|
|
57
|
+
<table className="data-table">
|
|
58
|
+
<thead>
|
|
59
|
+
<tr>
|
|
60
|
+
<th>Name</th>
|
|
61
|
+
<th>Email</th>
|
|
62
|
+
<th>Telephone</th>
|
|
63
|
+
<th>Position</th>
|
|
64
|
+
<th>Status</th>
|
|
65
|
+
</tr>
|
|
66
|
+
</thead>
|
|
67
|
+
<tbody>
|
|
68
|
+
{dept.employees.map((emp) => (
|
|
69
|
+
<tr key={emp.id}>
|
|
70
|
+
<td>{emp.firstName} {emp.lastName}</td>
|
|
71
|
+
<td>{emp.email}</td>
|
|
72
|
+
<td>{emp.telephone}</td>
|
|
73
|
+
<td>{emp.position}</td>
|
|
74
|
+
<td>{emp.status}</td>
|
|
75
|
+
</tr>
|
|
76
|
+
))}
|
|
77
|
+
</tbody>
|
|
78
|
+
</table>
|
|
79
|
+
</div>
|
|
80
|
+
</div>
|
|
81
|
+
))
|
|
82
|
+
)}
|
|
83
|
+
|
|
84
|
+
<div className="box bg-teal-50">
|
|
85
|
+
<p className="font-semibold text-teal-900">
|
|
86
|
+
Grand total on leave: {report.totalOnLeave}
|
|
87
|
+
</p>
|
|
88
|
+
</div>
|
|
89
|
+
</div>
|
|
90
|
+
);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
export default Reports;
|
|
94
|
+
|