Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/apps/copilots/src/models/CopilotApplication.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,5 @@ export interface CopilotApplication {
opportunityStatus: string,
existingMembership?: ExistingMembership,
projectName: string,
onApplied: () => void,
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The addition of the onApplied function property to the CopilotApplication interface should include a description of its purpose and usage in the context of the application. Ensure that this function is implemented and utilized correctly wherever the CopilotApplication interface is used.

}
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,7 @@ const CopilotOpportunityDetails: FC<{}> = () => {
copilotApplications={copilotApplications}
opportunity={opportunity}
members={members}
onApplied={onApplied}
/>
)}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import { useParams } from 'react-router-dom'
import { toast } from 'react-toastify'
import { mutate } from 'swr'
import { useCallback, useMemo, useState } from 'react'
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The removal of the mutate import suggests that it is no longer used in this file. Ensure that any related functionality relying on mutate is either updated or removed to prevent potential issues.


import { assignCopilotOpportunity, copilotBaseUrl } from '~/apps/copilots/src/services/copilot-opportunities'
import { assignCopilotOpportunity } from '~/apps/copilots/src/services/copilot-opportunities'
import { CopilotApplication, CopilotApplicationStatus } from '~/apps/copilots/src/models/CopilotApplication'
import { IconSolid, Tooltip } from '~/libs/ui'

Expand Down Expand Up @@ -38,8 +37,8 @@ const CopilotApplicationAction = (
if (opportunityId) {
try {
await assignCopilotOpportunity(opportunityId, copilotApplication.id)
toast.success('Invited a copilot')
mutate(`${copilotBaseUrl}/copilots/opportunity/${opportunityId}/applications`)
toast.success('Accepted as copilot')
copilotApplication.onApplied()
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The mutate function call has been removed. Ensure that the removal of this line does not affect the application's state management or data fetching logic. If this line was responsible for revalidating or updating the cache, consider implementing an alternative approach to maintain the application's data consistency.

} catch (e) {
const error = e as Error
toast.error(error.message)
Expand All @@ -56,7 +55,7 @@ const CopilotApplicationAction = (

await assignCopilotOpportunity(opportunityId, copilotApplication.id)
toast.success('Accepted as copilot')
mutate(`${copilotBaseUrl}/copilots/opportunity/${opportunityId}/applications`)
copilotApplication.onApplied()
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The line copilotApplication.onApplied() replaces the previous mutate function call. Ensure that onApplied() correctly handles the cache update or any necessary side effects that mutate was performing. If onApplied() does not handle these, consider maintaining the mutate call or implementing the necessary logic within onApplied().

setShowAlreadyMemberModal(false)
} catch (e) {
const error = e as Error
Expand Down Expand Up @@ -84,7 +83,7 @@ const CopilotApplicationAction = (
!isInvited
&& copilotApplication.status === CopilotApplicationStatus.PENDING
&& copilotApplication.opportunityStatus === 'active' && (
<Tooltip content='Send Invitation'>
<Tooltip content='Accept Application'>
<IconSolid.UserAddIcon />
</Tooltip>
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ const CopilotApplications: FC<{
copilotApplications?: CopilotApplication[]
members?: FormattedMembers[]
opportunity: CopilotOpportunity
onApplied: () => void
}> = props => {
const getData = (): CopilotApplication[] => (props.copilotApplications ? props.copilotApplications.map(item => {
const member = props.members && props.members.find(each => each.userId === item.userId)
Expand All @@ -85,6 +86,7 @@ const CopilotApplications: FC<{
activeProjects: member?.activeProjects || 0,
fulfilment: member?.copilotFulfillment || 0,
handle: member?.handle,
onApplied: props.onApplied,
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The addition of onApplied: props.onApplied seems to be a new property being passed to the component. Ensure that onApplied is defined and used appropriately within the component to avoid potential runtime errors.

opportunityStatus: props.opportunity.status,
pastProjects: member?.pastProjects || 0,
projectName: props.opportunity.projectName,
Expand Down