-
Notifications
You must be signed in to change notification settings - Fork 13
PM-1064 Request Copilot button on opportunity feed #1051
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,16 @@ | ||
import { FC, useMemo } from 'react' | ||
import { FC, useContext, useMemo } from 'react' | ||
import { useNavigate } from 'react-router-dom' | ||
import classNames from 'classnames' | ||
|
||
import { | ||
ButtonProps, | ||
ContentLayout, | ||
LoadingSpinner, | ||
PageTitle, | ||
Table, | ||
TableColumn, | ||
} from '~/libs/ui' | ||
import { profileContext, ProfileContextData, UserRole } from '~/libs/core' | ||
himaniraghav3 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
import { CopilotOpportunity } from '../../models/CopilotOpportunity' | ||
import { copilotRoutesMap } from '../../copilots.routes' | ||
|
@@ -88,6 +90,9 @@ const tableColumns: TableColumn<CopilotOpportunity>[] = [ | |
const CopilotOpportunityList: FC<{}> = () => { | ||
const navigate = useNavigate() | ||
|
||
const { profile }: ProfileContextData = useContext(profileContext) | ||
const isAdmin: boolean = useMemo(() => !!profile?.roles?.includes(UserRole.tcaAdmin), [profile]) | ||
himaniraghav3 marked this conversation as resolved.
Show resolved
Hide resolved
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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? |
||
|
||
const { | ||
data: opportunities, isValidating, size, setSize, | ||
}: CopilotOpportunitiesResponse = useCopilotOpportunities() | ||
|
@@ -107,9 +112,15 @@ const CopilotOpportunityList: FC<{}> = () => { | |
|
||
const opportunitiesLoading = isValidating | ||
|
||
const addNewRequestButton: ButtonProps = { | ||
label: 'New Copilot Request', | ||
onClick: () => navigate(copilotRoutesMap.CopilotRequestForm), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Consider adding error handling for the |
||
} | ||
|
||
return ( | ||
<ContentLayout | ||
title='Copilot Opportunities' | ||
buttonConfig={isAdmin ? addNewRequestButton : undefined} | ||
himaniraghav3 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
> | ||
<PageTitle>Copilot Opportunities</PageTitle> | ||
<Table | ||
|
Uh oh!
There was an error while loading. Please reload this page.