File tree Expand file tree Collapse file tree 4 files changed +10
-5
lines changed
apps/copilots/src/pages/copilot-opportunity-details/tabs/copilot-applications
libs/ui/lib/components/table Expand file tree Collapse file tree 4 files changed +10
-5
lines changed Original file line number Diff line number Diff line change 1
1
import { useParams } from 'react-router-dom'
2
2
import { toast } from 'react-toastify'
3
3
import { mutate } from 'swr'
4
- import { useCallback } from 'react'
4
+ import { useCallback , useMemo } from 'react'
5
5
6
6
import { assignCopilotOpportunity , copilotBaseUrl } from '~/apps/copilots/src/services/copilot-opportunities'
7
7
import { CopilotApplication , CopilotApplicationStatus } from '~/apps/copilots/src/models/CopilotApplication'
8
8
import { IconSolid , Tooltip } from '~/libs/ui'
9
9
10
10
import styles from './styles.module.scss'
11
11
12
- const CopilotApplicationAction = ( copilotApplication : CopilotApplication ) : JSX . Element => {
12
+ const CopilotApplicationAction = ( copilotApplication : CopilotApplication , allCopilotApplications : CopilotApplication [ ] ) : JSX . Element => {
13
13
const { opportunityId } : { opportunityId ?: string } = useParams < { opportunityId ?: string } > ( )
14
+ const isInvited = useMemo ( ( ) => allCopilotApplications . findIndex ( item => item . status === CopilotApplicationStatus . INVITED ) > - 1 , [ allCopilotApplications ] )
14
15
const onClick = useCallback ( async ( ) => {
15
16
if ( copilotApplication . status !== CopilotApplicationStatus . PENDING ) {
16
17
return
@@ -39,7 +40,7 @@ const CopilotApplicationAction = (copilotApplication: CopilotApplication): JSX.E
39
40
}
40
41
41
42
{
42
- copilotApplication . status === CopilotApplicationStatus . PENDING && (
43
+ ! isInvited && copilotApplication . status === CopilotApplicationStatus . PENDING && (
43
44
< IconSolid . UserAddIcon />
44
45
)
45
46
}
Original file line number Diff line number Diff line change @@ -177,6 +177,7 @@ const Table: <T extends { [propertyName: string]: any }>(props: TableProps<T>) =
177
177
< TableRow
178
178
key = { getKey ( index ) }
179
179
data = { sorted }
180
+ allRows = { sortedData }
180
181
onRowClick = { props . onRowClick }
181
182
columns = { props . columns }
182
183
index = { index }
Original file line number Diff line number Diff line change @@ -16,13 +16,14 @@ interface TableCellProps<T> {
16
16
readonly index : number
17
17
readonly propertyName ?: string
18
18
readonly className ?: string
19
- readonly renderer ?: ( data : T ) => JSX . Element | undefined
19
+ readonly renderer ?: ( data : T , allRows ?: ReadonlyArray < T > ) => JSX . Element | undefined
20
20
readonly type : TableCellType
21
21
readonly onExpand ?: ( ) => void
22
22
readonly as ?: ElementType
23
23
readonly showExpandIndicator ?: boolean
24
24
readonly isExpanded ?: boolean
25
25
readonly colSpan ?: number
26
+ allRows ?: ReadonlyArray < T >
26
27
}
27
28
28
29
const TableCell : < T extends { [ propertyName : string ] : any } > (
@@ -40,7 +41,7 @@ const TableCell: <T extends { [propertyName: string]: any }>(
40
41
case 'action' :
41
42
case 'element' :
42
43
case 'numberElement' :
43
- data = props . renderer ?.( props . data )
44
+ data = props . renderer ?.( props . data , props . allRows )
44
45
break
45
46
case 'money' :
46
47
data = textFormatMoneyLocaleString (
Original file line number Diff line number Diff line change @@ -22,6 +22,7 @@ interface Props<T> {
22
22
index : number
23
23
readonly showExpand ?: boolean
24
24
readonly preventDefault ?: boolean
25
+ allRows ?: ReadonlyArray < T >
25
26
}
26
27
27
28
export const TableRow : < T extends { [ propertyName : string ] : any } > (
@@ -50,6 +51,7 @@ export const TableRow: <T extends { [propertyName: string]: any }>(
50
51
{ ...col }
51
52
data = { props . data }
52
53
index = { props . index }
54
+ allRows = { props . allRows }
53
55
key = { getKey ( `${ props . index } ${ colIndex } ` ) }
54
56
showExpandIndicator = { colIndex === 0 && props . showExpand }
55
57
isExpanded = { isExpanded && colIndex === 0 }
You can’t perform that action at this time.
0 commit comments