Skip to content

Conversation

@hentrymartin
Copy link
Collaborator

Related JIRA Ticket:

https://topcoder.atlassian.net/browse/PM-1506

What's in this PR?

  • show already member modal

status: CopilotApplicationStatus,
opportunityStatus: string,
existingMembership?: ExistingMembership,
projectName: string,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The projectName property is added as a required field. If this is intentional, ensure that all instances of CopilotApplication are updated to include this field. If it should be optional, consider adding a question mark to make it projectName?: string.


const AlreadyMemberModal: FC<AlreadyMemberModalProps> = props => (
<BaseModal
onClose={props.onClose as () => void}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The onClose prop is being cast to () => void, which might lead to runtime errors if the function signature does not match. Consider ensuring that the function signature is compatible with BaseModal's expected type.

>
<div className={styles.applyCopilotModal}>
<div className={styles.info}>
{`The copilot ${props.handle} is part of ${props.projectName}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider using template literals for better readability and to avoid unnecessary whitespace in the rendered string. For example: The copilot ${props.handle} is part of ${props.projectName} project with ${props.copilotApplication.existingMembership?.role} role.

copilotApplication: CopilotApplication,
allCopilotApplications: CopilotApplication[],
): JSX.Element => {
console.log(copilotApplication, 'copilotApplication')

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Avoid using console.log statements in production code as it can lead to performance issues and clutter the console output. Consider using a proper logging mechanism if necessary.

}

if (copilotApplication.existingMembership) {
console.log('comes here')

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove console.log statement to avoid unnecessary logging in production code.

await assignCopilotOpportunity(opportunityId, copilotApplication.id)
toast.success('Accepted as copilot')
mutate(`${copilotBaseUrl}/copilots/opportunity/${opportunityId}/applications`)
setShowAlreadyMemberModal(false)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider checking if setShowAlreadyMemberModal is necessary here, as it is also called in the catch block. If the modal should always be closed regardless of success or failure, it might be more efficient to call it once after the try-catch block.

}
}, [opportunityId, copilotApplication])

const onCloseModal = useCallback((e: React.MouseEvent<HTMLButtonElement, MouseEvent>) => {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The useCallback dependency array includes showAlreadyMemberModal, but this state is not used within the callback function. Consider removing it from the dependency array to avoid unnecessary re-creations of the callback.

handle: member?.handle,
opportunityStatus: props.opportunity.status,
pastProjects: member?.pastProjects || 0,
projectName: props.opportunity.projectName,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ensure that props.opportunity.projectName is not undefined or null before assigning it to projectName. Consider using optional chaining or a default value to handle potential undefined values.

copilotApplication: CopilotApplication,
allCopilotApplications: CopilotApplication[],
): JSX.Element => {
const { opportunityId }: {opportunityId?: string} = useParams<{ opportunityId?: string }>()

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove the console.log statement if it is not needed for debugging purposes. Leaving console.log statements in production code can lead to performance issues and clutter the console output.

return
}

if (copilotApplication.existingMembership) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove the commented-out console.log('comes here') statement to keep the code clean and maintainable.

@hentrymartin hentrymartin merged commit 82920dc into dev Jul 30, 2025
4 checks passed
@hentrymartin hentrymartin deleted the pm-1506_1 branch July 30, 2025 20:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants