-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Track 210 - Update editing permissions for Issues and Status tabs. (#…
- Loading branch information
1 parent
a65ebac
commit f24c354
Showing
8 changed files
with
61 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { ROLES } from "../../constants/application-constant"; | ||
import { useContext } from "react"; | ||
import { useAppSelector } from "hooks"; | ||
import { WorkplanContext } from "./WorkPlanContext"; | ||
|
||
// Get the active team members | ||
export const useActiveTeam = () => { | ||
const { team } = useContext(WorkplanContext); | ||
return team?.filter((member) => member.is_active) || []; | ||
}; | ||
|
||
// Check if the current user is a team member | ||
export const useIsTeamMember = () => { | ||
const { team } = useContext(WorkplanContext); | ||
const { email } = useAppSelector((state) => state.user.userDetail); | ||
return team?.some((member) => member.staff.email === email) || false; | ||
}; | ||
|
||
// Check if the current user has a specific role in the active team | ||
export const useUserHasRole = () => { | ||
const activeTeam = useActiveTeam(); | ||
const { email } = useAppSelector((state) => state.user.userDetail); | ||
const rolesArray = [ | ||
ROLES.RESPONSIBLE_EPD, | ||
ROLES.TEAM_LEAD, | ||
ROLES.TEAM_CO_LEAD, | ||
]; | ||
return activeTeam.some( | ||
(member) => | ||
member.staff.email === email && rolesArray.includes(member.role.name) | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters