@@ -12,13 +12,15 @@ import {
1212 PaginationPrevious ,
1313} from '@/components/ui/pagination' ;
1414import { Table , TableBody , TableCell , TableHead , TableHeader , TableRow } from '@/components/ui/table' ;
15+ import { fetchCountryList } from '@/graphql/helpers/fetch-countries' ;
1516import { graphqlDirect } from '@/lib/graphql/graphql-direct' ;
1617import { GlobalRankingsDocument , RankOrder } from '@/types/generated/graphql' ;
1718import { getInitials } from '@/utils/get-initials' ;
1819
1920import { ClickableRow } from './components/clickale-row' ;
2021import { LinkWithStopPropagation } from './components/link-with-stop-propagation' ;
2122import { ProfileAvatar } from './components/profile-avatar' ;
23+ import { getCountryFlag } from './utils/get-country-flag' ;
2224
2325const ITEMS_PER_PAGE = 100 ;
2426
@@ -64,7 +66,10 @@ export default async function GlobalRanking({ params }: { params: Promise<{ rank
6466 const page = parseInt ( pageParam , 10 ) ;
6567 const [ queryOrder , rankPropName , title , subtitle , rankingBaseEntity ] = getConfigByRankingType ( rankingType ) ;
6668 const offset = ( page - 1 ) * ITEMS_PER_PAGE ;
67- const data = await graphqlDirect ( GlobalRankingsDocument , { order : queryOrder , offset } ) ;
69+ const [ { globalRankings } , countries ] = await Promise . all ( [
70+ graphqlDirect ( GlobalRankingsDocument , { order : queryOrder , offset } ) ,
71+ fetchCountryList ( ) ,
72+ ] ) ;
6873
6974 return (
7075 < Page className = "max-w-5xl gap-6" >
@@ -83,7 +88,7 @@ export default async function GlobalRanking({ params }: { params: Promise<{ rank
8388 </ TableRow >
8489 </ TableHeader >
8590 < TableBody >
86- { data . globalRankings . map ( ( item ) => {
91+ { globalRankings . map ( ( item ) => {
8792 const { githubId, user } = item ;
8893 return (
8994 < ClickableRow key = { githubId } className = "border-b-0" href = { `/profile/${ user ?. login } ` } >
@@ -101,7 +106,9 @@ export default async function GlobalRanking({ params }: { params: Promise<{ rank
101106 { user ?. login }
102107 </ LinkWithStopPropagation >
103108 </ TableCell >
104- < TableCell className = "hidden sm:table-cell break-all whitespace-normal" > { user ?. location } </ TableCell >
109+ < TableCell className = "hidden sm:table-cell break-all whitespace-normal" >
110+ { getCountryFlag ( countries , user ?. country ) } { user ?. location }
111+ </ TableCell >
105112 < TableCell className = "text-right" > { user ?. [ rankPropName ] ?. toLocaleString ( 'en-US' ) } </ TableCell >
106113 </ ClickableRow >
107114 ) ;
0 commit comments