alpe-temp 1.0.0 → 1.0.2
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/epms.js +149 -60
- package/frontend-project/src/App.css +1 -0
- package/frontend-project/src/Auth/Login.jsx +85 -0
- package/frontend-project/src/Auth/Register.jsx +183 -0
- package/frontend-project/src/Intro.jsx +33 -0
- package/frontend-project/src/LayOut.jsx +38 -0
- package/frontend-project/src/api/ApiClient.js +92 -0
- package/frontend-project/src/assets/hero.png +0 -0
- package/frontend-project/src/assets/react.svg +1 -0
- package/frontend-project/src/assets/vite.svg +1 -0
- package/frontend-project/src/components/Aside.jsx +9 -0
- package/frontend-project/src/components/Button.jsx +100 -0
- package/frontend-project/src/components/Card.jsx +104 -0
- package/frontend-project/src/components/FormField.jsx +129 -0
- package/frontend-project/src/components/Modal.jsx +106 -0
- package/frontend-project/src/components/Table.jsx +127 -0
- package/frontend-project/src/components/Toast.jsx +64 -0
- package/frontend-project/src/components/index.js +14 -0
- package/frontend-project/src/config.js +66 -0
- package/frontend-project/src/design.js +115 -0
- package/frontend-project/src/index.css +60 -0
- package/frontend-project/src/layouts/BottomNav.jsx +156 -0
- package/frontend-project/src/layouts/TopNav.jsx +150 -0
- package/frontend-project/src/layouts/useShell.js +44 -0
- package/frontend-project/src/main.jsx +41 -0
- package/frontend-project/src/pages/Department.jsx +188 -0
- package/frontend-project/src/pages/Employee.jsx +274 -0
- package/frontend-project/src/pages/Home.jsx +79 -0
- package/frontend-project/src/pages/Profile.jsx +9 -0
- package/frontend-project/src/pages/Register.jsx +57 -0
- package/frontend-project/src/pages/Reports.jsx +91 -0
- package/frontend-project/src/pages/Salary.jsx +264 -0
- package/frontend-project/src/themes.js +175 -0
- package/package.json +1 -1
package/bin/epms.js
CHANGED
|
@@ -5,38 +5,34 @@ const readline = require('readline');
|
|
|
5
5
|
const { execSync } = require('child_process');
|
|
6
6
|
|
|
7
7
|
const ROOT = path.resolve(__dirname, '..');
|
|
8
|
-
const
|
|
9
|
-
|
|
8
|
+
const CWD = process.cwd();
|
|
10
9
|
const args = process.argv.slice(2);
|
|
11
10
|
|
|
11
|
+
// ─── Help ─────────────────────────────────────────────────────────────────────
|
|
12
12
|
if (args.includes('--help') || args.includes('-h')) {
|
|
13
13
|
console.log(`
|
|
14
14
|
alpe-temp — Employee Payroll Management System (EPMS)
|
|
15
15
|
|
|
16
16
|
Usage:
|
|
17
|
-
npx alpe-temp
|
|
18
|
-
npx alpe-temp
|
|
17
|
+
npx alpe-temp Scaffold project + start server
|
|
18
|
+
npx alpe-temp init Scaffold project files only
|
|
19
|
+
npx alpe-temp seed Seed the database
|
|
20
|
+
npx alpe-temp start Start server (in existing project)
|
|
19
21
|
|
|
20
22
|
Options:
|
|
21
23
|
--db <uri> MongoDB connection string (non-interactive)
|
|
22
24
|
|
|
23
|
-
Environment variables
|
|
25
|
+
Environment variables:
|
|
24
26
|
PORT Server port (default: 3000)
|
|
25
27
|
MONGODB_URI MongoDB connection string
|
|
26
28
|
JWT_SECRET Secret for JWT signing
|
|
27
29
|
NODE_ENV Environment mode (development/production)
|
|
28
|
-
|
|
29
|
-
Requirements:
|
|
30
|
-
- Node.js >= 18
|
|
31
|
-
- MongoDB (will prompt if not found)
|
|
32
|
-
|
|
33
|
-
Visit http://localhost:3000 after starting.
|
|
34
30
|
`);
|
|
35
31
|
process.exit(0);
|
|
36
32
|
}
|
|
37
33
|
|
|
38
|
-
// ───
|
|
39
|
-
const ENV_PATH = path.join(
|
|
34
|
+
// ─── Helpers ──────────────────────────────────────────────────────────────────
|
|
35
|
+
const ENV_PATH = path.join(CWD, '.env');
|
|
40
36
|
|
|
41
37
|
function loadEnv() {
|
|
42
38
|
if (!fs.existsSync(ENV_PATH)) return {};
|
|
@@ -60,7 +56,7 @@ function writeEnv(key, value) {
|
|
|
60
56
|
fs.writeFileSync(ENV_PATH, updated, 'utf-8');
|
|
61
57
|
}
|
|
62
58
|
|
|
63
|
-
async function
|
|
59
|
+
async function ask(question, defaultValue) {
|
|
64
60
|
const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
|
|
65
61
|
return new Promise((resolve) => {
|
|
66
62
|
const hint = defaultValue ? ` (default: ${defaultValue})` : '';
|
|
@@ -86,76 +82,169 @@ async function waitForMongo(uri, timeoutMs = 5000) {
|
|
|
86
82
|
return false;
|
|
87
83
|
}
|
|
88
84
|
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
85
|
+
function isScaffolded(dir) {
|
|
86
|
+
return fs.existsSync(path.join(dir, 'backend-project', 'server.js'));
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
// ─── Scaffold: copy project to CWD ────────────────────────────────────────────
|
|
90
|
+
function scaffold() {
|
|
91
|
+
if (isScaffolded(CWD)) {
|
|
92
|
+
console.log(' Project already exists in this directory.');
|
|
93
|
+
return false;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
console.log('\n Setting up alpe-temp project...\n');
|
|
97
|
+
|
|
98
|
+
const skipDirs = new Set(['node_modules', '.git']);
|
|
99
|
+
const entries = fs.readdirSync(ROOT, { withFileTypes: true });
|
|
100
|
+
|
|
101
|
+
for (const entry of entries) {
|
|
102
|
+
if (skipDirs.has(entry.name)) continue;
|
|
103
|
+
const src = path.join(ROOT, entry.name);
|
|
104
|
+
const dest = path.join(CWD, entry.name);
|
|
105
|
+
if (entry.isDirectory()) {
|
|
106
|
+
fs.cpSync(src, dest, {
|
|
107
|
+
recursive: true,
|
|
108
|
+
filter: (s) => !skipDirs.has(path.basename(s)) && path.basename(s) !== 'node_modules',
|
|
109
|
+
});
|
|
110
|
+
} else if (!fs.existsSync(dest)) {
|
|
111
|
+
fs.copyFileSync(src, dest);
|
|
112
|
+
}
|
|
100
113
|
}
|
|
101
114
|
|
|
102
|
-
|
|
115
|
+
console.log(' ✓ Project files copied');
|
|
116
|
+
return true;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
// ─── Install dependencies ─────────────────────────────────────────────────────
|
|
120
|
+
function installDeps() {
|
|
121
|
+
console.log(' Installing dependencies...');
|
|
122
|
+
execSync('npm install', { cwd: CWD, stdio: 'inherit' });
|
|
123
|
+
console.log(' ✓ Dependencies installed');
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
// ─── Configure MongoDB ────────────────────────────────────────────────────────
|
|
127
|
+
async function configureMongo() {
|
|
103
128
|
const env = loadEnv();
|
|
104
|
-
if (env.MONGODB_URI)
|
|
129
|
+
if (env.MONGODB_URI) {
|
|
130
|
+
process.env.MONGODB_URI = env.MONGODB_URI;
|
|
131
|
+
return true;
|
|
132
|
+
}
|
|
105
133
|
|
|
106
|
-
// ─── --db flag overrides everything ────────────────────────────────────
|
|
107
134
|
const dbIndex = args.indexOf('--db');
|
|
108
135
|
if (dbIndex !== -1 && args[dbIndex + 1]) {
|
|
109
136
|
process.env.MONGODB_URI = args[dbIndex + 1];
|
|
137
|
+
writeEnv('MONGODB_URI', args[dbIndex + 1]);
|
|
138
|
+
return true;
|
|
110
139
|
}
|
|
111
140
|
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
);
|
|
119
|
-
if (uri) {
|
|
120
|
-
process.env.MONGODB_URI = uri;
|
|
121
|
-
writeEnv('MONGODB_URI', uri);
|
|
122
|
-
console.log(' Saved to .env');
|
|
123
|
-
}
|
|
141
|
+
console.log(' MongoDB not configured.');
|
|
142
|
+
const uri = await ask('Enter MongoDB URI', 'mongodb://127.0.0.1:27017/EPMS');
|
|
143
|
+
if (uri) {
|
|
144
|
+
process.env.MONGODB_URI = uri;
|
|
145
|
+
writeEnv('MONGODB_URI', uri);
|
|
146
|
+
console.log(' ✓ Saved to .env');
|
|
124
147
|
}
|
|
125
148
|
|
|
126
|
-
|
|
149
|
+
return !!process.env.MONGODB_URI;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
// ─── Verify MongoDB ───────────────────────────────────────────────────────────
|
|
153
|
+
async function verifyMongo() {
|
|
127
154
|
const uri = process.env.MONGODB_URI || 'mongodb://127.0.0.1:27017/EPMS';
|
|
128
155
|
process.stdout.write(' Checking MongoDB connection...');
|
|
129
156
|
const reachable = await waitForMongo(uri);
|
|
130
157
|
if (reachable) {
|
|
131
158
|
console.log(' connected');
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
console.error('\n Unable to connect to MongoDB. Please ensure it is running.\n');
|
|
144
|
-
process.exit(1);
|
|
145
|
-
}
|
|
159
|
+
return true;
|
|
160
|
+
}
|
|
161
|
+
console.log(' failed');
|
|
162
|
+
console.log(`\n Could not connect to MongoDB at:\n ${uri}\n`);
|
|
163
|
+
const retry = await ask('Try a different URI', uri);
|
|
164
|
+
if (retry) {
|
|
165
|
+
process.env.MONGODB_URI = retry;
|
|
166
|
+
writeEnv('MONGODB_URI', retry);
|
|
167
|
+
console.log(' ✓ Saved to .env');
|
|
168
|
+
process.stdout.write(' Checking MongoDB connection...');
|
|
169
|
+
if (await waitForMongo(retry)) {
|
|
146
170
|
console.log(' connected');
|
|
147
|
-
|
|
171
|
+
return true;
|
|
172
|
+
}
|
|
173
|
+
console.log(' failed');
|
|
174
|
+
}
|
|
175
|
+
return false;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
// ─── Start server ─────────────────────────────────────────────────────────────
|
|
179
|
+
function startServer() {
|
|
180
|
+
process.env.NODE_ENV = process.env.NODE_ENV || 'production';
|
|
181
|
+
const serverEntry = path.join(CWD, 'backend-project', 'server.js');
|
|
182
|
+
if (!fs.existsSync(serverEntry)) {
|
|
183
|
+
console.error(' server.js not found. Run from an alpe-temp project directory.');
|
|
184
|
+
process.exit(1);
|
|
185
|
+
}
|
|
186
|
+
require(serverEntry);
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
// ─── Main ─────────────────────────────────────────────────────────────────────
|
|
190
|
+
async function main() {
|
|
191
|
+
// Seed
|
|
192
|
+
if (args.includes('seed')) {
|
|
193
|
+
const cwdEnv = loadEnv();
|
|
194
|
+
if (cwdEnv.MONGODB_URI) process.env.MONGODB_URI = cwdEnv.MONGODB_URI;
|
|
195
|
+
if (!process.env.MONGODB_URI) await configureMongo();
|
|
196
|
+
console.log('Seeding database...');
|
|
197
|
+
const seedEntry = path.join(isScaffolded(CWD) ? CWD : ROOT, 'backend-project', 'src', 'seed.js');
|
|
198
|
+
execSync(`node "${seedEntry}"`, { cwd: isScaffolded(CWD) ? CWD : ROOT, stdio: 'inherit' });
|
|
199
|
+
return;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
// Init: scaffold only
|
|
203
|
+
if (args.includes('init')) {
|
|
204
|
+
scaffold();
|
|
205
|
+
if (isScaffolded(CWD)) {
|
|
206
|
+
installDeps();
|
|
207
|
+
console.log('\n ✔ Project ready! Run:\n npm start\n');
|
|
208
|
+
}
|
|
209
|
+
return;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
// Start: just start the server (assume already scaffolded)
|
|
213
|
+
if (args.includes('start')) {
|
|
214
|
+
if (!isScaffolded(CWD)) {
|
|
215
|
+
console.error(' No alpe-temp project found in this directory. Run `npx alpe-temp init` first.');
|
|
216
|
+
process.exit(1);
|
|
217
|
+
}
|
|
218
|
+
const env = loadEnv();
|
|
219
|
+
if (env.MONGODB_URI) process.env.MONGODB_URI = env.MONGODB_URI;
|
|
220
|
+
if (!process.env.MONGODB_URI && !await configureMongo()) {
|
|
221
|
+
console.error(' MongoDB URI is required.');
|
|
222
|
+
process.exit(1);
|
|
223
|
+
}
|
|
224
|
+
if (!(await verifyMongo())) {
|
|
148
225
|
console.error('\n Unable to connect to MongoDB. Please ensure it is running.\n');
|
|
149
226
|
process.exit(1);
|
|
150
227
|
}
|
|
228
|
+
startServer();
|
|
229
|
+
return;
|
|
151
230
|
}
|
|
152
231
|
|
|
153
|
-
//
|
|
154
|
-
|
|
155
|
-
|
|
232
|
+
// Default: scaffold → install → configure → start
|
|
233
|
+
const justScaffolded = scaffold();
|
|
234
|
+
if (justScaffolded) installDeps();
|
|
235
|
+
if (!isScaffolded(CWD)) {
|
|
236
|
+
console.error(' Project setup failed.');
|
|
237
|
+
process.exit(1);
|
|
238
|
+
}
|
|
239
|
+
await configureMongo();
|
|
240
|
+
if (!(await verifyMongo())) {
|
|
241
|
+
console.error('\n Unable to connect to MongoDB.\n');
|
|
242
|
+
process.exit(1);
|
|
243
|
+
}
|
|
244
|
+
startServer();
|
|
156
245
|
}
|
|
157
246
|
|
|
158
247
|
main().catch((err) => {
|
|
159
|
-
console.error('Failed
|
|
248
|
+
console.error('Failed:', err.message);
|
|
160
249
|
process.exit(1);
|
|
161
250
|
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
@import "tailwindcss";
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import React, { useState } from 'react';
|
|
2
|
+
import { useNavigate, Link } from 'react-router-dom';
|
|
3
|
+
import { Eye, EyeOff, LogIn } from 'lucide-react';
|
|
4
|
+
import { authApi } from '../api/ApiClient';
|
|
5
|
+
import Button from '../components/Button';
|
|
6
|
+
import FormField from '../components/FormField';
|
|
7
|
+
import { useToast } from '../components/Toast';
|
|
8
|
+
|
|
9
|
+
export default function Login() {
|
|
10
|
+
const [email, setEmail] = useState('');
|
|
11
|
+
const [password, setPassword] = useState('');
|
|
12
|
+
const [showPwd, setShowPwd] = useState(false);
|
|
13
|
+
const [loading, setLoading] = useState(false);
|
|
14
|
+
const navigate = useNavigate();
|
|
15
|
+
const toast = useToast();
|
|
16
|
+
|
|
17
|
+
const handleLogin = async () => {
|
|
18
|
+
if (!email || !password) { toast.error('Please fill in all fields'); return; }
|
|
19
|
+
setLoading(true);
|
|
20
|
+
try {
|
|
21
|
+
const data = await authApi.login({ email: email.trim(), password });
|
|
22
|
+
localStorage.setItem('token', data.data?.accessToken ?? '');
|
|
23
|
+
localStorage.setItem('user', JSON.stringify(data.data?.user ?? {}));
|
|
24
|
+
toast.success('Login successful');
|
|
25
|
+
navigate('/dashboard/overview');
|
|
26
|
+
} catch (err) {
|
|
27
|
+
toast.error(err.message ?? 'Login failed');
|
|
28
|
+
} finally {
|
|
29
|
+
setLoading(false);
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
const handleKey = (e) => { if (e.key === 'Enter') handleLogin(); };
|
|
34
|
+
|
|
35
|
+
return (
|
|
36
|
+
<div className="min-h-screen flex items-center justify-center p-4">
|
|
37
|
+
<div className="w-full max-w-[760px] flex h-[500px] overflow-hidden">
|
|
38
|
+
<div className="hidden bg-[#008A75] sm:flex flex-col w-5/12 p-10 text-white">
|
|
39
|
+
<div className="mb-auto">
|
|
40
|
+
<div className="flex items-center gap-2 mb-1">
|
|
41
|
+
<img src="/logo.png" alt="EPMS" className="w-8 h-10" />
|
|
42
|
+
<h1 className="text-[22px] font-bold tracking-tight mt-3">EPMS</h1>
|
|
43
|
+
</div>
|
|
44
|
+
<p className="text-[10px] text-white/60 font-medium uppercase tracking-widest">Employee Payroll Management System</p>
|
|
45
|
+
</div>
|
|
46
|
+
<div className="mt-10">
|
|
47
|
+
<p className="text-[18px] font-semibold leading-snug">
|
|
48
|
+
Welcome back.<br />
|
|
49
|
+
<span className="text-white/60">Manage your workforce.</span>
|
|
50
|
+
</p>
|
|
51
|
+
<p className="text-[12px] text-white/50 mt-3 leading-relaxed">
|
|
52
|
+
Sign in to manage employees, departments, and payroll records.
|
|
53
|
+
</p>
|
|
54
|
+
</div>
|
|
55
|
+
<div className="mt-auto pt-10 border-t border-white/20">
|
|
56
|
+
<p className="text-[11px] text-white/40">© {new Date().getFullYear()} EPMS · All rights reserved</p>
|
|
57
|
+
</div>
|
|
58
|
+
</div>
|
|
59
|
+
<div className="flex-1 bg-white p-8 sm:p-10 flex flex-col justify-center">
|
|
60
|
+
<div className="mb-6">
|
|
61
|
+
<h2 className="text-[20px] font-bold text-gray-800">Sign in</h2>
|
|
62
|
+
<p className="text-[13px] text-gray-400 mt-1">
|
|
63
|
+
Don't have an account?{' '}
|
|
64
|
+
<Link to="/register" className="text-[#008A75] font-semibold hover:underline">Create one</Link>
|
|
65
|
+
</p>
|
|
66
|
+
</div>
|
|
67
|
+
<div className="space-y-3">
|
|
68
|
+
<FormField label="Email address" required>
|
|
69
|
+
<FormField.Input type="email" value={email} onChange={(v) => setEmail(v)} placeholder="you@company.com" onKeyDown={handleKey} autoComplete="email" className='rounded-none' />
|
|
70
|
+
</FormField>
|
|
71
|
+
<FormField label="Password" required>
|
|
72
|
+
<div className="relative">
|
|
73
|
+
<FormField.Input type={showPwd ? 'text' : 'password'} value={password} onChange={(v) => setPassword(v)} placeholder="Enter password" onKeyDown={handleKey} className='rounded-none' autoComplete="current-password" className="pr-10" />
|
|
74
|
+
<button type="button" onClick={() => setShowPwd((v) => !v)} className="absolute right-3 top-1/2 -translate-y-1/2 text-gray-400 hover:text-gray-600 transition-colors">
|
|
75
|
+
{showPwd ? <EyeOff className="w-4 h-4" /> : <Eye className="w-4 h-4" />}
|
|
76
|
+
</button>
|
|
77
|
+
</div>
|
|
78
|
+
</FormField>
|
|
79
|
+
</div>
|
|
80
|
+
<Button className="mt-5 rounded-none" fullWidth size="lg" loading={loading} icon={<LogIn className="w-4 h-4" />} onClick={handleLogin}>Sign in</Button>
|
|
81
|
+
</div>
|
|
82
|
+
</div>
|
|
83
|
+
</div>
|
|
84
|
+
);
|
|
85
|
+
}
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Register.jsx – Account creation page.
|
|
3
|
+
* Matches Login's split-panel layout.
|
|
4
|
+
* Backend: POST /api/auth/signup → { name, email, password }
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import React, { useState } from 'react';
|
|
8
|
+
import { useNavigate, Link } from 'react-router-dom';
|
|
9
|
+
import { Eye, EyeOff, UserPlus } from 'lucide-react';
|
|
10
|
+
import { authApi } from '../api/ApiClient';
|
|
11
|
+
import Button from '../components/Button';
|
|
12
|
+
import FormField from '../components/FormField';
|
|
13
|
+
import { useToast } from '../components/Toast';
|
|
14
|
+
|
|
15
|
+
export default function Register() {
|
|
16
|
+
const [name, setName] = useState('');
|
|
17
|
+
const [email, setEmail] = useState('');
|
|
18
|
+
const [password, setPassword] = useState('');
|
|
19
|
+
const [confirm, setConfirm] = useState('');
|
|
20
|
+
const [showPwd, setShowPwd] = useState(false);
|
|
21
|
+
const [loading, setLoading] = useState(false);
|
|
22
|
+
const [errors, setErrors] = useState({});
|
|
23
|
+
const navigate = useNavigate();
|
|
24
|
+
const toast = useToast();
|
|
25
|
+
|
|
26
|
+
const validate = () => {
|
|
27
|
+
const e = {};
|
|
28
|
+
if (!name.trim()) e.name = 'Full name is required';
|
|
29
|
+
if (!email.trim()) e.email = 'Email is required';
|
|
30
|
+
else if (!/\S+@\S+\.\S+/.test(email)) e.email = 'Enter a valid email';
|
|
31
|
+
if (!password) e.password = 'Password is required';
|
|
32
|
+
else if (password.length < 6) e.password = 'Minimum 6 characters';
|
|
33
|
+
if (!confirm) e.confirm = 'Please confirm your password';
|
|
34
|
+
else if (confirm !== password) e.confirm = 'Passwords do not match';
|
|
35
|
+
setErrors(e);
|
|
36
|
+
return Object.keys(e).length === 0;
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
const handleRegister = async () => {
|
|
40
|
+
if (!validate()) return;
|
|
41
|
+
try {
|
|
42
|
+
setLoading(true);
|
|
43
|
+
const data = await authApi.signup({
|
|
44
|
+
name: name.trim(),
|
|
45
|
+
email: email.trim(),
|
|
46
|
+
password: password,
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
localStorage.setItem('token', data.data?.accessToken ?? '');
|
|
50
|
+
localStorage.setItem('user', JSON.stringify(data.data?.user ?? {}));
|
|
51
|
+
|
|
52
|
+
toast.success('Account created — welcome!');
|
|
53
|
+
navigate('/dashboard/overview');
|
|
54
|
+
} catch (err) {
|
|
55
|
+
toast.error(err.message ?? 'Registration failed. Please try again.');
|
|
56
|
+
} finally {
|
|
57
|
+
setLoading(false);
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
const handleKey = (e) => { if (e.key === 'Enter') handleRegister(); };
|
|
62
|
+
|
|
63
|
+
return (
|
|
64
|
+
<div className="min-h-screen flex items-center justify-center p-4">
|
|
65
|
+
<div className="w-full max-w-[760px] flex rounded-none h-[540px] overflow-hidden ">
|
|
66
|
+
|
|
67
|
+
{/* ── Left panel ── */}
|
|
68
|
+
<div className="hidden sm:flex bg-[#008A75] flex-col w-5/12 p-10 text-white">
|
|
69
|
+
<div className="mb-auto">
|
|
70
|
+
<div className="flex items-center gap-2 mb-1">
|
|
71
|
+
<img src="/logo.png" alt="EPMS" className="w-8 h-10" />
|
|
72
|
+
<h1 className="text-[22px] font-bold tracking-tight mt-3">EPMS</h1>
|
|
73
|
+
</div>
|
|
74
|
+
<p className="text-[10px] text-white/60 font-medium uppercase tracking-widest">Employee Payroll Management System</p>
|
|
75
|
+
</div>
|
|
76
|
+
|
|
77
|
+
<div className="mt-10">
|
|
78
|
+
<p className="text-[18px] font-semibold leading-snug">
|
|
79
|
+
Get started today.<br />
|
|
80
|
+
<span className="text-white/60">Your team awaits.</span>
|
|
81
|
+
</p>
|
|
82
|
+
<p className="text-[12px] text-white/50 mt-3 leading-relaxed">
|
|
83
|
+
Create your admin account and start managing employees, departments, and payroll.
|
|
84
|
+
</p>
|
|
85
|
+
</div>
|
|
86
|
+
|
|
87
|
+
<div className="mt-auto pt-10 border-t border-white/20">
|
|
88
|
+
<p className="text-[11px] text-white/40">
|
|
89
|
+
© {new Date().getFullYear()} EPMS · All rights reserved
|
|
90
|
+
</p>
|
|
91
|
+
</div>
|
|
92
|
+
</div>
|
|
93
|
+
|
|
94
|
+
{/* ── Right panel ── */}
|
|
95
|
+
<div className="flex-1 p-8 sm:p-10 flex flex-col justify-center overflow-y-auto">
|
|
96
|
+
<div className="mb-6">
|
|
97
|
+
<h2 className="text-[20px] font-bold text-gray-800">Create account</h2>
|
|
98
|
+
<p className="text-[13px] text-gray-400 mt-1">
|
|
99
|
+
Already have an account?{' '}
|
|
100
|
+
<Link to="/login" className="text-[#008A75] font-semibold hover:underline">
|
|
101
|
+
Sign in
|
|
102
|
+
</Link>
|
|
103
|
+
</p>
|
|
104
|
+
</div>
|
|
105
|
+
|
|
106
|
+
<div className="space-y-3">
|
|
107
|
+
<FormField label="Full name" required error={errors.name}>
|
|
108
|
+
<FormField.Input
|
|
109
|
+
type="text"
|
|
110
|
+
value={name}
|
|
111
|
+
onChange={(v) => setName(v)}
|
|
112
|
+
placeholder="Jane Doe"
|
|
113
|
+
onKeyDown={handleKey}
|
|
114
|
+
autoComplete="name"
|
|
115
|
+
className='rounded-none'
|
|
116
|
+
/>
|
|
117
|
+
</FormField>
|
|
118
|
+
|
|
119
|
+
<FormField label="Email address" required error={errors.email}>
|
|
120
|
+
<FormField.Input
|
|
121
|
+
type="email"
|
|
122
|
+
value={email}
|
|
123
|
+
onChange={(v) => setEmail(v)}
|
|
124
|
+
placeholder="you@company.com"
|
|
125
|
+
onKeyDown={handleKey}
|
|
126
|
+
autoComplete="email"
|
|
127
|
+
className='rounded-none'
|
|
128
|
+
/>
|
|
129
|
+
</FormField>
|
|
130
|
+
|
|
131
|
+
<FormField label="Password" required error={errors.password}>
|
|
132
|
+
<div className="relative">
|
|
133
|
+
<FormField.Input
|
|
134
|
+
type={showPwd ? 'text' : 'password'}
|
|
135
|
+
value={password}
|
|
136
|
+
onChange={(v) => setPassword(v)}
|
|
137
|
+
placeholder="Min. 6 characters"
|
|
138
|
+
onKeyDown={handleKey}
|
|
139
|
+
autoComplete="new-password"
|
|
140
|
+
className="pr-10 rounded-none"
|
|
141
|
+
/>
|
|
142
|
+
<button
|
|
143
|
+
type="button"
|
|
144
|
+
onClick={() => setShowPwd((v) => !v)}
|
|
145
|
+
className="absolute right-3 top-1/2 -translate-y-1/2 text-gray-400 hover:text-gray-600 transition-colors"
|
|
146
|
+
>
|
|
147
|
+
{showPwd ? <EyeOff className="w-4 h-4" /> : <Eye className="w-4 h-4" />}
|
|
148
|
+
</button>
|
|
149
|
+
</div>
|
|
150
|
+
</FormField>
|
|
151
|
+
|
|
152
|
+
<FormField label="Confirm password" required error={errors.confirm}>
|
|
153
|
+
<FormField.Input
|
|
154
|
+
type={showPwd ? 'text' : 'password'}
|
|
155
|
+
value={confirm}
|
|
156
|
+
onChange={(v) => setConfirm(v)}
|
|
157
|
+
placeholder="Repeat your password"
|
|
158
|
+
onKeyDown={handleKey}
|
|
159
|
+
autoComplete="new-password"
|
|
160
|
+
className='rounded-none'
|
|
161
|
+
/>
|
|
162
|
+
</FormField>
|
|
163
|
+
</div>
|
|
164
|
+
|
|
165
|
+
<Button
|
|
166
|
+
className="mt-5 rounded-none"
|
|
167
|
+
fullWidth
|
|
168
|
+
size="lg"
|
|
169
|
+
loading={loading}
|
|
170
|
+
icon={<UserPlus className="w-4 h-4" />}
|
|
171
|
+
onClick={handleRegister}
|
|
172
|
+
>
|
|
173
|
+
Create account
|
|
174
|
+
</Button>
|
|
175
|
+
|
|
176
|
+
<p className="text-[11px] text-gray-400 text-center mt-4">
|
|
177
|
+
Protected by JWT authentication
|
|
178
|
+
</p>
|
|
179
|
+
</div>
|
|
180
|
+
</div>
|
|
181
|
+
</div>
|
|
182
|
+
);
|
|
183
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { useEffect } from 'react'
|
|
2
|
+
import { useNavigate } from 'react-router-dom'
|
|
3
|
+
|
|
4
|
+
export default function Intro() {
|
|
5
|
+
const navigate = useNavigate()
|
|
6
|
+
|
|
7
|
+
useEffect(() => {
|
|
8
|
+
const timer = setTimeout(() => {
|
|
9
|
+
const token = localStorage.getItem('token')
|
|
10
|
+
navigate(token ? '/dashboard/overview' : '/login', { replace: true })
|
|
11
|
+
}, 2800)
|
|
12
|
+
return () => clearTimeout(timer)
|
|
13
|
+
}, [navigate])
|
|
14
|
+
|
|
15
|
+
return (
|
|
16
|
+
<div className="fixed inset-0 z-50 flex flex-col items-center justify-center bg-white">
|
|
17
|
+
<div className="flex flex-col items-center gap-6">
|
|
18
|
+
<img src="/logo.png" alt="EPMS" className="w-16 h-20" />
|
|
19
|
+
|
|
20
|
+
<div className="flex flex-col items-center">
|
|
21
|
+
<span className="text-4xl font-bold tracking-tight text-zinc-800">
|
|
22
|
+
EP<span className="text-[#008A75]">MS</span>
|
|
23
|
+
</span>
|
|
24
|
+
<span className="text-xs text-zinc-800/60 font-medium uppercase tracking-[0.2em] mt-1">
|
|
25
|
+
Employee Payroll Management System
|
|
26
|
+
</span>
|
|
27
|
+
</div>
|
|
28
|
+
|
|
29
|
+
<div className="w-6 h-6 border-2 border-zinc-200 border-t-[#008A75] rounded-full animate-spin mt-2" />
|
|
30
|
+
</div>
|
|
31
|
+
</div>
|
|
32
|
+
)
|
|
33
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
2
|
+
// 🏗️ LAYOUT — The app shell (reads config, picks the right layout)
|
|
3
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
4
|
+
//
|
|
5
|
+
// WHAT THIS FILE DOES:
|
|
6
|
+
// 1. Reads your config.js settings
|
|
7
|
+
// 2. Applies the chosen theme as CSS variables on the root div
|
|
8
|
+
// 3. Renders the correct navigation layout (top or bottom)
|
|
9
|
+
//
|
|
10
|
+
// HOW TO CUSTOMIZE:
|
|
11
|
+
// Change config.js values and everything updates automatically.
|
|
12
|
+
// - navigation: 'topnav' | 'bottomnav'
|
|
13
|
+
// - theme: any theme name from themes.js
|
|
14
|
+
// - rounded: 'none' | 'sm' | 'md' | 'lg' | 'xl' | 'full'
|
|
15
|
+
// - fontSize: 'normal' | 'large'
|
|
16
|
+
//
|
|
17
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
18
|
+
|
|
19
|
+
import React from 'react';
|
|
20
|
+
import { config } from './config';
|
|
21
|
+
import { getDesignTokens } from './design';
|
|
22
|
+
import TopNav from './layouts/TopNav';
|
|
23
|
+
import BottomNav from './layouts/BottomNav';
|
|
24
|
+
|
|
25
|
+
export default function Layout() {
|
|
26
|
+
// ─── Read config and generate design tokens ───────────────────────────────
|
|
27
|
+
const tokens = getDesignTokens(config);
|
|
28
|
+
|
|
29
|
+
// ─── Apply CSS variables as inline styles on the root wrapper ─────────────
|
|
30
|
+
// Every child component can use: var(--color-primary), var(--radius), etc.
|
|
31
|
+
//
|
|
32
|
+
return (
|
|
33
|
+
<div style={tokens.cssVars}>
|
|
34
|
+
{/* Pick the right navigation layout based on config */}
|
|
35
|
+
{config.navigation === 'bottomnav' ? <BottomNav /> : <TopNav />}
|
|
36
|
+
</div>
|
|
37
|
+
);
|
|
38
|
+
}
|