1
1
/* eslint-disable @typescript-eslint/no-explicit-any */
2
2
import { memo , useMemo } from 'react' ;
3
- import { Box } from '../../base' ;
3
+ import { Box , Button } from '../../base' ;
4
4
import { iconXSmall } from '../../constants/iconsSizes' ;
5
5
import { LeaderBoardIcon , TropyIcon } from '../../icons' ;
6
6
import { useTheme } from '../../theme' ;
@@ -20,6 +20,7 @@ import {
20
20
StatsValue ,
21
21
StyledCard ,
22
22
Title ,
23
+ TitleBox ,
23
24
UserNameText
24
25
} from './styles' ;
25
26
@@ -46,21 +47,18 @@ interface StatCardProps {
46
47
patternName : string ;
47
48
pattern : Pattern ;
48
49
userName : string ;
49
- userid : string ;
50
50
status : string ;
51
51
id : string ;
52
52
onCardClick : ( pattern : Pattern ) => void ;
53
53
onIconClick : ( sortOrder : string ) => void ;
54
- onAuthorClick : ( userId : string ) => void ;
55
- onStatusClick : ( status : string ) => void ;
54
+ onOpenLeaderboard ?: ( ) => void ;
56
55
}
57
56
58
57
interface PerformersSectionProps {
59
58
useGetCatalogFilters : ( params : any ) => any ;
60
59
onCardClick : ( pattern : Pattern ) => void ;
61
60
onIconClick : ( sortOrder : string ) => void ;
62
- onAuthorClick : ( userId : string ) => void ;
63
- onStatusClick : ( status : string ) => void ;
61
+ onOpenLeaderboard ?: ( ) => void ;
64
62
}
65
63
66
64
type MetricType = 'view' | 'clone' | 'download' | 'deployment' | 'share' ;
@@ -114,12 +112,10 @@ const StatCardComponent: React.FC<StatCardProps> = ({
114
112
patternName,
115
113
pattern,
116
114
userName,
117
- userid,
118
115
status,
119
116
id,
120
117
onCardClick,
121
- onIconClick,
122
- onAuthorClick
118
+ onIconClick
123
119
} ) => {
124
120
const handleCardClick = ( ) => {
125
121
onCardClick ( pattern ) ;
@@ -130,11 +126,8 @@ const StatCardComponent: React.FC<StatCardProps> = ({
130
126
onIconClick ( sortOrder ) ;
131
127
} ;
132
128
133
- const handleAuthorClick = ( e : React . MouseEvent ) => {
134
- e . stopPropagation ( ) ;
135
- onAuthorClick ( userid ) ;
136
- } ;
137
129
const theme = useTheme ( ) ;
130
+
138
131
return (
139
132
< StyledCard elevation = { 0 } status = { status } onClick = { handleCardClick } >
140
133
< ContentWrapper cardId = { id } >
@@ -149,7 +142,7 @@ const StatCardComponent: React.FC<StatCardProps> = ({
149
142
150
143
< Box >
151
144
< RepoTitle > { patternName } </ RepoTitle >
152
- < UserNameText onClick = { handleAuthorClick } > by { userName } </ UserNameText >
145
+ < UserNameText > by { userName } </ UserNameText >
153
146
</ Box >
154
147
</ ContentWrapper >
155
148
</ StyledCard >
@@ -222,7 +215,6 @@ const processQueryData = (
222
215
patternName : pattern . name || 'Unknown' ,
223
216
pattern : pattern ,
224
217
userName : pattern . user ?. first_name || 'Unknown' ,
225
- userid : pattern . user ?. id ,
226
218
id : config . id ,
227
219
status : pattern ?. catalog_data ?. content_class
228
220
} ;
@@ -232,8 +224,7 @@ const PerformersSection: React.FC<PerformersSectionProps> = ({
232
224
useGetCatalogFilters,
233
225
onCardClick,
234
226
onIconClick,
235
- onAuthorClick,
236
- onStatusClick
227
+ onOpenLeaderboard
237
228
} ) => {
238
229
const theme = useTheme ( ) ;
239
230
const { queries, isLoading, hasError } = useMetricQueries ( useGetCatalogFilters ) ;
@@ -242,13 +233,8 @@ const PerformersSection: React.FC<PerformersSectionProps> = ({
242
233
( ) =>
243
234
( Object . keys ( METRICS ) as MetricType [ ] )
244
235
. map ( ( metric ) => processQueryData ( queries , metric ) )
245
- . filter (
246
- (
247
- stat
248
- ) : stat is Omit <
249
- StatCardProps ,
250
- 'onCardClick' | 'onIconClick' | 'onAuthorClick' | 'onStatusClick'
251
- > => Boolean ( stat )
236
+ . filter ( ( stat ) : stat is Omit < StatCardProps , 'onCardClick' | 'onIconClick' > =>
237
+ Boolean ( stat )
252
238
) ,
253
239
[ queries ]
254
240
) ;
@@ -266,24 +252,29 @@ const PerformersSection: React.FC<PerformersSectionProps> = ({
266
252
{ ...stat }
267
253
onCardClick = { onCardClick }
268
254
onIconClick = { onIconClick }
269
- onAuthorClick = { onAuthorClick }
270
- onStatusClick = { onStatusClick }
271
255
/>
272
256
) ) ;
273
257
274
258
return (
275
259
< ErrorBoundary >
276
260
< MainContainer >
277
- < Title >
278
- Top Performers
279
- < TropyIcon
280
- style = { {
281
- height : '2rem' ,
282
- width : '2rem' ,
283
- color : theme . palette . icon . secondary
284
- } }
285
- />
286
- </ Title >
261
+ < TitleBox >
262
+ < Box display = { 'flex' } alignItems = "center" gap = { 1 } >
263
+ < Title > Top Performers</ Title >
264
+ < TropyIcon
265
+ style = { {
266
+ height : '2rem' ,
267
+ width : '2rem' ,
268
+ color : theme . palette . icon . secondary
269
+ } }
270
+ />
271
+ </ Box >
272
+ { onOpenLeaderboard && (
273
+ < Button variant = "contained" onClick = { ( ) => onOpenLeaderboard ( ) } >
274
+ Open Leaderboard
275
+ </ Button >
276
+ ) }
277
+ </ TitleBox >
287
278
< CardsContainer >
288
279
{ isLoading && < StateCardSekeleton /> }
289
280
< Carousel items = { statComponents } />
0 commit comments