@@ -18,11 +18,13 @@ import {
18
18
ButtonProps ,
19
19
ContentLayout ,
20
20
IconOutline ,
21
+ IconSolid ,
21
22
LoadingSpinner ,
22
23
PageTitle ,
23
24
TabsNavbar ,
24
25
} from '~/libs/ui'
25
26
import { profileContext , ProfileContextData , UserRole } from '~/libs/core'
27
+ import { textFormatDateLocaleShortString } from '~/libs/shared'
26
28
27
29
import { CopilotApplication } from '../../models/CopilotApplication'
28
30
import {
@@ -77,8 +79,12 @@ const CopilotOpportunityDetails: FC<{}> = () => {
77
79
const [ activeTab , setActiveTab ] : [ string , Dispatch < SetStateAction < string > > ] = useState < string > ( activeTabHash )
78
80
79
81
useEffect ( ( ) => {
80
- setActiveTab ( activeTabHash )
81
- } , [ activeTabHash ] )
82
+ if ( isAdminOrPM ) {
83
+ setActiveTab ( activeTabHash )
84
+ } else {
85
+ setActiveTab ( '0' )
86
+ }
87
+ } , [ activeTabHash , isAdminOrPM ] )
82
88
83
89
const handleTabChange = useCallback ( ( tabId : string ) : void => {
84
90
setActiveTab ( tabId )
@@ -97,6 +103,7 @@ const CopilotOpportunityDetails: FC<{}> = () => {
97
103
98
104
const onApplied : ( ) => void = useCallback ( ( ) => {
99
105
mutate ( `${ copilotBaseUrl } /copilots/opportunity/${ opportunityId } /applications` )
106
+ mutate ( `${ copilotBaseUrl } /copilots/opportunity/${ opportunityId } ` )
100
107
} , [ ] )
101
108
102
109
const onCloseApplyModal : ( ) => void = useCallback ( ( ) => {
@@ -117,16 +124,34 @@ const CopilotOpportunityDetails: FC<{}> = () => {
117
124
onClick : ( ) => setShowApplyOpportunityModal ( true ) ,
118
125
}
119
126
127
+ const application = copilotApplications && copilotApplications [ 0 ]
128
+
120
129
return (
121
130
< ContentLayout
122
131
title = 'Copilot Opportunity'
123
132
buttonConfig = {
124
133
isCopilot
125
134
&& copilotApplications
126
- && copilotApplications . length === 0 ? applyCopilotOpportunityButton : undefined
135
+ && copilotApplications . length === 0
136
+ && opportunity ?. status === 'active' ? applyCopilotOpportunityButton : undefined
127
137
}
138
+ infoComponent = { ( isCopilot && ! ( copilotApplications
139
+ && copilotApplications . length === 0
140
+ && opportunity ?. status === 'active'
141
+ ) && ! ! application ) && (
142
+ < div className = { styles . applied } >
143
+ < IconSolid . CheckCircleIcon className = { styles . appliedIcon } />
144
+ < span
145
+ className = { styles . appliedText }
146
+ >
147
+ { `Applied on ${ textFormatDateLocaleShortString ( new Date ( application . createdAt ) ) } ` }
148
+ </ span >
149
+ </ div >
150
+ ) }
128
151
>
129
- < PageTitle > Copilot Opportunity</ PageTitle >
152
+ < PageTitle >
153
+ Copilot Opportunity
154
+ </ PageTitle >
130
155
{ isValidating && ! showNotFound && (
131
156
< LoadingSpinner />
132
157
) }
0 commit comments