@@ -12,9 +12,11 @@ import {
12
12
PageTitle ,
13
13
Table ,
14
14
TableColumn ,
15
+ Tooltip ,
15
16
useConfirmationModal ,
16
17
} from '~/libs/ui'
17
18
import { profileContext , ProfileContextData , UserRole } from '~/libs/core'
19
+ import { EnvironmentConfig } from '~/config'
18
20
19
21
import { ProjectTypeLabels } from '../../constants'
20
22
import { approveCopilotRequest , CopilotRequestsResponse , useCopilotRequests } from '../../services/copilot-requests'
@@ -56,13 +58,38 @@ const CopilotTableActions: FC<{request: CopilotRequest}> = props => {
56
58
navigate ( copilotRoutesMap . CopilotRequestDetails . replace ( ':requestId' , `${ props . request . id } ` ) )
57
59
} , [ navigate , props . request . id ] )
58
60
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
+
59
69
return (
60
70
< >
61
71
{ confirmModal . modal }
62
72
< div className = { styles . actionButtons } >
63
73
< 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 >
65
80
</ 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
+
66
93
{ props . request . status === 'new' && (
67
94
< >
68
95
< Button icon = { IconCheck } primary size = 'sm' onClick = { confirmApprove } />
@@ -81,43 +108,6 @@ const CopilotTableActions: FC<{request: CopilotRequest}> = props => {
81
108
)
82
109
}
83
110
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
-
121
111
const CopilotRequestsPage : FC = ( ) => {
122
112
const navigate : NavigateFunction = useNavigate ( )
123
113
const routeParams : Params < string > = useParams ( )
@@ -153,6 +143,64 @@ const CopilotRequestsPage: FC = () => {
153
143
Object . assign ( all , { [ c . id ] : c } )
154
144
) , { } as { [ key : string ] : Project } ) , [ projects ] )
155
145
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
+
156
204
const tableData = useMemo ( ( ) => requests . map ( request => ( {
157
205
...request ,
158
206
projectName : projectsMap [ request . projectId ] ?. name ,
0 commit comments