@@ -65,6 +65,10 @@ const CopilotOpportunityDetails: FC<{}> = () => {
6565 [ profile ] ,
6666 )
6767 const { data : copilotApplications } : { data ?: CopilotApplication [ ] } = useCopilotApplications ( opportunityId )
68+ const appliedCopilotApplications = useMemo (
69+ ( ) => copilotApplications ?. filter ( item => item . userId === profile ?. userId ) ,
70+ [ copilotApplications , profile ] ,
71+ )
6872 const { data : members } : { data ?: FormattedMembers [ ] } = useMembers (
6973 copilotApplications ? copilotApplications ?. map ( item => item . userId ) : [ ] ,
7074 )
@@ -95,13 +99,16 @@ const CopilotOpportunityDetails: FC<{}> = () => {
9599 } , [ getHashFromTabId , setActiveTab ] )
96100
97101 useEffect ( ( ) => {
102+ if ( opportunity ) {
103+ setShowNotFound ( false )
104+ return undefined
105+ }
106+
98107 const timer = setTimeout ( ( ) => {
99- if ( ! opportunity ) {
100- setShowNotFound ( true )
101- }
102- } , 2000 )
108+ setShowNotFound ( true )
109+ } , 1000 )
103110
104- return ( ) => clearTimeout ( timer ) // Cleanup on unmount
111+ return ( ) => clearTimeout ( timer )
105112 } , [ opportunity ] )
106113
107114 const onApplied : ( ) => void = useCallback ( ( ) => {
@@ -113,6 +120,14 @@ const CopilotOpportunityDetails: FC<{}> = () => {
113120 setShowApplyOpportunityModal ( false )
114121 } , [ setShowApplyOpportunityModal ] )
115122
123+ if ( isValidating && ! opportunity ) {
124+ return (
125+ < ContentLayout title = 'Copilot Opportunity Details' >
126+ < LoadingSpinner />
127+ </ ContentLayout >
128+ )
129+ }
130+
116131 if ( ! opportunity && showNotFound ) {
117132 return (
118133 < ContentLayout title = 'Copilot Opportunity Details' >
@@ -164,17 +179,17 @@ const CopilotOpportunityDetails: FC<{}> = () => {
164179 title = 'Copilot Opportunity'
165180 buttonConfig = {
166181 isCopilot
167- && copilotApplications
168- && copilotApplications . length === 0
182+ && appliedCopilotApplications
183+ && appliedCopilotApplications . length === 0
169184 && opportunity ?. status === 'active'
170- && opportunity ?. canApplyAsCopilot ? applyCopilotOpportunityButton : undefined
185+ ? applyCopilotOpportunityButton : undefined
171186 }
172187 secondaryButtonConfig = {
173188 opportunity ?. status === 'active'
174189 && isAdminOrPM ? cancelCopilotOpportunityButton : undefined
175190 }
176- infoComponent = { ( isCopilot && ! ( copilotApplications
177- && copilotApplications . length === 0
191+ infoComponent = { ( isCopilot && ! ( appliedCopilotApplications
192+ && appliedCopilotApplications . length === 0
178193 ) && opportunity ?. status === 'active' && ! ! application ) && (
179194 < div className = { styles . applied } >
180195 < IconSolid . CheckCircleIcon className = { styles . appliedIcon } />
@@ -194,7 +209,7 @@ const CopilotOpportunityDetails: FC<{}> = () => {
194209 ) }
195210 < div className = { styles . wrapper } >
196211 < h1 className = { styles . header } >
197- { opportunity ?. projectName }
212+ { opportunity ?. opportunityTitle ?? opportunity ?. projectName }
198213 </ h1 >
199214 < div className = { styles . infoRow } >
200215 < div className = { styles . infoColumn } >
@@ -255,6 +270,16 @@ const CopilotOpportunityDetails: FC<{}> = () => {
255270 < span className = { styles . infoValue } > { opportunity ?. tzRestrictions } </ span >
256271 </ div >
257272 </ div >
273+ < div className = { styles . infoColumn } >
274+ < IconOutline . CashIcon className = { styles . icon } />
275+ < div className = { styles . infoText } >
276+ < span className = { styles . infoHeading } > Payment</ span >
277+ < span className = { styles . infoValue } >
278+ { opportunity ?. paymentType === 'standard'
279+ ? opportunity . paymentType : opportunity ?. otherPaymentType }
280+ </ span >
281+ </ div >
282+ </ div >
258283 </ div >
259284 {
260285 initialized && (
0 commit comments