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 11import { useParams } from 'react-router-dom'
22import { toast } from 'react-toastify'
33import { mutate } from 'swr'
4- import { useCallback } from 'react'
4+ import { useCallback , useMemo } from 'react'
55
66import { assignCopilotOpportunity , copilotBaseUrl } from '~/apps/copilots/src/services/copilot-opportunities'
77import { CopilotApplication , CopilotApplicationStatus } from '~/apps/copilots/src/models/CopilotApplication'
88import { IconSolid , Tooltip } from '~/libs/ui'
99
1010import styles from './styles.module.scss'
1111
12- const CopilotApplicationAction = ( copilotApplication : CopilotApplication ) : JSX . Element => {
12+ const CopilotApplicationAction = ( copilotApplication : CopilotApplication , allCopilotApplications : CopilotApplication [ ] ) : JSX . Element => {
1313 const { opportunityId } : { opportunityId ?: string } = useParams < { opportunityId ?: string } > ( )
14+ const isInvited = useMemo ( ( ) => allCopilotApplications . findIndex ( item => item . status === CopilotApplicationStatus . INVITED ) > - 1 , [ allCopilotApplications ] )
1415 const onClick = useCallback ( async ( ) => {
1516 if ( copilotApplication . status !== CopilotApplicationStatus . PENDING ) {
1617 return
@@ -39,7 +40,7 @@ const CopilotApplicationAction = (copilotApplication: CopilotApplication): JSX.E
3940 }
4041
4142 {
42- copilotApplication . status === CopilotApplicationStatus . PENDING && (
43+ ! isInvited && copilotApplication . status === CopilotApplicationStatus . PENDING && (
4344 < IconSolid . UserAddIcon />
4445 )
4546 }
Original file line number Diff line number Diff 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 }
Original file line number Diff line number Diff 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
2829const 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 (
Original file line number Diff line number Diff 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
2728export 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 }
You can’t perform that action at this time.
0 commit comments