feat(project-view): implement finance tab visibility based on user permissions

- Added permission checks to conditionally display the finance tab in the project view based on user roles.
- Introduced `hasFinanceViewPermission` utility to determine access rights for the finance tab.
- Updated tab management logic to handle redirection and default tab selection when permissions change.
This commit is contained in:
chamikaJ
2025-06-06 09:10:50 +05:30
parent dcdb651dd1
commit 59880bfd59
2 changed files with 76 additions and 3 deletions

View File

@@ -27,6 +27,29 @@ export const hasFinanceEditPermission = (
return false;
};
/**
* Checks if the current user has permission to view finance data
* Only project managers, admins, and owners should be able to view the finance tab
*/
export const hasFinanceViewPermission = (
currentSession: ILocalSession | null,
currentProject?: IProjectViewModel | null
): boolean => {
if (!currentSession) return false;
// Team owner or admin always have permission
if (currentSession.owner || currentSession.is_admin) {
return true;
}
// Project manager has permission
if (currentProject?.project_manager?.id === currentSession.team_member_id) {
return true;
}
return false;
};
/**
* Checks if the current user can edit fixed costs
*/