fix bsr copy

This commit is contained in:
Lee 2024-09-11 23:18:02 +01:00
parent b5df147728
commit fe4532d7cd
2 changed files with 10 additions and 8 deletions

@ -62,10 +62,10 @@ export default function Pagination({ mobilePagination, page, totalPages, onPageC
if (startPage > 1 && !mobilePagination) { if (startPage > 1 && !mobilePagination) {
pageNumbers.push( pageNumbers.push(
<> <>
<PaginationItem key="start"> <PaginationItem key="start" className="cursor-pointer">
<PaginationLink onClick={() => handlePageChange(1)}>1</PaginationLink> <PaginationLink onClick={() => handlePageChange(1)}>1</PaginationLink>
</PaginationItem> </PaginationItem>
<PaginationItem key="ellipsis-start"> <PaginationItem key="ellipsis-start" className="cursor-pointer">
<PaginationEllipsis /> <PaginationEllipsis />
</PaginationItem> </PaginationItem>
</> </>
@ -75,7 +75,7 @@ export default function Pagination({ mobilePagination, page, totalPages, onPageC
// Generate page numbers between startPage and endPage for desktop view // Generate page numbers between startPage and endPage for desktop view
for (let i = startPage; i <= endPage; i++) { for (let i = startPage; i <= endPage; i++) {
pageNumbers.push( pageNumbers.push(
<PaginationItem key={i}> <PaginationItem key={i} className="cursor-pointer">
<PaginationLink isActive={i === currentPage} onClick={() => handlePageChange(i)}> <PaginationLink isActive={i === currentPage} onClick={() => handlePageChange(i)}>
{i} {i}
</PaginationLink> </PaginationLink>
@ -90,7 +90,7 @@ export default function Pagination({ mobilePagination, page, totalPages, onPageC
<ShadCnPagination className="select-none"> <ShadCnPagination className="select-none">
<PaginationContent> <PaginationContent>
{/* Previous button for mobile and desktop */} {/* Previous button for mobile and desktop */}
<PaginationItem> <PaginationItem className="cursor-pointer">
<PaginationPrevious onClick={() => handlePageChange(currentPage - 1)} /> <PaginationPrevious onClick={() => handlePageChange(currentPage - 1)} />
</PaginationItem> </PaginationItem>
@ -100,16 +100,16 @@ export default function Pagination({ mobilePagination, page, totalPages, onPageC
{!mobilePagination && currentPage < totalPages && ( {!mobilePagination && currentPage < totalPages && (
<> <>
<PaginationItem key="ellipsis-end"> <PaginationItem key="ellipsis-end">
<PaginationEllipsis /> <PaginationEllipsis className="cursor-default" />
</PaginationItem> </PaginationItem>
<PaginationItem key="end"> <PaginationItem key="end" className="cursor-pointer">
<PaginationLink onClick={() => handlePageChange(totalPages)}>{totalPages}</PaginationLink> <PaginationLink onClick={() => handlePageChange(totalPages)}>{totalPages}</PaginationLink>
</PaginationItem> </PaginationItem>
</> </>
)} )}
{/* Next button for mobile and desktop */} {/* Next button for mobile and desktop */}
<PaginationItem> <PaginationItem className="cursor-pointer">
<PaginationNext onClick={() => handlePageChange(currentPage + 1)} /> <PaginationNext onClick={() => handlePageChange(currentPage + 1)} />
</PaginationItem> </PaginationItem>
</PaginationContent> </PaginationContent>

@ -1,5 +1,6 @@
"use client"; "use client";
import { copyToClipboard } from "@/common/browser-utils";
import { beatsaverFetcher } from "@/common/data-fetcher/impl/beatsaver"; import { beatsaverFetcher } from "@/common/data-fetcher/impl/beatsaver";
import ScoreSaberPlayerScore from "@/common/data-fetcher/types/scoresaber/scoresaber-player-score"; import ScoreSaberPlayerScore from "@/common/data-fetcher/types/scoresaber/scoresaber-player-score";
import { formatNumberWithCommas } from "@/common/number-utils"; import { formatNumberWithCommas } from "@/common/number-utils";
@ -30,7 +31,7 @@ export default function Score({ playerScore }: Props) {
const bsrFound = await beatsaverFetcher.getMapBsr(leaderboard.songHash); const bsrFound = await beatsaverFetcher.getMapBsr(leaderboard.songHash);
setBsr(bsrFound); setBsr(bsrFound);
})(); })();
}, [playerScore]); }, [playerScore, leaderboard.songHash]);
return ( return (
<div className="grid gap-2 md:gap-0 pb-2 pt-2 first:pt-0 last:pb-0 grid-cols-[20px 1fr_1fr] md:grid-cols-[0.85fr_5fr_1fr_1.2fr]"> <div className="grid gap-2 md:gap-0 pb-2 pt-2 first:pt-0 last:pb-0 grid-cols-[20px 1fr_1fr] md:grid-cols-[0.85fr_5fr_1fr_1.2fr]">
@ -68,6 +69,7 @@ export default function Score({ playerScore }: Props) {
title: "Copied!", title: "Copied!",
description: `Copied "!bsr ${bsr}" to your clipboard!`, description: `Copied "!bsr ${bsr}" to your clipboard!`,
}); });
copyToClipboard(`!bsr ${bsr}`);
}} }}
tooltip={<p>Click to copy the bsr code</p>} tooltip={<p>Click to copy the bsr code</p>}
> >