1+ /* eslint-disable max-len */
12/* eslint-disable react/jsx-no-bind */
23import { toast } from 'react-toastify'
34import { AxiosError } from 'axios'
@@ -72,6 +73,7 @@ const ListView: FC<ListViewProps> = (props: ListViewProps) => {
7273 const [ confirmFlow , setConfirmFlow ] = React . useState < ConfirmFlowData | undefined > ( undefined )
7374 const [ winnings , setWinnings ] = React . useState < ReadonlyArray < Winning > > ( [ ] )
7475 const [ isLoading , setIsLoading ] = React . useState < boolean > ( false )
76+ const [ filters , setFilters ] = React . useState < Record < string , string [ ] > > ( { } )
7577
7678 const convertToWinnings = useCallback (
7779 ( payments : WinningDetail [ ] ) => payments . map ( payment => ( {
@@ -94,15 +96,15 @@ const ListView: FC<ListViewProps> = (props: ListViewProps) => {
9496 const fetchWinnings = useCallback ( async ( ) => {
9597 setIsLoading ( true )
9698 try {
97- const payments = await getPayments ( props . profile . userId . toString ( ) )
99+ const payments = await getPayments ( props . profile . userId . toString ( ) , filters )
98100 const winningsData = convertToWinnings ( payments )
99101 setWinnings ( winningsData )
100102 } catch ( apiError ) {
101103 console . error ( 'Failed to fetch winnings:' , apiError )
102104 } finally {
103105 setIsLoading ( false )
104106 }
105- } , [ props . profile . userId , convertToWinnings ] )
107+ } , [ props . profile . userId , convertToWinnings , filters ] )
106108
107109 const renderConfirmModalContent = React . useMemo ( ( ) => {
108110 if ( confirmFlow ?. content === undefined ) {
@@ -192,6 +194,10 @@ const ListView: FC<ListViewProps> = (props: ListViewProps) => {
192194 label : 'Contest Payment' ,
193195 value : 'CONTEST_PAYMENT' ,
194196 } ,
197+ {
198+ label : 'Copilot Payment' ,
199+ value : 'COPILOT_PAYMENT' ,
200+ } ,
195201 {
196202 label : 'Review Board Payment' ,
197203 value : 'REVIEW_BOARD_PAYMENT' ,
@@ -224,15 +230,18 @@ const ListView: FC<ListViewProps> = (props: ListViewProps) => {
224230 } ,
225231 ] }
226232 onFilterChange = { ( key : string , value : string [ ] ) => {
227- console . log ( key , value )
233+ setFilters ( {
234+ ...filters ,
235+ [ key ] : value ,
236+ } )
228237 } }
229238 onResetFilters = { ( ) => {
230- console . log ( 'reset' )
239+ setFilters ( { } )
231240 } }
232241 />
233242 { /* <PageDivider /> */ }
234- { isLoading && < LoadingCircles /> }
235- { ! isLoading && (
243+ { isLoading && < LoadingCircles className = { styles . centered } /> }
244+ { ! isLoading && winnings . length > 0 && (
236245 < PaymentsTable
237246 payments = { winnings }
238247 onPayMeClick = { async function onPayMeClicked (
@@ -248,6 +257,15 @@ const ListView: FC<ListViewProps> = (props: ListViewProps) => {
248257 } }
249258 />
250259 ) }
260+ { ! isLoading && winnings . length === 0 && (
261+ < div className = { styles . centered } >
262+ < p className = 'body-main' >
263+ { Object . keys ( filters ) . length === 0
264+ ? 'Your future earnings will appear here — explore Topcoder\'s opportunities to start making an impact!'
265+ : 'No payments match your filters.' }
266+ </ p >
267+ </ div >
268+ ) }
251269 </ Collapsible >
252270 </ div >
253271 </ div >
0 commit comments