Skip to content

Conversation

@himaniraghav3
Copy link
Collaborator

Related JIRA Ticket:

https://topcoder.atlassian.net/browse/PM-1064

What's in this PR?

Admin can see a "New Copilot Request" button on the opportunity listing page which takes them to the form.


const addNewRequestButton: ButtonProps = {
label: 'New Copilot Request',
onClick: () => navigate(copilotRoutesMap.CopilotRequestForm),

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider adding error handling for the navigate function to handle cases where the navigation might fail.

const navigate = useNavigate()

const { profile }: ProfileContextData = useContext(profileContext)
const isAdmin: boolean = useMemo(() => !!profile?.roles?.includes(UserRole.tcaAdmin), [profile])
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@himaniraghav3 can we please extend this to PM role to ensure PMs can use the functionality as well?

@himaniraghav3 himaniraghav3 requested a review from kkartunov April 28, 2025 10:13

const { profile }: ProfileContextData = useContext(profileContext)
const isAdminOrPM: boolean = useMemo(
() => !!profile?.roles?.some(role => role === UserRole.tcaAdmin || role === UserRole.projectManager),

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider using includes instead of some for checking roles if the list of roles is small and fixed, as it can be more readable and straightforward.

@kkartunov kkartunov merged commit 374040b into dev Apr 29, 2025
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants