This commit is contained in:
parent
b86fb3a609
commit
e2d9a23974
@ -20,7 +20,7 @@ type Props = {
|
||||
beatSaverMap?: BeatSaverMap;
|
||||
alwaysSingleLine?: boolean;
|
||||
setIsLeaderboardExpanded?: (isExpanded: boolean) => void;
|
||||
setScore?: (score: ScoreSaberScoreToken) => void;
|
||||
updateScore?: (score: ScoreSaberScoreToken) => void;
|
||||
};
|
||||
|
||||
export default function ScoreButtons({
|
||||
@ -29,7 +29,7 @@ export default function ScoreButtons({
|
||||
beatSaverMap,
|
||||
alwaysSingleLine,
|
||||
setIsLeaderboardExpanded,
|
||||
setScore,
|
||||
updateScore,
|
||||
}: Props) {
|
||||
const [leaderboardExpanded, setLeaderboardExpanded] = useState(false);
|
||||
const { toast } = useToast();
|
||||
@ -84,8 +84,8 @@ export default function ScoreButtons({
|
||||
className={`flex gap-2 ${alwaysSingleLine ? "flex-row" : "flex-row lg:flex-col"} items-center justify-center`}
|
||||
>
|
||||
{/* Edit score button */}
|
||||
{score && leaderboard && setScore && (
|
||||
<ScoreEditorButton score={score} leaderboard={leaderboard} setScore={setScore} />
|
||||
{score && leaderboard && updateScore && (
|
||||
<ScoreEditorButton score={score} leaderboard={leaderboard} updateScore={updateScore} />
|
||||
)}
|
||||
|
||||
{/* View Leaderboard button */}
|
||||
|
@ -12,10 +12,10 @@ import Tooltip from "@/components/tooltip";
|
||||
type ScoreEditorButtonProps = {
|
||||
score: ScoreSaberScoreToken;
|
||||
leaderboard: ScoreSaberLeaderboardToken;
|
||||
setScore: (score: ScoreSaberScoreToken) => void;
|
||||
updateScore: (score: ScoreSaberScoreToken) => void;
|
||||
};
|
||||
|
||||
export default function ScoreEditorButton({ score, leaderboard, setScore }: ScoreEditorButtonProps) {
|
||||
export default function ScoreEditorButton({ score, leaderboard, updateScore }: ScoreEditorButtonProps) {
|
||||
const [isScoreEditMode, setIsScoreEditMode] = useState(false);
|
||||
|
||||
const maxScore = leaderboard.maxScore || 1; // Use 1 to prevent division by zero
|
||||
@ -24,14 +24,14 @@ export default function ScoreEditorButton({ score, leaderboard, setScore }: Scor
|
||||
const handleSliderChange = (value: number[]) => {
|
||||
const newAccuracy = Math.max(0, Math.min(value[0], 100)); // Ensure the accuracy stays within 0-100
|
||||
const newBaseScore = (newAccuracy / 100) * maxScore;
|
||||
setScore({
|
||||
updateScore({
|
||||
...score,
|
||||
baseScore: newBaseScore,
|
||||
});
|
||||
};
|
||||
|
||||
const handleSliderReset = () => {
|
||||
setScore({
|
||||
updateScore({
|
||||
...score,
|
||||
baseScore: (accuracy / 100) * maxScore,
|
||||
});
|
||||
|
@ -60,7 +60,7 @@ export default function Score({ player, playerScore }: Props) {
|
||||
beatSaverMap={beatSaverMap}
|
||||
score={score}
|
||||
setIsLeaderboardExpanded={setIsLeaderboardExpanded}
|
||||
setScore={score => {
|
||||
updateScore={score => {
|
||||
setBaseScore(score.baseScore);
|
||||
}}
|
||||
/>
|
||||
|
Reference in New Issue
Block a user