Files
worklenz/worklenz-frontend/src/hooks/useIsProjectManager.ts
chamikaJ 8825b0410a init
2025-04-17 18:28:54 +05:30

16 lines
790 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;