Skip to content

fix(PM-578): QA feedbacks on apply copilot opportunity functionality #1072

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

Merged
merged 2 commits into from
May 13, 2025

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


props.onApplied()
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.

@@ -17,17 +17,19 @@ interface ApplyOpportunityModalProps {
const ApplyOpportunityModal: FC<ApplyOpportunityModalProps> = props => {
const [notes, setNotes] = useState('')
const [success, setSuccess] = useState(false)
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.

@@ -77,8 +79,12 @@ const CopilotOpportunityDetails: FC<{}> = () => {
const [activeTab, setActiveTab]: [string, Dispatch<SetStateAction<string>>] = useState<string>(activeTabHash)

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.

return (
<ContentLayout
title='Copilot Opportunity'
buttonConfig={
isCopilot
&& 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.

}
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.

@@ -97,7 +97,7 @@ export const useCopilotOpportunity = (opportunityId?: string): CopilotOpportunit
* @param request
* @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.

2 participants