Skip to content

Commit 63d486a

Browse files
committed
fix: lint
1 parent 3692ce4 commit 63d486a

File tree

4 files changed

+69
-24
lines changed

4 files changed

+69
-24
lines changed

src/apps/copilots/src/models/CopilotApplication.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ export interface CopilotApplication {
33
notes?: string,
44
createdAt: Date,
55
opportunityId: string,
6-
}
6+
}

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

Lines changed: 29 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@ import { FC, useCallback, useState } from 'react'
22

33
import { BaseModal, Button, InputTextarea } from '~/libs/ui'
44

5-
import styles from './styles.module.scss'
65
import { applyCopilotOpportunity } from '../../../services/copilot-opportunities'
76

7+
import styles from './styles.module.scss'
8+
89
interface ApplyOpportunityModalProps {
910
onClose: () => void
1011
copilotOpportunityId: number
@@ -14,7 +15,7 @@ interface ApplyOpportunityModalProps {
1415

1516
const ApplyOpportunityModal: FC<ApplyOpportunityModalProps> = props => {
1617
const [notes, setNotes] = useState('')
17-
const [success, setSuccess] = useState(false);
18+
const [success, setSuccess] = useState(false)
1819

1920
const onApply = useCallback(async () => {
2021
await applyCopilotOpportunity(props.copilotOpportunityId, {
@@ -25,12 +26,20 @@ const ApplyOpportunityModal: FC<ApplyOpportunityModalProps> = props => {
2526
setSuccess(true)
2627
}, [props.copilotOpportunityId, notes])
2728

29+
const onChange = (e: React.ChangeEvent<HTMLTextAreaElement>) => {
30+
setNotes(e.target.value)
31+
}
32+
2833
return (
2934
<BaseModal
3035
onClose={props.onClose}
3136
open
3237
size='lg'
33-
title={success ? `Your Application for ${props.projectName} Has Been Received!` : `Confirm Your Copilot Application for ${props.projectName}`}
38+
title={
39+
success
40+
? `Your Application for ${props.projectName} Has Been Received!`
41+
: `Confirm Your Copilot Application for ${props.projectName}`
42+
}
3443
buttons={
3544
!success ? (
3645
<>
@@ -42,17 +51,28 @@ const ApplyOpportunityModal: FC<ApplyOpportunityModalProps> = props => {
4251
)
4352
}
4453
>
45-
4654
<div className={styles.applyCopilotModal}>
4755
<div className={styles.info}>
48-
{success ?
49-
"We appreciate the time and effort you've taken to apply for this exciting opportunity. Our team is committed to providing a seamless and efficient process to ensure a great experience for all copilots. We will review your application within short time." : `We're excited to see your interest in joining our team as a copilot for the ${props.projectName} project! Before we proceed, we want to ensure that you have carefully reviewed the project requirements and are committed to meeting them.`}
56+
{
57+
success
58+
? `We appreciate the time and effort you've taken to apply
59+
for this exciting opportunity. Our team is committed
60+
to providing a seamless and efficient process to ensure a
61+
great experience for all copilots. We will review your application
62+
within short time.`
63+
: `We're excited to see your interest in joining our team as a copilot
64+
for the ${props.projectName} project! Before we proceed, we want to
65+
ensure that you have carefully reviewed the project requirements and
66+
are committed to meeting them.`
67+
}
5068
</div>
5169
{
5270
!success && (
53-
<InputTextarea name="Notes" onChange={(e) => {
54-
setNotes(e.target.value)
55-
}} value={notes} />
71+
<InputTextarea
72+
name='Notes'
73+
onChange={onChange}
74+
value={notes}
75+
/>
5676
)
5777
}
5878
</div>

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

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { FC, useContext, useEffect, useMemo, useState } from 'react'
22
import { useNavigate, useParams } from 'react-router-dom'
3-
import moment from 'moment'
43
import { mutate } from 'swr'
4+
import moment from 'moment'
55

66
import {
77
ButtonProps,
@@ -12,11 +12,16 @@ import {
1212
} from '~/libs/ui'
1313
import { profileContext, ProfileContextData, UserRole } from '~/libs/core'
1414

15-
import { copilotBaseUrl, CopilotOpportunityResponse, useCopilotApplications, useCopilotOpportunity } from '../../services/copilot-opportunities'
15+
import {
16+
copilotBaseUrl,
17+
CopilotOpportunityResponse,
18+
useCopilotApplications,
19+
useCopilotOpportunity,
20+
} from '../../services/copilot-opportunities'
1621
import { copilotRoutesMap } from '../../copilots.routes'
22+
import { ApplyOpportunityModal } from './apply-opportunity-modal'
1723

1824
import styles from './styles.module.scss'
19-
import { ApplyOpportunityModal } from './apply-opportunity-modal'
2025

2126
const CopilotOpportunityDetails: FC<{}> = () => {
2227
const { opportunityId }: {opportunityId?: string} = useParams<{ opportunityId?: string }>()
@@ -60,12 +65,23 @@ const CopilotOpportunityDetails: FC<{}> = () => {
6065
onClick: () => setShowApplyOpportunityModal(true),
6166
}
6267

63-
const onApplied = () => {
68+
const onApplied: () => void = () => {
6469
mutate(`${copilotBaseUrl}/copilots/opportunity/${opportunityId}/applications`)
6570
}
6671

72+
const onCloseApplyModal: () => void = () => {
73+
setShowApplyOpportunityModal(false)
74+
}
75+
6776
return (
68-
<ContentLayout title='Copilot Opportunity' buttonConfig={isCopilot && copilotApplications && copilotApplications.length === 0 ? applyCopilotOpportunityButton : undefined}>
77+
<ContentLayout
78+
title='Copilot Opportunity'
79+
buttonConfig={
80+
isCopilot
81+
&& copilotApplications
82+
&& copilotApplications.length === 0 ? applyCopilotOpportunityButton : undefined
83+
}
84+
>
6985
<PageTitle>Copilot Opportunity</PageTitle>
7086
{isValidating && !showNotFound && (
7187
<LoadingSpinner />
@@ -153,7 +169,15 @@ const CopilotOpportunityDetails: FC<{}> = () => {
153169
</div>
154170
</div>
155171
{
156-
showApplyOpportunityModal && opportunity && <ApplyOpportunityModal copilotOpportunityId={opportunity?.id} onClose={() => setShowApplyOpportunityModal(false)} projectName={opportunity?.projectName} onApplied={onApplied} />
172+
showApplyOpportunityModal
173+
&& opportunity && (
174+
<ApplyOpportunityModal
175+
copilotOpportunityId={opportunity?.id}
176+
onClose={onCloseApplyModal}
177+
projectName={opportunity?.projectName}
178+
onApplied={onApplied}
179+
/>
180+
)
157181
}
158182
</ContentLayout>
159183
)

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

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ function copilotOpportunityFactory(data: any): CopilotOpportunity {
2929

3030
/**
3131
* Creates a CopilotApplication object by merging the provided data and its nested data
32-
* @param data
33-
* @returns
32+
* @param data
33+
* @returns
3434
*/
3535
function opportunityApplicationFactory(data: any): CopilotApplication[] {
3636
return data
@@ -100,15 +100,15 @@ export const useCopilotOpportunity = (opportunityId?: string): CopilotOpportunit
100100

101101
/**
102102
* apply copilot opportunity
103-
* @param opportunityId
104-
* @param request
105-
* @returns
103+
* @param opportunityId
104+
* @param request
105+
* @returns
106106
*/
107107
export const applyCopilotOpportunity = async (opportunityId: number, request: {
108108
notes?: string;
109109
}) => {
110110
const url = `${copilotBaseUrl}/copilots/opportunity/${opportunityId}/apply`
111-
111+
112112
return xhrPostAsync(url, request, {})
113113
}
114114

@@ -122,10 +122,11 @@ export const useCopilotApplications = (opportunityId?: string): CopilotApplicati
122122
const url = opportunityId ? buildUrl(`${copilotBaseUrl}/copilots/opportunity/${opportunityId}/applications`) : undefined
123123

124124
const fetcher = (urlp: string): Promise<CopilotApplication[]> => xhrGetAsync<CopilotApplication[]>(urlp)
125-
.then((data) => data).catch(() => [])
125+
.then(data => data)
126+
.catch(() => [])
126127

127128
return useSWR(url, fetcher, {
128129
refreshInterval: 0,
129130
revalidateOnFocus: false,
130131
})
131-
}
132+
}

0 commit comments

Comments
 (0)