Skip to content

Commit

Permalink
refactor: change query name from tab to role
Browse files Browse the repository at this point in the history
  • Loading branch information
teodorus-nathaniel committed Jan 24, 2024
1 parent ddfa344 commit f31a853
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/components/leaderboard/GeneralLeaderboardPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export default function GeneralLeaderboardPage({}: GeneralLeaderboardPageProps)
<Tabs
activeKey='general'
onChange={key => {
if (key === 'user') router.push(`/leaderboard/${myAddress}?tab=${key}`)
if (key === 'user') router.push(`/leaderboard/${myAddress}?role=${key}`)
else if (key === 'stats') router.push('/stats')
}}
>
Expand Down
5 changes: 3 additions & 2 deletions src/components/leaderboard/UserLeaderboardPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ export default function UserLeaderboardPage({ address }: UserLeaderboardPageProp
const myAddress = useMyAddress()

const { query } = useRouter()
let tabState = query.tab as 'staker' | 'creator'
let tabState = query.role as 'staker' | 'creator'
if (tabState !== 'staker' && tabState !== 'creator') {
tabState = 'staker'
}
Expand All @@ -127,6 +127,7 @@ export default function UserLeaderboardPage({ address }: UserLeaderboardPageProp
onChange={key => {
if (key === 'general') router.push('/leaderboard')
else if (key === 'stats') router.push('/stats')
else router.push(`/leaderboard/${myAddress}?role=${tabState}`)
}}
>
{myAddress && <Tabs.TabPane tab='My Staking Stats' key='user' />}
Expand All @@ -147,7 +148,7 @@ export default function UserLeaderboardPage({ address }: UserLeaderboardPageProp
]}
onChange={e => {
const value = e.target.value
router.push(`/leaderboard/${address}?tab=${value}`, undefined, { shallow: true })
router.push(`/leaderboard/${address}?role=${value}`, undefined, { shallow: true })
}}
value={tabState}
optionType='button'
Expand Down
2 changes: 1 addition & 1 deletion src/components/leaderboard/common/LeaderboardTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ function UserRow({
)

return (
<Link href={`/leaderboard/${data.address}?tab=${role}`} passHref>
<Link href={`/leaderboard/${data.address}?role=${role}`} passHref>
<a
className={clsx(
styles.LeaderboardRow,
Expand Down
2 changes: 1 addition & 1 deletion src/components/statistics/StatisticsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export default function StatisticsPage(props: StatisticsProps) {
activeKey='stats'
onChange={key => {
if (key === 'general') router.push('/leaderboard')
else if (key === 'user') router.push(`/leaderboard/${myAddress}?tab=staker`)
else if (key === 'user') router.push(`/leaderboard/${myAddress}?role=staker`)
}}
>
{myAddress && <Tabs.TabPane tab='My Staking Stats' key='user' />}
Expand Down

0 comments on commit f31a853

Please sign in to comment.