Files
worklenz/worklenz-frontend/src/hooks/useIsProjectManager.ts
2025-07-03 01:31:05 +05:30

19 lines
797 B
TypeScript

import { useAuthService } from '@/hooks/useAuth';
import { useAppSelector } from '@/hooks/useAppSelector';
const useIsProjectManager = () => {
const currentSession = useAuthService().getCurrentSession();
const { project: currentProject } = useAppSelector(state => state.projectReducer);
const { project: drawerProject } = useAppSelector(state => state.projectDrawerReducer);
// Check if user is project manager for either the current project or drawer project
const isManagerOfCurrentProject =
currentSession?.team_member_id === currentProject?.project_manager?.id;
const isManagerOfDrawerProject =
currentSession?.team_member_id === drawerProject?.project_manager?.id;
return isManagerOfCurrentProject || isManagerOfDrawerProject;
};
export default useIsProjectManager;