Skip to content

Commit

Permalink
Redirect for leaderboard links to polkaverse part of leaderboard
Browse files Browse the repository at this point in the history
  • Loading branch information
samchuk-vlad committed May 7, 2024
1 parent 943c200 commit 84ae8bd
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 8 deletions.
3 changes: 2 additions & 1 deletion src/components/layouts/CreatorSidebar/RewardInfo.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Skeleton } from '@/components/SkeletonFallback'
import getAmountRange from '@/components/content-staking/utils/getAmountRangeForAnalytics'
import PopOver from '@/components/floating/PopOver'
import { getLeaderboardLink } from '@/components/leaderboard/utils'
import {
PostRewards,
RewardReport,
Expand All @@ -19,7 +20,6 @@ import { AiOutlineLineChart } from 'react-icons/ai'
import { RiHistoryFill } from 'react-icons/ri'
import { SlQuestion } from 'react-icons/sl'
import CustomLink from 'src/components/referral/CustomLink'
import { getLeaderboardLink } from '../Sidebar'
import RewardHistoryModal from './RewardHistoryModal'
import StakerRewardProgressBar, {
StakerRewardProgressBarProps,
Expand Down Expand Up @@ -98,6 +98,7 @@ export default function RewardInfo({ size, ...props }: RewardInfoProps) {
<CustomLink
className='flex items-center justify-center gap-2 px-4 py-3.5 font-medium text-text-primary'
href={`${getLeaderboardLink(myAddress)}?role=staker`}
forceHardNavigation
onClick={() => {
sendEvent('leaderboard_my_stats_opened', {
myStats: true,
Expand Down
5 changes: 2 additions & 3 deletions src/components/layouts/Sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { MdOutlineLeaderboard } from 'react-icons/md'
import { RiLineChartLine } from 'react-icons/ri'
import { TbCoins, TbWorld } from 'react-icons/tb'
import { TiFlashOutline } from 'react-icons/ti'
import { getLeaderboardLink } from '../leaderboard/utils'
import CustomLink from '../referral/CustomLink'

export default function Sidebar() {
Expand Down Expand Up @@ -41,6 +42,7 @@ export default function Sidebar() {
icon={MdOutlineLeaderboard}
title='Leaderboard'
href={getLeaderboardLink(myAddress)}
forceHardNavigation
/>
<SidebarItem
icon={RiLineChartLine}
Expand Down Expand Up @@ -77,9 +79,6 @@ export default function Sidebar() {
)
}

export const getLeaderboardLink = (address: string | null) =>
`/leaderboard${address ? `/${address}` : ''}`

function SidebarItem({
icon: Icon,
title,
Expand Down
2 changes: 1 addition & 1 deletion src/components/leaderboard/MyStats/LeaderboardModal.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import Loading from '@/components/Loading'
import { Column, TableHeader } from '@/components/Table'
import { getLeaderboardLink } from '@/components/layouts/Sidebar'
import Modal from '@/components/modals/Modal'
import { LeaderboardRole } from '@/services/datahub/leaderboard'
import { getLeaderboardDataQuery } from '@/services/datahub/leaderboard/query'
import { cx } from '@/utils/class-names'
import { useRouter } from 'next/router'
import InfiniteScroll from 'react-infinite-scroll-component'
import { TableRow } from '../../Table'
import { getLeaderboardLink } from '../utils'
import { UserPreview, UserReward, leaderboardColumns } from './LeaderboardTable'

type LeaderboardModalProps = {
Expand Down
2 changes: 1 addition & 1 deletion src/components/leaderboard/MyStats/LeaderboardTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import Loading from '@/components/Loading'
import Name from '@/components/Name'
import Table, { Column } from '@/components/Table'
import { mutedTextColorStyles } from '@/components/content-staking/utils/commonStyles'
import { getLeaderboardLink } from '@/components/layouts/Sidebar'
import { ZERO } from '@/constants/config'
import { getProfileQuery } from '@/services/api/query'
import { useGetChainDataByNetwork } from '@/services/chainsInfo/query'
Expand All @@ -17,6 +16,7 @@ import { convertToBalanceWithDecimal, isEmptyArray } from '@subsocial/utils'
import Image from 'next/image'
import { useRouter } from 'next/router'
import { useMemo, useState } from 'react'
import { getLeaderboardLink } from '../utils'
import LeaderboardModal from './LeaderboardModal'

const TABLE_LIMIT = 10
Expand Down
3 changes: 1 addition & 2 deletions src/components/leaderboard/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@ import { useMyMainAddress } from '@/stores/my-account'
import { useRouter } from 'next/router'
import { useCallback, useEffect, useMemo, useState } from 'react'
import Tabs from '../Tabs'
import { getLeaderboardLink } from '../layouts/Sidebar'
import GlobalStats from './GlobalStats'
import MyStats from './MyStats'
import { useGetLeaderboardRole } from './utils'
import { getLeaderboardLink, useGetLeaderboardRole } from './utils'

const getIndexById = (tabs: any[], id: string) => {
return tabs.findIndex((tab) => tab.id === id)
Expand Down
3 changes: 3 additions & 0 deletions src/components/leaderboard/utils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,6 @@ export const useGetLeaderboardRole = () => {

return role || 'staker'
}

export const getLeaderboardLink = (address: string | null) =>
`/leaderboard${address ? `/${address}` : ''}`

0 comments on commit 84ae8bd

Please sign in to comment.