-
Notifications
You must be signed in to change notification settings - Fork 21
feat(PM-1506): show already member modal #1165
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
| status: CopilotApplicationStatus, | ||
| opportunityStatus: string, | ||
| existingMembership?: ExistingMembership, | ||
| projectName: string, |
There was a problem hiding this comment.
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} |
There was a problem hiding this comment.
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} |
There was a problem hiding this comment.
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') |
There was a problem hiding this comment.
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') |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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>) => { |
There was a problem hiding this comment.
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, |
There was a problem hiding this comment.
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 }>() |
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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.
Related JIRA Ticket:
https://topcoder.atlassian.net/browse/PM-1506
What's in this PR?