Skip to content

Commit 2ead2c1

Browse files
authored
Merge pull request #1145 from topcoder-platform/pm-1395
fix(PM-1395): Show apply as copilot button for a user who is both admin and copilot
2 parents 4519c74 + b9353f0 commit 2ead2c1

File tree

1 file changed

+8
-4
lines changed
  • src/apps/copilots/src/pages/copilot-opportunity-details

1 file changed

+8
-4
lines changed

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

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -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
)
@@ -164,17 +168,17 @@ const CopilotOpportunityDetails: FC<{}> = () => {
164168
title='Copilot Opportunity'
165169
buttonConfig={
166170
isCopilot
167-
&& copilotApplications
168-
&& copilotApplications.length === 0
171+
&& appliedCopilotApplications
172+
&& appliedCopilotApplications.length === 0
169173
&& opportunity?.status === 'active'
170174
&& opportunity?.canApplyAsCopilot ? applyCopilotOpportunityButton : undefined
171175
}
172176
secondaryButtonConfig={
173177
opportunity?.status === 'active'
174178
&& isAdminOrPM ? cancelCopilotOpportunityButton : undefined
175179
}
176-
infoComponent={(isCopilot && !(copilotApplications
177-
&& copilotApplications.length === 0
180+
infoComponent={(isCopilot && !(appliedCopilotApplications
181+
&& appliedCopilotApplications.length === 0
178182
) && opportunity?.status === 'active' && !!application) && (
179183
<div className={styles.applied}>
180184
<IconSolid.CheckCircleIcon className={styles.appliedIcon} />

0 commit comments

Comments
 (0)