Skip to content

Commit baa4337

Browse files
authored
Merge pull request #1087 from topcoder-platform/pm-580_1
fix(PM-580): dont show action button when invite is inprogress
2 parents b9cf19e + 742128b commit baa4337

File tree

4 files changed

+16
-5
lines changed

4 files changed

+16
-5
lines changed

src/apps/copilots/src/pages/copilot-opportunity-details/tabs/copilot-applications/CopilotApplicationAction.tsx

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,23 @@
11
import { useParams } from 'react-router-dom'
22
import { toast } from 'react-toastify'
33
import { mutate } from 'swr'
4-
import { useCallback } from 'react'
4+
import { useCallback, useMemo } from 'react'
55

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

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

12-
const CopilotApplicationAction = (copilotApplication: CopilotApplication): JSX.Element => {
12+
const CopilotApplicationAction = (
13+
copilotApplication: CopilotApplication,
14+
allCopilotApplications: CopilotApplication[],
15+
): JSX.Element => {
1316
const { opportunityId }: {opportunityId?: string} = useParams<{ opportunityId?: string }>()
17+
const isInvited = useMemo(
18+
() => allCopilotApplications.findIndex(item => item.status === CopilotApplicationStatus.INVITED) > -1,
19+
[allCopilotApplications],
20+
)
1421
const onClick = useCallback(async () => {
1522
if (copilotApplication.status !== CopilotApplicationStatus.PENDING) {
1623
return
@@ -39,7 +46,7 @@ const CopilotApplicationAction = (copilotApplication: CopilotApplication): JSX.E
3946
}
4047

4148
{
42-
copilotApplication.status === CopilotApplicationStatus.PENDING && (
49+
!isInvited && copilotApplication.status === CopilotApplicationStatus.PENDING && (
4350
<IconSolid.UserAddIcon />
4451
)
4552
}

src/libs/ui/lib/components/table/Table.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,7 @@ const Table: <T extends { [propertyName: string]: any }>(props: TableProps<T>) =
177177
<TableRow
178178
key={getKey(index)}
179179
data={sorted}
180+
allRows={sortedData}
180181
onRowClick={props.onRowClick}
181182
columns={props.columns}
182183
index={index}

src/libs/ui/lib/components/table/table-cell/TableCell.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,14 @@ interface TableCellProps<T> {
1616
readonly index: number
1717
readonly propertyName?: string
1818
readonly className?: string
19-
readonly renderer?: (data: T) => JSX.Element | undefined
19+
readonly renderer?: (data: T, allRows?: ReadonlyArray<T>) => JSX.Element | undefined
2020
readonly type: TableCellType
2121
readonly onExpand?: () => void
2222
readonly as?: ElementType
2323
readonly showExpandIndicator?: boolean
2424
readonly isExpanded?: boolean
2525
readonly colSpan?: number
26+
allRows?: ReadonlyArray<T>
2627
}
2728

2829
const TableCell: <T extends { [propertyName: string]: any }>(
@@ -40,7 +41,7 @@ const TableCell: <T extends { [propertyName: string]: any }>(
4041
case 'action':
4142
case 'element':
4243
case 'numberElement':
43-
data = props.renderer?.(props.data)
44+
data = props.renderer?.(props.data, props.allRows)
4445
break
4546
case 'money':
4647
data = textFormatMoneyLocaleString(

src/libs/ui/lib/components/table/table-row/TableRow.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ interface Props<T> {
2222
index: number
2323
readonly showExpand?: boolean
2424
readonly preventDefault?: boolean
25+
allRows?: ReadonlyArray<T>
2526
}
2627

2728
export const TableRow: <T extends { [propertyName: string]: any }>(
@@ -50,6 +51,7 @@ export const TableRow: <T extends { [propertyName: string]: any }>(
5051
{...col}
5152
data={props.data}
5253
index={props.index}
54+
allRows={props.allRows}
5355
key={getKey(`${props.index}${colIndex}`)}
5456
showExpandIndicator={colIndex === 0 && props.showExpand}
5557
isExpanded={isExpanded && colIndex === 0}

0 commit comments

Comments
 (0)