Skip to content

Commit 374040b

Browse files
authored
Merge pull request #1051 from topcoder-platform/PM-1064
PM-1064 Request Copilot button on opportunity feed
2 parents 9d945ef + a4457e3 commit 374040b

File tree

1 file changed

+15
-1
lines changed
  • src/apps/copilots/src/pages/copilot-opportunity-list

1 file changed

+15
-1
lines changed

src/apps/copilots/src/pages/copilot-opportunity-list/index.tsx

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
1-
import { FC, useMemo } from 'react'
1+
import { FC, useContext, useMemo } from 'react'
22
import { useNavigate } from 'react-router-dom'
33
import classNames from 'classnames'
44

55
import {
6+
ButtonProps,
67
ContentLayout,
78
LoadingSpinner,
89
PageTitle,
910
Table,
1011
TableColumn,
1112
} from '~/libs/ui'
13+
import { profileContext, ProfileContextData, UserRole } from '~/libs/core'
1214

1315
import { CopilotOpportunity } from '../../models/CopilotOpportunity'
1416
import { copilotRoutesMap } from '../../copilots.routes'
@@ -102,6 +104,12 @@ const tableColumns: TableColumn<CopilotOpportunity>[] = [
102104
const CopilotOpportunityList: FC<{}> = () => {
103105
const navigate = useNavigate()
104106

107+
const { profile }: ProfileContextData = useContext(profileContext)
108+
const isAdminOrPM: boolean = useMemo(
109+
() => !!profile?.roles?.some(role => role === UserRole.tcaAdmin || role === UserRole.projectManager),
110+
[profile],
111+
)
112+
105113
const {
106114
data: opportunities, isValidating, size, setSize,
107115
}: CopilotOpportunitiesResponse = useCopilotOpportunities()
@@ -121,9 +129,15 @@ const CopilotOpportunityList: FC<{}> = () => {
121129

122130
const opportunitiesLoading = isValidating
123131

132+
const addNewRequestButton: ButtonProps = {
133+
label: 'New Copilot Request',
134+
onClick: () => navigate(copilotRoutesMap.CopilotRequestForm),
135+
}
136+
124137
return (
125138
<ContentLayout
126139
title='Copilot Opportunities'
140+
buttonConfig={isAdminOrPM ? addNewRequestButton : undefined}
127141
>
128142
<PageTitle>Copilot Opportunities</PageTitle>
129143
<Table

0 commit comments

Comments
 (0)