11/* eslint-disable @typescript-eslint/no-explicit-any */
22import { memo , useMemo } from 'react' ;
3- import { Box } from '../../base' ;
3+ import { Box , Button } from '../../base' ;
44import { iconXSmall } from '../../constants/iconsSizes' ;
55import { LeaderBoardIcon , TropyIcon } from '../../icons' ;
66import { useTheme } from '../../theme' ;
@@ -20,6 +20,7 @@ import {
2020 StatsValue ,
2121 StyledCard ,
2222 Title ,
23+ TitleBox ,
2324 UserNameText
2425} from './styles' ;
2526
@@ -46,21 +47,18 @@ interface StatCardProps {
4647 patternName : string ;
4748 pattern : Pattern ;
4849 userName : string ;
49- userid : string ;
5050 status : string ;
5151 id : string ;
5252 onCardClick : ( pattern : Pattern ) => void ;
5353 onIconClick : ( sortOrder : string ) => void ;
54- onAuthorClick : ( userId : string ) => void ;
55- onStatusClick : ( status : string ) => void ;
54+ onOpenLeaderboard ?: ( ) => void ;
5655}
5756
5857interface PerformersSectionProps {
5958 useGetCatalogFilters : ( params : any ) => any ;
6059 onCardClick : ( pattern : Pattern ) => void ;
6160 onIconClick : ( sortOrder : string ) => void ;
62- onAuthorClick : ( userId : string ) => void ;
63- onStatusClick : ( status : string ) => void ;
61+ onOpenLeaderboard ?: ( ) => void ;
6462}
6563
6664type MetricType = 'view' | 'clone' | 'download' | 'deployment' | 'share' ;
@@ -114,12 +112,10 @@ const StatCardComponent: React.FC<StatCardProps> = ({
114112 patternName,
115113 pattern,
116114 userName,
117- userid,
118115 status,
119116 id,
120117 onCardClick,
121- onIconClick,
122- onAuthorClick
118+ onIconClick
123119} ) => {
124120 const handleCardClick = ( ) => {
125121 onCardClick ( pattern ) ;
@@ -130,11 +126,8 @@ const StatCardComponent: React.FC<StatCardProps> = ({
130126 onIconClick ( sortOrder ) ;
131127 } ;
132128
133- const handleAuthorClick = ( e : React . MouseEvent ) => {
134- e . stopPropagation ( ) ;
135- onAuthorClick ( userid ) ;
136- } ;
137129 const theme = useTheme ( ) ;
130+
138131 return (
139132 < StyledCard elevation = { 0 } status = { status } onClick = { handleCardClick } >
140133 < ContentWrapper cardId = { id } >
@@ -149,7 +142,7 @@ const StatCardComponent: React.FC<StatCardProps> = ({
149142
150143 < Box >
151144 < RepoTitle > { patternName } </ RepoTitle >
152- < UserNameText onClick = { handleAuthorClick } > by { userName } </ UserNameText >
145+ < UserNameText > by { userName } </ UserNameText >
153146 </ Box >
154147 </ ContentWrapper >
155148 </ StyledCard >
@@ -222,7 +215,6 @@ const processQueryData = (
222215 patternName : pattern . name || 'Unknown' ,
223216 pattern : pattern ,
224217 userName : pattern . user ?. first_name || 'Unknown' ,
225- userid : pattern . user ?. id ,
226218 id : config . id ,
227219 status : pattern ?. catalog_data ?. content_class
228220 } ;
@@ -232,8 +224,7 @@ const PerformersSection: React.FC<PerformersSectionProps> = ({
232224 useGetCatalogFilters,
233225 onCardClick,
234226 onIconClick,
235- onAuthorClick,
236- onStatusClick
227+ onOpenLeaderboard
237228} ) => {
238229 const theme = useTheme ( ) ;
239230 const { queries, isLoading, hasError } = useMetricQueries ( useGetCatalogFilters ) ;
@@ -242,13 +233,8 @@ const PerformersSection: React.FC<PerformersSectionProps> = ({
242233 ( ) =>
243234 ( Object . keys ( METRICS ) as MetricType [ ] )
244235 . 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 )
252238 ) ,
253239 [ queries ]
254240 ) ;
@@ -266,24 +252,29 @@ const PerformersSection: React.FC<PerformersSectionProps> = ({
266252 { ...stat }
267253 onCardClick = { onCardClick }
268254 onIconClick = { onIconClick }
269- onAuthorClick = { onAuthorClick }
270- onStatusClick = { onStatusClick }
271255 />
272256 ) ) ;
273257
274258 return (
275259 < ErrorBoundary >
276260 < 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 >
287278 < CardsContainer >
288279 { isLoading && < StateCardSekeleton /> }
289280 < Carousel items = { statComponents } />
0 commit comments