Skip to content

Commit

Permalink
Refactor TopVoters component to use Next.js Link for voter profiles
Browse files Browse the repository at this point in the history
  • Loading branch information
chimpdev committed May 26, 2024
1 parent 46f368f commit e448534
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
8 changes: 5 additions & 3 deletions client/app/(bots)/bots/[id]/components/Tabs/TopVoters.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import Image from 'next/image';
import { TbSquareRoundedChevronUp } from 'react-icons/tb';
import fetchVoters from '@/lib/request/bots/fetchVoters';
import { toast } from 'sonner';
import Link from 'next/link';

export default function TopVoters({ bot }) {
const [loading, setLoading] = useState(false);
Expand Down Expand Up @@ -51,10 +52,11 @@ export default function TopVoters({ bot }) {
) : (
<div className='grid w-full grid-cols-1 mt-4' key='voters'>
{voters.map((voter, index) => (
<div
<Link
href={`/profile/u/${voter.id}`}
key={voter.id}
className={cn(
'flex items-center w-full gap-4 p-4 odd:bg-secondary even:bg-tertiary',
'flex items-center w-full gap-4 p-4 odd:bg-secondary even:bg-tertiary hover:opacity-70 transition-opacity',
index === 0 && 'rounded-t-xl',
index === voters.length - 1 && 'rounded-b-xl',
page === 1 && voters.length > 3 && voters.indexOf(voter) === 0 && 'border-x-2 border-t-2 border-yellow-500 odd:bg-yellow-500/10',
Expand Down Expand Up @@ -90,7 +92,7 @@ export default function TopVoters({ bot }) {
{voter.votes}
<TbSquareRoundedChevronUp />
</div>
</div>
</Link>
))}
</div>
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import Image from 'next/image';
import { TbSquareRoundedChevronUp } from 'react-icons/tb';
import fetchVoters from '@/lib/request/servers/fetchVoters';
import { toast } from 'sonner';
import Link from 'next/link';

export default function TopVoters({ server }) {
const [loading, setLoading] = useState(false);
Expand Down Expand Up @@ -51,10 +52,11 @@ export default function TopVoters({ server }) {
) : (
<div className='grid w-full grid-cols-1 mt-4' key='voters'>
{voters.map((voter, index) => (
<div
<Link
href={`/profile/u/${voter.id}`}
key={voter.id}
className={cn(
'flex items-center w-full gap-4 p-4 odd:bg-secondary even:bg-tertiary',
'flex items-center w-full gap-4 p-4 odd:bg-secondary even:bg-tertiary hover:opacity-70 transition-opacity',
index === 0 && 'rounded-t-xl',
index === voters.length - 1 && 'rounded-b-xl',
page === 1 && voters.length > 3 && voters.indexOf(voter) === 0 && 'border-x-2 border-t-2 border-yellow-500 odd:bg-yellow-500/10',
Expand Down Expand Up @@ -90,7 +92,7 @@ export default function TopVoters({ server }) {
{voter.votes}
<TbSquareRoundedChevronUp />
</div>
</div>
</Link>
))}
</div>
)}
Expand Down

0 comments on commit e448534

Please sign in to comment.