Skip to content

Conversation

@hentrymartin
Copy link
Collaborator

Related JIRA Ticket:

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

What's in this PR?

  • Fixed QA feedbacks on apply copilot opportunity functionality

setSuccess(true)
} catch (e) {
setSuccess(true)
} catch (e: any) {

Choose a reason for hiding this comment

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

The setSuccess(true) call in the catch block seems incorrect. It should likely be setSuccess(false) to indicate the application was not successful due to an error.

const [error, setError] = useState('')

const onApply = useCallback(async () => {
try {

Choose a reason for hiding this comment

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

Consider adding a type for the e parameter in the catch block instead of using any. This will help with type safety and better error handling.

useEffect(() => {
setActiveTab(activeTabHash)
}, [activeTabHash])
if (isAdminOrPM) {

Choose a reason for hiding this comment

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

Consider adding a default value for isAdminOrPM to ensure it is defined before use. This will prevent potential runtime errors if isAdminOrPM is undefined.

&& copilotApplications
&& copilotApplications.length === 0 ? applyCopilotOpportunityButton : undefined
&& copilotApplications.length === 0
&& opportunity?.status === 'active' ? applyCopilotOpportunityButton : undefined

Choose a reason for hiding this comment

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

Consider using a more descriptive variable name for application to improve readability, especially since it represents the first element of copilotApplications. This will make the code easier to understand for other developers.

&& copilotApplications.length === 0
&& opportunity?.status === 'active' ? applyCopilotOpportunityButton : undefined
}
infoComponent={(isCopilot && !(copilotApplications

Choose a reason for hiding this comment

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

The logic for infoComponent is complex and could benefit from being extracted into a separate function or component for better readability and maintainability. This would also help in isolating the logic for easier testing.

* @returns
*/
export const applyCopilotOpportunity = async (opportunityId: number, request: {
export const applyCopilotOpportunity = async (opportunityId: number, request?: {

Choose a reason for hiding this comment

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

The request parameter is now optional, but the function implementation should handle the case where request is undefined. Ensure that the code inside the function checks for request being undefined before accessing its properties.

Copy link
Collaborator

@kkartunov kkartunov left a comment

Choose a reason for hiding this comment

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

Looks good.

@hentrymartin hentrymartin merged commit b5bc422 into dev May 13, 2025
3 checks passed
@hentrymartin hentrymartin deleted the pm-578_1 branch May 13, 2025 21:26
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.

3 participants