feat: implement super_admin role, add swap station user, and update login routing logic
This commit is contained in:
@@ -6,11 +6,12 @@ import { users } from '@/data/mockData';
|
|||||||
import { Zap, ArrowRight, Bike, Wallet, Shield, Users, Calculator, Store, Truck } from 'lucide-react';
|
import { Zap, ArrowRight, Bike, Wallet, Shield, Users, Calculator, Store, Truck } from 'lucide-react';
|
||||||
|
|
||||||
const demoUsers = [
|
const demoUsers = [
|
||||||
{ email: 'superadmin@jaiben.com', role: 'admin', label: 'Super Admin', icon: Shield, color: 'bg-accent' },
|
{ email: 'superadmin@jaiben.com', role: 'super_admin', label: 'Super Admin', icon: Shield, color: 'bg-accent' },
|
||||||
{ email: 'admin@jaiben.com', role: 'manager', label: 'Admin Manager', icon: Users, color: 'bg-blue-500' },
|
{ email: 'admin@jaiben.com', role: 'admin', label: 'Admin Manager', icon: Users, color: 'bg-blue-500' },
|
||||||
{ email: 'staff@jaiben.com', role: 'staff', label: 'Front Desk', icon: Users, color: 'bg-purple-500' },
|
{ email: 'staff@jaiben.com', role: 'staff', label: 'Front Desk', icon: Users, color: 'bg-purple-500' },
|
||||||
{ email: 'accountant@jaiben.com', role: 'accountant', label: 'Accountant', icon: Calculator, color: 'bg-green-500' },
|
{ email: 'accountant@jaiben.com', role: 'accountant', label: 'Accountant', icon: Calculator, color: 'bg-green-500' },
|
||||||
{ email: 'investor@email.com', role: 'investor', label: 'Investor', icon: Wallet, color: 'bg-amber-500' },
|
{ email: 'investor@email.com', role: 'investor', label: 'Investor', icon: Wallet, color: 'bg-amber-500' },
|
||||||
|
{ email: 'swap@jaiben.com', role: 'swap-station', label: 'Swap Station', icon: Zap, color: 'bg-purple-500' },
|
||||||
];
|
];
|
||||||
|
|
||||||
export default function LoginPage() {
|
export default function LoginPage() {
|
||||||
@@ -35,13 +36,14 @@ export default function LoginPage() {
|
|||||||
sessionStorage.setItem('userName', user.name);
|
sessionStorage.setItem('userName', user.name);
|
||||||
|
|
||||||
switch (user.role) {
|
switch (user.role) {
|
||||||
|
case 'super_admin':
|
||||||
case 'admin':
|
case 'admin':
|
||||||
case 'manager':
|
case 'manager':
|
||||||
case 'staff':
|
case 'staff':
|
||||||
router.push('/admin');
|
router.push('/admin');
|
||||||
break;
|
break;
|
||||||
case 'accountant':
|
case 'accountant':
|
||||||
router.push('/admin');
|
router.push('/admin/accounting');
|
||||||
break;
|
break;
|
||||||
case 'investor':
|
case 'investor':
|
||||||
router.push('/investor');
|
router.push('/investor');
|
||||||
@@ -56,7 +58,7 @@ export default function LoginPage() {
|
|||||||
router.push('/merchant');
|
router.push('/merchant');
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
router.push('/');
|
router.push('/login');
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
setError('Invalid email or password. Try demo123');
|
setError('Invalid email or password. Try demo123');
|
||||||
@@ -76,13 +78,14 @@ export default function LoginPage() {
|
|||||||
sessionStorage.setItem('userName', user.name);
|
sessionStorage.setItem('userName', user.name);
|
||||||
|
|
||||||
switch (user.role) {
|
switch (user.role) {
|
||||||
|
case 'super_admin':
|
||||||
case 'admin':
|
case 'admin':
|
||||||
case 'manager':
|
case 'manager':
|
||||||
case 'staff':
|
case 'staff':
|
||||||
router.push('/admin');
|
router.push('/admin');
|
||||||
break;
|
break;
|
||||||
case 'accountant':
|
case 'accountant':
|
||||||
router.push('/admin');
|
router.push('/admin/accounting');
|
||||||
break;
|
break;
|
||||||
case 'investor':
|
case 'investor':
|
||||||
router.push('/investor');
|
router.push('/investor');
|
||||||
@@ -140,7 +143,7 @@ export default function LoginPage() {
|
|||||||
|
|
||||||
<div>
|
<div>
|
||||||
<label htmlFor="password" className="block text-sm font-medium text-slate-300 mb-2">
|
<label htmlFor="password" className="block text-sm font-medium text-slate-300 mb-2">
|
||||||
Password
|
Password <span className="text-slate-500 text-xs">(demo: demo123)</span>
|
||||||
</label>
|
</label>
|
||||||
<input
|
<input
|
||||||
type="password"
|
type="password"
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ export interface User {
|
|||||||
name: string;
|
name: string;
|
||||||
email: string;
|
email: string;
|
||||||
phone: string;
|
phone: string;
|
||||||
role: 'biker' | 'admin' | 'manager' | 'staff' | 'accountant' | 'investor' | 'swap-station' | 'merchant';
|
role: 'biker' | 'super_admin' | 'admin_manager' | 'staff' | 'accountant' | 'investor' | 'swap-station' | 'merchant';
|
||||||
avatar?: string;
|
avatar?: string;
|
||||||
status: 'active' | 'pending' | 'inactive';
|
status: 'active' | 'pending' | 'inactive';
|
||||||
createdAt: string;
|
createdAt: string;
|
||||||
@@ -157,6 +157,7 @@ export interface Delivery {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const users: User[] = [
|
export const users: User[] = [
|
||||||
|
{ id: 'u0', name: 'Super Admin', email: 'superadmin@jaiben.com', phone: '01710000000', role: 'super_admin', status: 'active', createdAt: '2023-01-01' },
|
||||||
{ id: 'u1', name: 'Rahim Ahmed', email: 'rahim@email.com', phone: '01712345678', role: 'biker', status: 'active', createdAt: '2024-01-15' },
|
{ id: 'u1', name: 'Rahim Ahmed', email: 'rahim@email.com', phone: '01712345678', role: 'biker', status: 'active', createdAt: '2024-01-15' },
|
||||||
{ id: 'u2', name: 'Karim Hasan', email: 'karim@email.com', phone: '01712345679', role: 'biker', status: 'active', createdAt: '2024-02-20' },
|
{ id: 'u2', name: 'Karim Hasan', email: 'karim@email.com', phone: '01712345679', role: 'biker', status: 'active', createdAt: '2024-02-20' },
|
||||||
{ id: 'u3', name: 'Admin User', email: 'admin@jaiben.com', phone: '01710000001', role: 'admin', status: 'active', createdAt: '2023-06-01' },
|
{ id: 'u3', name: 'Admin User', email: 'admin@jaiben.com', phone: '01710000001', role: 'admin', status: 'active', createdAt: '2023-06-01' },
|
||||||
|
|||||||
Reference in New Issue
Block a user