Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor TopVoters component to use Next.js Link for voter profiles #24

Merged
merged 1 commit into from
May 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading