mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-30 05:59:51 +01:00
feat: jump to league
This commit is contained in:
1 parent
8d2679c458
commit
57527115d4
3 files changed
+39
-24
No files matched your search
@@ -5,14 +5,7 @@ import {
|
|||||||
CaretRightIcon,
|
CaretRightIcon,
|
||||||
MagnifyingGlassIcon,
|
MagnifyingGlassIcon,
|
||||||
} from '@radix-ui/react-icons';
|
} from '@radix-ui/react-icons';
|
||||||
import {
|
import { Button, Dialog, Flex, Select, TextField } from '@radix-ui/themes';
|
||||||
Button,
|
|
||||||
Dialog,
|
|
||||||
Flex,
|
|
||||||
Popover,
|
|
||||||
Select,
|
|
||||||
TextField,
|
|
||||||
} from '@radix-ui/themes';
|
|
||||||
import { produce } from 'immer';
|
import { produce } from 'immer';
|
||||||
import { debounce, range } from 'lodash';
|
import { debounce, range } from 'lodash';
|
||||||
import { ChangeEvent, useEffect, useRef, useState } from 'react';
|
import { ChangeEvent, useEffect, useRef, useState } from 'react';
|
||||||
@@ -20,6 +13,7 @@ import useSWR from 'swr';
|
|||||||
import { create } from 'zustand';
|
import { create } from 'zustand';
|
||||||
import * as Leaderboard from '../../../components/Leaderboard';
|
import * as Leaderboard from '../../../components/Leaderboard';
|
||||||
import PageWrapper from '../../../components/PageWrapper';
|
import PageWrapper from '../../../components/PageWrapper';
|
||||||
|
import { LEAGUES } from '../../../constants/leagues';
|
||||||
import { FIRST_ARCHIVED_RATINGS_SEASON } from '../../../constants/ratings';
|
import { FIRST_ARCHIVED_RATINGS_SEASON } from '../../../constants/ratings';
|
||||||
import { REGIONS, REGION_NAMES, Region } from '../../../constants/regions';
|
import { REGIONS, REGION_NAMES, Region } from '../../../constants/regions';
|
||||||
import { WARGAMING_APPLICATION_ID } from '../../../constants/wargamingApplicationID';
|
import { WARGAMING_APPLICATION_ID } from '../../../constants/wargamingApplicationID';
|
||||||
@@ -318,12 +312,12 @@ export default function Page() {
|
|||||||
</Dialog.Content>
|
</Dialog.Content>
|
||||||
</Dialog.Root>
|
</Dialog.Root>
|
||||||
|
|
||||||
<Popover.Root>
|
<Dialog.Root>
|
||||||
<Popover.Trigger>
|
<Dialog.Trigger>
|
||||||
<Button variant="soft">Jump to league...</Button>
|
<Button variant="soft">Jump to league...</Button>
|
||||||
</Popover.Trigger>
|
</Dialog.Trigger>
|
||||||
|
|
||||||
<Popover.Content>
|
<Dialog.Content>
|
||||||
<Flex direction="column" gap="2">
|
<Flex direction="column" gap="2">
|
||||||
<Select.Root
|
<Select.Root
|
||||||
value={`${jumpToLeague}`}
|
value={`${jumpToLeague}`}
|
||||||
@@ -342,13 +336,34 @@ export default function Page() {
|
|||||||
</Select.Root>
|
</Select.Root>
|
||||||
|
|
||||||
<Flex gap="2">
|
<Flex gap="2">
|
||||||
<Popover.Close>
|
<Dialog.Close>
|
||||||
<Button color="red">Cancel</Button>
|
<Button color="red">Cancel</Button>
|
||||||
</Popover.Close>
|
</Dialog.Close>
|
||||||
|
<Dialog.Close>
|
||||||
|
<Button
|
||||||
|
onClick={() => {
|
||||||
|
if (!ratingsInfo || ratingsInfo.detail || !players.data)
|
||||||
|
return;
|
||||||
|
|
||||||
|
const minScore =
|
||||||
|
LEAGUES[jumpToLeague - 1]?.minScore ?? Infinity;
|
||||||
|
const firstPlayerIndex = players.data.findIndex(
|
||||||
|
(player) => player.score < minScore,
|
||||||
|
);
|
||||||
|
|
||||||
|
if (firstPlayerIndex === -1) return;
|
||||||
|
|
||||||
|
setPage(Math.floor(firstPlayerIndex / rowsPerPage));
|
||||||
|
setHighlightedPlayerId(players.data[firstPlayerIndex].id);
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
Jump
|
||||||
|
</Button>
|
||||||
|
</Dialog.Close>
|
||||||
</Flex>
|
</Flex>
|
||||||
</Flex>
|
</Flex>
|
||||||
</Popover.Content>
|
</Dialog.Content>
|
||||||
</Popover.Root>
|
</Dialog.Root>
|
||||||
|
|
||||||
<Dialog.Root>
|
<Dialog.Root>
|
||||||
<Dialog.Trigger>
|
<Dialog.Trigger>
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import { BlitzkriegRatingsLeaderboard } from '../../scripts/buildRatingsLeaderbo
|
|||||||
import * as Leaderboard from '../components/Leaderboard';
|
import * as Leaderboard from '../components/Leaderboard';
|
||||||
import TitleBar from '../components/TitleBar';
|
import TitleBar from '../components/TitleBar';
|
||||||
import Wrapper from '../components/Wrapper';
|
import Wrapper from '../components/Wrapper';
|
||||||
|
import { LEAGUES } from '../constants/leagues';
|
||||||
import { FIRST_ARCHIVED_RATINGS_SEASON } from '../constants/ratings';
|
import { FIRST_ARCHIVED_RATINGS_SEASON } from '../constants/ratings';
|
||||||
import { REGION_NAMES_SHORT, Region } from '../constants/regions';
|
import { REGION_NAMES_SHORT, Region } from '../constants/regions';
|
||||||
import { getAccountInfo } from '../core/blitz/getAccountInfo';
|
import { getAccountInfo } from '../core/blitz/getAccountInfo';
|
||||||
@@ -114,14 +115,6 @@ export interface RatingsNeighbors {
|
|||||||
neighbors: RatingsPlayer[];
|
neighbors: RatingsPlayer[];
|
||||||
}
|
}
|
||||||
|
|
||||||
const LEAGUES = [
|
|
||||||
{ name: 'Diamond', minScore: 5000 },
|
|
||||||
{ name: 'Platinum', minScore: 4000 },
|
|
||||||
{ name: 'Gold', minScore: 3000 },
|
|
||||||
{ name: 'Silver', minScore: 2000 },
|
|
||||||
{ name: 'Bronze', minScore: 0 },
|
|
||||||
];
|
|
||||||
|
|
||||||
function addSubcommands(
|
function addSubcommands(
|
||||||
option: SlashCommandSubcommandGroupBuilder,
|
option: SlashCommandSubcommandGroupBuilder,
|
||||||
addOptions = (option: SlashCommandSubcommandBuilder) => option,
|
addOptions = (option: SlashCommandSubcommandBuilder) => option,
|
||||||
|
|||||||
@@ -0,0 +1,7 @@
|
|||||||
|
export const LEAGUES = [
|
||||||
|
{ name: 'Diamond', minScore: 5000 },
|
||||||
|
{ name: 'Platinum', minScore: 4000 },
|
||||||
|
{ name: 'Gold', minScore: 3000 },
|
||||||
|
{ name: 'Silver', minScore: 2000 },
|
||||||
|
{ name: 'Bronze', minScore: 0 },
|
||||||
|
];
|
||||||
Reference in new issue
Block a user