Skip to content

fix(PM-580): dont show action button when invite is inprogress #1087

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 2 commits into from
May 27, 2025
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
Original file line number Diff line number Diff line change
@@ -1,16 +1,23 @@
import { useParams } from 'react-router-dom'
import { toast } from 'react-toastify'
import { mutate } from 'swr'
import { useCallback } from 'react'
import { useCallback, useMemo } from 'react'

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

import styles from './styles.module.scss'

const CopilotApplicationAction = (copilotApplication: CopilotApplication): JSX.Element => {
const CopilotApplicationAction = (
copilotApplication: CopilotApplication,
allCopilotApplications: CopilotApplication[],
): JSX.Element => {
const { opportunityId }: {opportunityId?: string} = useParams<{ opportunityId?: string }>()
const isInvited = useMemo(
() => allCopilotApplications.findIndex(item => item.status === CopilotApplicationStatus.INVITED) > -1,
[allCopilotApplications],
)
const onClick = useCallback(async () => {
if (copilotApplication.status !== CopilotApplicationStatus.PENDING) {
return
Expand Down Expand Up @@ -39,7 +46,7 @@ const CopilotApplicationAction = (copilotApplication: CopilotApplication): JSX.E
}

{
copilotApplication.status === CopilotApplicationStatus.PENDING && (
!isInvited && copilotApplication.status === CopilotApplicationStatus.PENDING && (

Choose a reason for hiding this comment

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

Consider adding a check for isInvited before copilotApplication.status === CopilotApplicationStatus.PENDING to improve readability and ensure the logical flow is clear. This helps in understanding that the invitation status is checked first before evaluating the application status.

<IconSolid.UserAddIcon />
)
}
Expand Down
1 change: 1 addition & 0 deletions src/libs/ui/lib/components/table/Table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ const Table: <T extends { [propertyName: string]: any }>(props: TableProps<T>) =
<TableRow
key={getKey(index)}
data={sorted}
allRows={sortedData}

Choose a reason for hiding this comment

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

The addition of the allRows prop to the TableRow component should be verified to ensure that it is necessary for the functionality described in the pull request. If allRows is not used within TableRow, consider removing it to avoid unnecessary prop passing.

onRowClick={props.onRowClick}
columns={props.columns}
index={index}
Expand Down
5 changes: 3 additions & 2 deletions src/libs/ui/lib/components/table/table-cell/TableCell.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,14 @@ interface TableCellProps<T> {
readonly index: number
readonly propertyName?: string
readonly className?: string
readonly renderer?: (data: T) => JSX.Element | undefined
readonly renderer?: (data: T, allRows?: ReadonlyArray<T>) => JSX.Element | undefined

Choose a reason for hiding this comment

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

The renderer function signature has been updated to include an optional allRows parameter. Ensure that all usages of this function are updated accordingly to handle this new parameter, even if it's not used in all cases.

readonly type: TableCellType
readonly onExpand?: () => void
readonly as?: ElementType
readonly showExpandIndicator?: boolean
readonly isExpanded?: boolean
readonly colSpan?: number
allRows?: ReadonlyArray<T>

Choose a reason for hiding this comment

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

The allRows property has been added to the TableCellProps interface. Verify that this property is correctly passed and utilized in the component where necessary, and ensure it aligns with the intended functionality described in the pull request.

}

const TableCell: <T extends { [propertyName: string]: any }>(
Expand All @@ -40,7 +41,7 @@ const TableCell: <T extends { [propertyName: string]: any }>(
case 'action':
case 'element':
case 'numberElement':
data = props.renderer?.(props.data)
data = props.renderer?.(props.data, props.allRows)

Choose a reason for hiding this comment

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

The renderer function now receives an additional argument props.allRows. Ensure that the renderer function is designed to handle this new parameter appropriately. If renderer is a third-party or external function, verify its compatibility with this change.

break
case 'money':
data = textFormatMoneyLocaleString(
Expand Down
2 changes: 2 additions & 0 deletions src/libs/ui/lib/components/table/table-row/TableRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ interface Props<T> {
index: number
readonly showExpand?: boolean
readonly preventDefault?: boolean
allRows?: ReadonlyArray<T>
}

export const TableRow: <T extends { [propertyName: string]: any }>(
Expand Down Expand Up @@ -50,6 +51,7 @@ export const TableRow: <T extends { [propertyName: string]: any }>(
{...col}
data={props.data}
index={props.index}
allRows={props.allRows}

Choose a reason for hiding this comment

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

The addition of the allRows prop to the component should be verified for its necessity. Ensure that this prop is used within the component logic and that it aligns with the purpose of the pull request, which is to hide the action button when an invite is in progress. If allRows is not directly related to this functionality, consider removing it or clarifying its role.

key={getKey(`${props.index}${colIndex}`)}
showExpandIndicator={colIndex === 0 && props.showExpand}
isExpanded={isExpanded && colIndex === 0}
Expand Down