-
Notifications
You must be signed in to change notification settings - Fork 13
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 { | ||
await applyCopilotOpportunity(props.copilotOpportunityId, { | ||
await applyCopilotOpportunity(props.copilotOpportunityId, notes ? { | ||
notes, | ||
}) | ||
} : undefined) | ||
|
||
props.onApplied() | ||
setSuccess(true) | ||
} catch (e) { | ||
setSuccess(true) | ||
} catch (e: any) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The |
||
setSuccess(false) | ||
setError(e.message) | ||
} | ||
}, [props.copilotOpportunityId, notes]) | ||
|
||
|
@@ -77,6 +79,8 @@ const ApplyOpportunityModal: FC<ApplyOpportunityModalProps> = props => { | |
name='Notes' | ||
onChange={onChange} | ||
value={notes} | ||
error={error} | ||
dirty={!!error} | ||
/> | ||
) | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,11 +18,13 @@ import { | |
ButtonProps, | ||
ContentLayout, | ||
IconOutline, | ||
IconSolid, | ||
LoadingSpinner, | ||
PageTitle, | ||
TabsNavbar, | ||
} from '~/libs/ui' | ||
import { profileContext, ProfileContextData, UserRole } from '~/libs/core' | ||
import { textFormatDateLocaleShortString } from '~/libs/shared' | ||
|
||
import { CopilotApplication } from '../../models/CopilotApplication' | ||
import { | ||
|
@@ -77,8 +79,12 @@ const CopilotOpportunityDetails: FC<{}> = () => { | |
const [activeTab, setActiveTab]: [string, Dispatch<SetStateAction<string>>] = useState<string>(activeTabHash) | ||
|
||
useEffect(() => { | ||
setActiveTab(activeTabHash) | ||
}, [activeTabHash]) | ||
if (isAdminOrPM) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Consider adding a default value for |
||
setActiveTab(activeTabHash) | ||
} else { | ||
setActiveTab('0') | ||
} | ||
}, [activeTabHash, isAdminOrPM]) | ||
|
||
const handleTabChange = useCallback((tabId: string): void => { | ||
setActiveTab(tabId) | ||
|
@@ -97,6 +103,7 @@ const CopilotOpportunityDetails: FC<{}> = () => { | |
|
||
const onApplied: () => void = useCallback(() => { | ||
mutate(`${copilotBaseUrl}/copilots/opportunity/${opportunityId}/applications`) | ||
mutate(`${copilotBaseUrl}/copilots/opportunity/${opportunityId}`) | ||
}, []) | ||
|
||
const onCloseApplyModal: () => void = useCallback(() => { | ||
|
@@ -117,16 +124,34 @@ const CopilotOpportunityDetails: FC<{}> = () => { | |
onClick: () => setShowApplyOpportunityModal(true), | ||
} | ||
|
||
const application = copilotApplications && copilotApplications[0] | ||
|
||
return ( | ||
<ContentLayout | ||
title='Copilot Opportunity' | ||
buttonConfig={ | ||
isCopilot | ||
&& copilotApplications | ||
&& copilotApplications.length === 0 ? applyCopilotOpportunityButton : undefined | ||
&& copilotApplications.length === 0 | ||
&& opportunity?.status === 'active' ? applyCopilotOpportunityButton : undefined | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Consider using a more descriptive variable name for |
||
} | ||
infoComponent={(isCopilot && !(copilotApplications | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The logic for |
||
&& copilotApplications.length === 0 | ||
&& opportunity?.status === 'active' | ||
) && !!application) && ( | ||
<div className={styles.applied}> | ||
<IconSolid.CheckCircleIcon className={styles.appliedIcon} /> | ||
<span | ||
className={styles.appliedText} | ||
> | ||
{`Applied on ${textFormatDateLocaleShortString(new Date(application.createdAt))}`} | ||
</span> | ||
</div> | ||
)} | ||
> | ||
<PageTitle>Copilot Opportunity</PageTitle> | ||
<PageTitle> | ||
Copilot Opportunity | ||
</PageTitle> | ||
{isValidating && !showNotFound && ( | ||
<LoadingSpinner /> | ||
) } | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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?: { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The |
||
notes?: string; | ||
}): Promise<CopilotApplication> => { | ||
const url = `${copilotBaseUrl}/copilots/opportunity/${opportunityId}/apply` | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -54,7 +54,6 @@ | |
|
||
.react-responsive-modal-closeButton { | ||
top: $sp-5; | ||
padding: $sp-1; | ||
border-radius: 50%; | ||
|
||
svg { | ||
|
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 adding a type for the
e
parameter in thecatch
block instead of usingany
. This will help with type safety and better error handling.