@@ -12,9 +12,11 @@ import {
1212 PageTitle ,
1313 Table ,
1414 TableColumn ,
15+ Tooltip ,
1516 useConfirmationModal ,
1617} from '~/libs/ui'
1718import { profileContext , ProfileContextData , UserRole } from '~/libs/core'
19+ import { EnvironmentConfig } from '~/config'
1820
1921import { ProjectTypeLabels } from '../../constants'
2022import { approveCopilotRequest , CopilotRequestsResponse , useCopilotRequests } from '../../services/copilot-requests'
@@ -56,13 +58,38 @@ const CopilotTableActions: FC<{request: CopilotRequest}> = props => {
5658 navigate ( copilotRoutesMap . CopilotRequestDetails . replace ( ':requestId' , `${ props . request . id } ` ) )
5759 } , [ navigate , props . request . id ] )
5860
61+ const copilotOpportunityId = props . request . opportunity ?. id
62+
63+ const navigateToOpportunity = useCallback ( ( ) => {
64+ const url = copilotRoutesMap . CopilotOpportunityDetails
65+ . replace ( ':opportunityId' , `${ copilotOpportunityId } ` )
66+ window . open ( url , '_blank' , 'noopener,noreferrer' )
67+ } , [ copilotOpportunityId ] )
68+
5969 return (
6070 < >
6171 { confirmModal . modal }
6272 < div className = { styles . actionButtons } >
6373 < div className = { styles . viewRequestIcon } onClick = { viewRequest } >
64- < IconSolid . EyeIcon className = 'icon-lg' />
74+ < Tooltip
75+ content = 'View Copilot Request'
76+ place = 'top'
77+ >
78+ < IconSolid . EyeIcon className = 'icon-lg' />
79+ </ Tooltip >
6580 </ div >
81+ { props . request . status === 'approved'
82+ && (
83+ < div className = { styles . viewRequestIcon } onClick = { navigateToOpportunity } >
84+ < Tooltip
85+ content = 'View Copilot Opportunity'
86+ place = 'top'
87+ >
88+ < IconSolid . ExternalLinkIcon className = 'icon-lg' />
89+ </ Tooltip >
90+ </ div >
91+ ) }
92+
6693 { props . request . status === 'new' && (
6794 < >
6895 < Button icon = { IconCheck } primary size = 'sm' onClick = { confirmApprove } />
@@ -81,43 +108,6 @@ const CopilotTableActions: FC<{request: CopilotRequest}> = props => {
81108 )
82109}
83110
84- const tableColumns : TableColumn < CopilotRequest > [ ] = [
85- {
86- label : 'Project' ,
87- propertyName : 'projectName' ,
88- type : 'text' ,
89- } ,
90- {
91- label : 'Type' ,
92- propertyName : 'type' ,
93- type : 'text' ,
94- } ,
95- {
96- label : 'Status' ,
97- propertyName : 'status' ,
98- type : 'text' ,
99- } ,
100- {
101- label : '' ,
102- propertyName : '' ,
103- type : 'text' ,
104- } ,
105- {
106- defaultSortDirection : 'desc' ,
107- isDefaultSort : true ,
108- label : 'Created At' ,
109- propertyName : 'createdAt' ,
110- type : 'date' ,
111- } ,
112- {
113- label : '' ,
114- renderer : ( request : CopilotRequest ) => (
115- < CopilotTableActions request = { request } />
116- ) ,
117- type : 'action' ,
118- } ,
119- ]
120-
121111const CopilotRequestsPage : FC = ( ) => {
122112 const navigate : NavigateFunction = useNavigate ( )
123113 const routeParams : Params < string > = useParams ( )
@@ -153,6 +143,64 @@ const CopilotRequestsPage: FC = () => {
153143 Object . assign ( all , { [ c . id ] : c } )
154144 ) , { } as { [ key : string ] : Project } ) , [ projects ] )
155145
146+ const handleLinkClick = useCallback ( ( e : React . MouseEvent < HTMLAnchorElement > ) => {
147+ e . stopPropagation ( )
148+ } , [ ] )
149+
150+ const tableColumns : TableColumn < CopilotRequest > [ ] = [
151+ {
152+ label : 'Project' ,
153+ propertyName : 'projectName' ,
154+ renderer : ( copilotRequest : CopilotRequest ) => {
155+ const projectName = projectsMap [ copilotRequest . projectId ] ?. name
156+ const projectLink = `
157+ ${ EnvironmentConfig . ADMIN . WORK_MANAGER_URL } /projects/${ copilotRequest . projectId } /challenges
158+ `
159+ return (
160+ < a
161+ href = { projectLink }
162+ className = { styles . title }
163+ target = '_blank'
164+ rel = 'noreferrer'
165+ onClick = { handleLinkClick }
166+ >
167+ { projectName }
168+ </ a >
169+ )
170+ } ,
171+ type : 'element' ,
172+ } ,
173+ {
174+ label : 'Type' ,
175+ propertyName : 'type' ,
176+ type : 'text' ,
177+ } ,
178+ {
179+ label : 'Status' ,
180+ propertyName : 'status' ,
181+ type : 'text' ,
182+ } ,
183+ {
184+ label : '' ,
185+ propertyName : '' ,
186+ type : 'text' ,
187+ } ,
188+ {
189+ defaultSortDirection : 'desc' ,
190+ isDefaultSort : true ,
191+ label : 'Created At' ,
192+ propertyName : 'createdAt' ,
193+ type : 'date' ,
194+ } ,
195+ {
196+ label : '' ,
197+ renderer : ( request : CopilotRequest ) => (
198+ < CopilotTableActions request = { request } />
199+ ) ,
200+ type : 'action' ,
201+ } ,
202+ ]
203+
156204 const tableData = useMemo ( ( ) => requests . map ( request => ( {
157205 ...request ,
158206 projectName : projectsMap [ request . projectId ] ?. name ,
0 commit comments