Skip to content

PROD: Copilot portal CRs & Bugs V3 #1181

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

Merged
merged 13 commits into from
Aug 11, 2025
Merged

PROD: Copilot portal CRs & Bugs V3 #1181

merged 13 commits into from
Aug 11, 2025

Conversation

hentrymartin
Copy link
Collaborator

@hentrymartin hentrymartin commented Aug 11, 2025


const ConfirmModal: FC<ConfirmModalProps> = props => (
<BaseModal
onClose={props.onClose as () => void}

Choose a reason for hiding this comment

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

Suggestion

The onClose prop is being cast to () => void, which might suppress type errors. Consider ensuring that the onClose function matches the expected type without casting.

title='Confirm to accept as copilot'
buttons={(
<>
<Button primary onClick={props.onApply} label='Confirm' />

Choose a reason for hiding this comment

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

Suggestion

Consider adding type='button' to the Button components to explicitly define their type and avoid potential form submission issues if this component is used within a form.

buttons={(
<>
<Button primary onClick={props.onApply} label='Confirm' />
<Button secondary onClick={props.onClose} label='Cancel' />

Choose a reason for hiding this comment

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

Suggestion

Consider adding type='button' to the Button components to explicitly define their type and avoid potential form submission issues if this component is used within a form.

@@ -1,13 +1,13 @@
import { useParams } from 'react-router-dom'
import { toast } from 'react-toastify'
import { mutate } from 'swr'
import { useCallback, useMemo, useState } from 'react'

Choose a reason for hiding this comment

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

The import statement for mutate from 'swr' has been removed. If this function is still used elsewhere in the code, ensure that it is not causing any issues or errors due to its removal.

@@ -32,19 +33,8 @@ const CopilotApplicationAction = (

if (copilotApplication.existingMembership) {
setShowAlreadyMemberModal(true)

Choose a reason for hiding this comment

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

The return statement has been removed, which changes the control flow of the function. Ensure that this change is intentional and that the function should continue execution after setting setShowAlreadyMemberModal(true).

toast.error(error.message)
}

} else {

Choose a reason for hiding this comment

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

The else block has been added, which changes the logic of when setShowConfirmModal(true) is called. Verify that this logic change aligns with the intended behavior of the application.

@@ -56,8 +46,9 @@ const CopilotApplicationAction = (

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

Choose a reason for hiding this comment

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

Consider checking if copilotApplication.onApplied is defined before calling it to prevent potential runtime errors.

@@ -84,7 +76,7 @@ const CopilotApplicationAction = (
!isInvited
&& copilotApplication.status === CopilotApplicationStatus.PENDING
&& copilotApplication.opportunityStatus === 'active' && (
<Tooltip content='Send Invitation'>
<Tooltip content='Accept'>

Choose a reason for hiding this comment

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

The tooltip content has been changed from 'Send Invitation' to 'Accept'. Ensure that this change aligns with the intended functionality and user experience. If the action is still related to sending an invitation, consider revisiting the tooltip text for clarity.

@@ -85,6 +86,7 @@ const CopilotApplications: FC<{
activeProjects: member?.activeProjects || 0,
fulfilment: member?.copilotFulfillment || 0,
handle: member?.handle,
onApplied: props.onApplied,

Choose a reason for hiding this comment

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

The onApplied property is being added to the object, but it is not clear from the diff if this property is being used or handled correctly elsewhere in the code. Ensure that onApplied is being utilized appropriately and that it does not introduce any unintended side effects.

{props.opportunity?.overview}
</p>
{props.opportunity?.overview && (
<div dangerouslySetInnerHTML={{

Choose a reason for hiding this comment

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

Using dangerouslySetInnerHTML can expose the application to XSS attacks if the overview content is not properly sanitized. Consider sanitizing the HTML content before rendering it to ensure security.

@@ -45,6 +45,7 @@ const CopilotRequestForm: FC<{}> = () => {
const [formErrors, setFormErrors] = useState<any>({})
const [paymentType, setPaymentType] = useState<string>('')
const [projectFromQuery, setProjectFromQuery] = useState<Project>()
const activeProjectStatuses = ['active', 'approved', 'draft', 'new']

Choose a reason for hiding this comment

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

Consider defining activeProjectStatuses as a constant outside of the component to avoid re-initializing it on every render. This can improve performance slightly by reducing unnecessary re-creation of the array.

const response = await getProjects(inputValue, {
filter: {
status: {
$in: [activeProjectStatuses],

Choose a reason for hiding this comment

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

The variable activeProjectStatuses should be an array or a list of statuses. Ensure that activeProjectStatuses is defined and contains the appropriate values for filtering projects by status.

@@ -97,4 +97,8 @@ $gradient: linear-gradient(
margin-right: $sp-1;
}
}

.datepicker input{

Choose a reason for hiding this comment

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

Consider adding a space before the opening curly brace for consistency with the rest of the file's formatting.


.datepicker input{
color: black;
}
}

Choose a reason for hiding this comment

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

It's a good practice to ensure that files end with a newline character to avoid potential issues with some tools and version control systems.

@@ -200,7 +200,10 @@ const CopilotRequestsPage: FC = () => {
className: styles.opportunityTitle,
label: 'Title',
propertyName: 'opportunityTitle',
type: 'text',
renderer: (copilotRequest: CopilotRequest) => (
<div className={styles.title}>{copilotRequest.opportunityTitle}</div>

Choose a reason for hiding this comment

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

Consider adding a fallback or default value for copilotRequest.opportunityTitle to handle cases where it might be undefined or null.

@@ -63,8 +63,8 @@ export const getProject = (projectId: string): Promise<Project> => {
return xhrGetAsync<Project>(url)
}

export const getProjects = (search?: string, filter?: any): Promise<Project[]> => {
const params = { name: `"${search}"`, ...filter }
export const getProjects = (search?: string, config?: {filter: any}): Promise<Project[]> => {

Choose a reason for hiding this comment

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

The type for config parameter should be more specific if possible, instead of using any for filter. Consider defining a type or interface for filter to improve type safety.

export const getProjects = (search?: string, filter?: any): Promise<Project[]> => {
const params = { name: `"${search}"`, ...filter }
export const getProjects = (search?: string, config?: {filter: any}): Promise<Project[]> => {
const params = { name: search, ...config?.filter }

Choose a reason for hiding this comment

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

The name parameter in params is now directly assigned search without quotes. Ensure that this change is intentional and that the API expects the search term without quotes.

@hentrymartin hentrymartin requested a review from jmgasper August 11, 2025 16:09
@jmgasper jmgasper merged commit 51e8773 into master Aug 11, 2025
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants