updates
This commit is contained in:
Binary file not shown.
@@ -122,6 +122,9 @@ const AccountantPaymentManagementPage = lazy(() => import('./pages/accountant/Pa
|
|||||||
const AccountantInvoiceManagementPage = lazy(() => import('./pages/accountant/InvoiceManagementPage'));
|
const AccountantInvoiceManagementPage = lazy(() => import('./pages/accountant/InvoiceManagementPage'));
|
||||||
const AccountantAnalyticsDashboardPage = lazy(() => import('./pages/accountant/AnalyticsDashboardPage'));
|
const AccountantAnalyticsDashboardPage = lazy(() => import('./pages/accountant/AnalyticsDashboardPage'));
|
||||||
const AccountantLayout = lazy(() => import('./pages/AccountantLayout'));
|
const AccountantLayout = lazy(() => import('./pages/AccountantLayout'));
|
||||||
|
const AdminProfilePage = lazy(() => import('./pages/admin/ProfilePage'));
|
||||||
|
const StaffProfilePage = lazy(() => import('./pages/staff/ProfilePage'));
|
||||||
|
const AccountantProfilePage = lazy(() => import('./pages/accountant/ProfilePage'));
|
||||||
|
|
||||||
const NotFoundPage = lazy(() => import('./shared/pages/NotFoundPage'));
|
const NotFoundPage = lazy(() => import('./shared/pages/NotFoundPage'));
|
||||||
|
|
||||||
@@ -604,6 +607,10 @@ function App() {
|
|||||||
path="backups"
|
path="backups"
|
||||||
element={<BackupManagementPage />}
|
element={<BackupManagementPage />}
|
||||||
/>
|
/>
|
||||||
|
<Route
|
||||||
|
path="profile"
|
||||||
|
element={<AdminProfilePage />}
|
||||||
|
/>
|
||||||
</Route>
|
</Route>
|
||||||
|
|
||||||
{}
|
{}
|
||||||
@@ -654,6 +661,10 @@ function App() {
|
|||||||
path="advanced-rooms"
|
path="advanced-rooms"
|
||||||
element={<StaffAdvancedRoomManagementPage />}
|
element={<StaffAdvancedRoomManagementPage />}
|
||||||
/>
|
/>
|
||||||
|
<Route
|
||||||
|
path="profile"
|
||||||
|
element={<StaffProfilePage />}
|
||||||
|
/>
|
||||||
</Route>
|
</Route>
|
||||||
|
|
||||||
{/* Accountant Routes */}
|
{/* Accountant Routes */}
|
||||||
@@ -692,6 +703,10 @@ function App() {
|
|||||||
path="reports"
|
path="reports"
|
||||||
element={<AccountantAnalyticsDashboardPage />}
|
element={<AccountantAnalyticsDashboardPage />}
|
||||||
/>
|
/>
|
||||||
|
<Route
|
||||||
|
path="profile"
|
||||||
|
element={<AccountantProfilePage />}
|
||||||
|
/>
|
||||||
</Route>
|
</Route>
|
||||||
|
|
||||||
{}
|
{}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import React, { useState, useEffect } from 'react';
|
|||||||
import { useForm } from 'react-hook-form';
|
import { useForm } from 'react-hook-form';
|
||||||
import { yupResolver } from '@hookform/resolvers/yup';
|
import { yupResolver } from '@hookform/resolvers/yup';
|
||||||
import { X, Eye, EyeOff, LogIn, Loader2, Mail, Lock, Shield, ArrowLeft } from 'lucide-react';
|
import { X, Eye, EyeOff, LogIn, Loader2, Mail, Lock, Shield, ArrowLeft } from 'lucide-react';
|
||||||
|
import { useNavigate } from 'react-router-dom';
|
||||||
import useAuthStore from '../../../store/useAuthStore';
|
import useAuthStore from '../../../store/useAuthStore';
|
||||||
import { loginSchema, LoginFormData } from '../../../shared/utils/validationSchemas';
|
import { loginSchema, LoginFormData } from '../../../shared/utils/validationSchemas';
|
||||||
import { useCompanySettings } from '../../../shared/contexts/CompanySettingsContext';
|
import { useCompanySettings } from '../../../shared/contexts/CompanySettingsContext';
|
||||||
@@ -26,8 +27,9 @@ type MFATokenFormData = yup.InferType<typeof mfaTokenSchema>;
|
|||||||
|
|
||||||
const LoginModal: React.FC = () => {
|
const LoginModal: React.FC = () => {
|
||||||
const { closeModal, openModal } = useAuthModal();
|
const { closeModal, openModal } = useAuthModal();
|
||||||
const { login, verifyMFA, isLoading, error, clearError, requiresMFA, clearMFA, isAuthenticated } = useAuthStore();
|
const { login, verifyMFA, isLoading, error, clearError, requiresMFA, clearMFA, isAuthenticated, userInfo } = useAuthStore();
|
||||||
const { settings } = useCompanySettings();
|
const { settings } = useCompanySettings();
|
||||||
|
const navigate = useNavigate();
|
||||||
|
|
||||||
const [showPassword, setShowPassword] = useState(false);
|
const [showPassword, setShowPassword] = useState(false);
|
||||||
|
|
||||||
@@ -61,12 +63,26 @@ const LoginModal: React.FC = () => {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
// Close modal on successful authentication
|
// Close modal and redirect to appropriate dashboard on successful authentication
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!isLoading && isAuthenticated && !requiresMFA) {
|
if (!isLoading && isAuthenticated && !requiresMFA && userInfo) {
|
||||||
closeModal();
|
closeModal();
|
||||||
|
|
||||||
|
// Redirect to role-specific dashboard
|
||||||
|
const role = userInfo.role?.toLowerCase() || (userInfo as any).role_name?.toLowerCase();
|
||||||
|
|
||||||
|
if (role === 'admin') {
|
||||||
|
navigate('/admin/dashboard', { replace: true });
|
||||||
|
} else if (role === 'staff') {
|
||||||
|
navigate('/staff/dashboard', { replace: true });
|
||||||
|
} else if (role === 'accountant') {
|
||||||
|
navigate('/accountant/dashboard', { replace: true });
|
||||||
|
} else {
|
||||||
|
// Customer or default - go to customer dashboard
|
||||||
|
navigate('/dashboard', { replace: true });
|
||||||
}
|
}
|
||||||
}, [isLoading, isAuthenticated, requiresMFA, closeModal]);
|
}
|
||||||
|
}, [isLoading, isAuthenticated, requiresMFA, userInfo, closeModal, navigate]);
|
||||||
|
|
||||||
const {
|
const {
|
||||||
register,
|
register,
|
||||||
|
|||||||
1489
Frontend/src/pages/accountant/ProfilePage.tsx
Normal file
1489
Frontend/src/pages/accountant/ProfilePage.tsx
Normal file
File diff suppressed because it is too large
Load Diff
1489
Frontend/src/pages/admin/ProfilePage.tsx
Normal file
1489
Frontend/src/pages/admin/ProfilePage.tsx
Normal file
File diff suppressed because it is too large
Load Diff
1489
Frontend/src/pages/staff/ProfilePage.tsx
Normal file
1489
Frontend/src/pages/staff/ProfilePage.tsx
Normal file
File diff suppressed because it is too large
Load Diff
@@ -9,7 +9,8 @@ import {
|
|||||||
Menu,
|
Menu,
|
||||||
X,
|
X,
|
||||||
CreditCard,
|
CreditCard,
|
||||||
Receipt
|
Receipt,
|
||||||
|
User
|
||||||
} from 'lucide-react';
|
} from 'lucide-react';
|
||||||
import useAuthStore from '../../store/useAuthStore';
|
import useAuthStore from '../../store/useAuthStore';
|
||||||
import { useResponsive } from '../../hooks';
|
import { useResponsive } from '../../hooks';
|
||||||
@@ -95,6 +96,11 @@ const SidebarAccountant: React.FC<SidebarAccountantProps> = ({
|
|||||||
icon: BarChart3,
|
icon: BarChart3,
|
||||||
label: 'Financial Reports'
|
label: 'Financial Reports'
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
path: '/accountant/profile',
|
||||||
|
icon: User,
|
||||||
|
label: 'My Profile'
|
||||||
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
const isActive = (path: string) => {
|
const isActive = (path: string) => {
|
||||||
|
|||||||
@@ -303,6 +303,11 @@ const SidebarAdmin: React.FC<SidebarAdminProps> = ({
|
|||||||
icon: HardDrive,
|
icon: HardDrive,
|
||||||
label: 'Backups'
|
label: 'Backups'
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
path: '/admin/profile',
|
||||||
|
icon: User,
|
||||||
|
label: 'My Profile'
|
||||||
|
},
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|||||||
@@ -127,6 +127,11 @@ const SidebarStaff: React.FC<SidebarStaffProps> = ({
|
|||||||
icon: BarChart3,
|
icon: BarChart3,
|
||||||
label: 'Reports'
|
label: 'Reports'
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
path: '/staff/profile',
|
||||||
|
icon: Users,
|
||||||
|
label: 'My Profile'
|
||||||
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
const isActive = (path: string) => {
|
const isActive = (path: string) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user