Skip to content

Commit ec0e17e

Browse files
authored
Merge branch 'pm-578' into pm-1067
2 parents 6acbb53 + 49286f4 commit ec0e17e

File tree

3 files changed

+30
-21
lines changed

3 files changed

+30
-21
lines changed

src/apps/copilots/src/pages/copilot-opportunity-details/apply-opportunity-modal/ApplyOpportunityModal.tsx

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,21 @@ const ApplyOpportunityModal: FC<ApplyOpportunityModalProps> = props => {
1919
const [success, setSuccess] = useState(false)
2020

2121
const onApply = useCallback(async () => {
22-
await applyCopilotOpportunity(props.copilotOpportunityId, {
23-
notes,
24-
})
22+
try {
23+
await applyCopilotOpportunity(props.copilotOpportunityId, {
24+
notes,
25+
})
2526

26-
props.onApplied()
27-
setSuccess(true)
27+
props.onApplied()
28+
setSuccess(true)
29+
} catch (e) {
30+
setSuccess(true)
31+
}
2832
}, [props.copilotOpportunityId, notes])
2933

30-
const onChange: (e: React.ChangeEvent<HTMLTextAreaElement>) => void = e => {
34+
const onChange: (e: React.ChangeEvent<HTMLTextAreaElement>) => void = useCallback(e => {
3135
setNotes(e.target.value)
32-
}
36+
}, [setNotes])
3337

3438
return (
3539
<BaseModal

src/apps/copilots/src/pages/copilot-opportunity-details/index.tsx

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
11
/* eslint-disable react/jsx-no-bind */
2-
/* eslint-disable complexity */
3-
import { Dispatch, FC, SetStateAction, useCallback, useContext, useEffect, useMemo, useState } from 'react'
2+
import {
3+
Dispatch,
4+
FC,
5+
SetStateAction,
6+
useCallback,
7+
useContext,
8+
useEffect,
9+
useMemo,
10+
useState,
11+
} from 'react'
412
import { useLocation, useNavigate, useParams } from 'react-router-dom'
513
import { mutate } from 'swr'
614
import moment from 'moment'
@@ -86,6 +94,14 @@ const CopilotOpportunityDetails: FC<{}> = () => {
8694
return () => clearTimeout(timer) // Cleanup on unmount
8795
}, [opportunity])
8896

97+
const onApplied: () => void = useCallback(() => {
98+
mutate(`${copilotBaseUrl}/copilots/opportunity/${opportunityId}/applications`)
99+
}, [])
100+
101+
const onCloseApplyModal: () => void = useCallback(() => {
102+
setShowApplyOpportunityModal(false)
103+
}, [setShowApplyOpportunityModal])
104+
89105
if (!opportunity && showNotFound) {
90106
return (
91107
<ContentLayout title='Copilot Opportunity Details'>
@@ -100,14 +116,6 @@ const CopilotOpportunityDetails: FC<{}> = () => {
100116
onClick: () => setShowApplyOpportunityModal(true),
101117
}
102118

103-
const onApplied: () => void = () => {
104-
mutate(`${copilotBaseUrl}/copilots/opportunity/${opportunityId}/applications`)
105-
}
106-
107-
const onCloseApplyModal: () => void = () => {
108-
setShowApplyOpportunityModal(false)
109-
}
110-
111119
return (
112120
<ContentLayout
113121
title='Copilot Opportunity'

src/apps/copilots/src/services/copilot-opportunities.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,5 @@ export const useCopilotApplications = (opportunityId?: string): CopilotApplicati
120120
.then(data => data)
121121
.catch(() => [])
122122

123-
return useSWR(url, fetcher, {
124-
refreshInterval: 0,
125-
revalidateOnFocus: false,
126-
})
123+
return useSWR(url, fetcher)
127124
}

0 commit comments

Comments
 (0)