Skip to content

Commit 49286f4

Browse files
committed
fix: review comments
1 parent 54fbb38 commit 49286f4

File tree

3 files changed

+28
-20
lines changed

3 files changed

+28
-20
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: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
/* eslint-disable react/jsx-no-bind */
2-
import { FC, useContext, useEffect, useMemo, useState } from 'react'
2+
import {
3+
FC,
4+
useCallback,
5+
useContext,
6+
useEffect,
7+
useMemo,
8+
useState,
9+
} from 'react'
310
import { useNavigate, useParams } from 'react-router-dom'
411
import { mutate } from 'swr'
512
import moment from 'moment'
@@ -53,6 +60,14 @@ const CopilotOpportunityDetails: FC<{}> = () => {
5360
return () => clearTimeout(timer) // Cleanup on unmount
5461
}, [opportunity])
5562

63+
const onApplied: () => void = useCallback(() => {
64+
mutate(`${copilotBaseUrl}/copilots/opportunity/${opportunityId}/applications`)
65+
}, [])
66+
67+
const onCloseApplyModal: () => void = useCallback(() => {
68+
setShowApplyOpportunityModal(false)
69+
}, [setShowApplyOpportunityModal])
70+
5671
if (!opportunity && showNotFound) {
5772
return (
5873
<ContentLayout title='Copilot Opportunity Details'>
@@ -67,14 +82,6 @@ const CopilotOpportunityDetails: FC<{}> = () => {
6782
onClick: () => setShowApplyOpportunityModal(true),
6883
}
6984

70-
const onApplied: () => void = () => {
71-
mutate(`${copilotBaseUrl}/copilots/opportunity/${opportunityId}/applications`)
72-
}
73-
74-
const onCloseApplyModal: () => void = () => {
75-
setShowApplyOpportunityModal(false)
76-
}
77-
7885
return (
7986
<ContentLayout
8087
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)