Skip to content

Commit

Permalink
releasef fix default bracket
Browse files Browse the repository at this point in the history
  • Loading branch information
Sammers21 committed Sep 19, 2024
1 parent 50a56f3 commit 283611e
Show file tree
Hide file tree
Showing 3 changed files with 103 additions and 104 deletions.
1 change: 0 additions & 1 deletion frontend/src/components/DataTable/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import { getLadder } from '@/services/stats.service';
import {getActivityFromUrl, getBracket, getRegion} from '@/utils/urlparts';

import { BRACKETS } from '@/constants/pvp-activity';
import { REGION } from '@/constants/region';
import type { IActivityRecord } from '@/types';

export function getFromSearchParams(searchParams: URLSearchParams, name: string): string[] {
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/components/Header/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { borderColor, containerBg } from "@/theme";
import { metaUrls, publicUrls, shuffleMulticlassUrls } from "@/config";
import { REGION } from "@/constants/region";
import { BRACKETS } from "@/constants/pvp-activity";
import {getActivityFromUrl, getRegion} from "@/utils/urlparts";
import {getActivityFromUrl, getBracket, getRegion} from "@/utils/urlparts";

const StyledAppBar = styled(AppBar)({
backgroundImage: "none",
Expand All @@ -33,7 +33,7 @@ const Header = () => {
const host = window.location.host.toUpperCase();
const {
region: regionFromUrl = REGION.eu,
bracket = BRACKETS["3v3"],
bracket = getBracket(),
} = useParams();
const region = getRegion(regionFromUrl);
const activity = getActivityFromUrl();
Expand Down
202 changes: 101 additions & 101 deletions frontend/src/containers/Activity/Tabs.tsx
Original file line number Diff line number Diff line change
@@ -1,101 +1,101 @@
import {useNavigate, useLocation, useParams} from 'react-router-dom';
import {generatePath} from 'react-router';

import {Button, Chip} from '@mui/material';
import {styled} from '@mui/system';

import {getActivityFromUrl, getBracket, getRegion} from '@/utils/urlparts';
import {publicUrls} from '@/config';
import {BRACKETS} from '@/constants/pvp-activity';
import {borderColor} from '@/theme';

interface IProps {
bracketActivity: Record<BRACKETS, string> | undefined;
}

export const TabButton = styled(Button)<{ isActive: boolean }>(({isActive}) => {
return {
color: 'white',
flexGrow: 1,
borderRadius: 0,
borderColor: borderColor,
borderRightWidth: 1,
borderStyle: 'solid',
textTransform: 'none',
fontSize: 16,
fontWeight: 1000,
backgroundColor: isActive ? 'rgb(21, 128, 61, 0.25)' : 'rgba(31, 41, 55, 0.25)',
'&:hover': {
backgroundColor: isActive && 'rgb(21, 128, 61, 0.25)',
},
};
});

export const BracketCount = ({content}: { content: number | string | undefined }) => {
if (!content) return null;

return (
<div className="flex items-center justify-between ml-2">
<Chip className="!text-sm" label={content} size="small"/>
</div>
);
};

const ActivityTabs = ({bracketActivity}: IProps) => {
let navigate = useNavigate();
const location = useLocation();

const {region: regionFromUrl, bracket: bracketFromParams} = useParams();

const bracket = getBracket(bracketFromParams);
const activity = getActivityFromUrl();
const region = getRegion(regionFromUrl);

const handleBracketChange = (bracket: BRACKETS) => {
const newPath = generatePath(publicUrls.page, {region, activity, bracket});
navigate(`${newPath}${location.search}`);
};

return (
<div className="flex w-full rounded-t-md border-t border-l border-b border-solid border-[#2f384de6] bg-[#030303e6]">
<TabButton
sx={{borderTopLeftRadius: 5}}
onClick={() => handleBracketChange(BRACKETS.shuffle)}
isActive={bracket === BRACKETS.shuffle}
>
Shuffle
<BracketCount content={bracketActivity?.shuffle}/>
</TabButton>
<TabButton
onClick={() => handleBracketChange(BRACKETS['2v2'])}
isActive={bracket === BRACKETS['2v2']}
>
2v2
<BracketCount content={bracketActivity?.['2v2']}/>
</TabButton>
<TabButton
onClick={() => handleBracketChange(BRACKETS['3v3'])}
isActive={bracket === BRACKETS['3v3']}
>
3v3 <BracketCount content={bracketActivity?.['3v3']}/>
</TabButton>
<TabButton
sx={{}}
onClick={() => handleBracketChange(BRACKETS.blitz)}
isActive={bracket === BRACKETS.blitz}
>
Blitz
<BracketCount content={bracketActivity?.blitz}/>
</TabButton>
<TabButton
sx={{}}
onClick={() => handleBracketChange(BRACKETS.rbg)}
isActive={bracket === BRACKETS.rbg}
>
RBG <BracketCount content={bracketActivity?.rbg}/>
</TabButton>
</div>
);
};

export default ActivityTabs;
import {useNavigate, useLocation, useParams} from 'react-router-dom';
import {generatePath} from 'react-router';

import {Button, Chip} from '@mui/material';
import {styled} from '@mui/system';

import {getActivityFromUrl, getBracket, getRegion} from '@/utils/urlparts';
import {publicUrls} from '@/config';
import {BRACKETS} from '@/constants/pvp-activity';
import {borderColor} from '@/theme';

interface IProps {
bracketActivity: Record<BRACKETS, string> | undefined;
}

export const TabButton = styled(Button)<{ isActive: boolean }>(({isActive}) => {
return {
color: 'white',
flexGrow: 1,
borderRadius: 0,
borderColor: borderColor,
borderRightWidth: 1,
borderStyle: 'solid',
textTransform: 'none',
fontSize: 16,
fontWeight: 1000,
backgroundColor: isActive ? 'rgb(21, 128, 61, 0.25)' : 'rgba(31, 41, 55, 0.25)',
'&:hover': {
backgroundColor: isActive && 'rgb(21, 128, 61, 0.25)',
},
};
});

export const BracketCount = ({content}: { content: number | string | undefined }) => {
if (!content) return null;

return (
<div className="flex items-center justify-between ml-2">
<Chip className="!text-sm" label={content} size="small"/>
</div>
);
};

const ActivityTabs = ({bracketActivity}: IProps) => {
let navigate = useNavigate();
const location = useLocation();

const {region: regionFromUrl, bracket: bracketFromParams} = useParams();

const bracket = getBracket(bracketFromParams);
const activity = getActivityFromUrl();
const region = getRegion(regionFromUrl);

const handleBracketChange = (bracket: BRACKETS) => {
const newPath = generatePath(publicUrls.page, {region, activity, bracket});
navigate(`${newPath}${location.search}`);
};

return (
<div className="flex w-full rounded-t-md border-t border-l border-b border-solid border-[#2f384de6] bg-[#030303e6]">
<TabButton
sx={{borderTopLeftRadius: 5}}
onClick={() => handleBracketChange(BRACKETS.shuffle)}
isActive={bracket === BRACKETS.shuffle}
>
Shuffle
<BracketCount content={bracketActivity?.shuffle}/>
</TabButton>
<TabButton
onClick={() => handleBracketChange(BRACKETS['2v2'])}
isActive={bracket === BRACKETS['2v2']}
>
2v2
<BracketCount content={bracketActivity?.['2v2']}/>
</TabButton>
<TabButton
onClick={() => handleBracketChange(BRACKETS['3v3'])}
isActive={bracket === BRACKETS['3v3']}
>
3v3 <BracketCount content={bracketActivity?.['3v3']}/>
</TabButton>
<TabButton
sx={{}}
onClick={() => handleBracketChange(BRACKETS.blitz)}
isActive={bracket === BRACKETS.blitz}
>
Blitz
<BracketCount content={bracketActivity?.blitz}/>
</TabButton>
<TabButton
sx={{}}
onClick={() => handleBracketChange(BRACKETS.rbg)}
isActive={bracket === BRACKETS.rbg}
>
RBG <BracketCount content={bracketActivity?.rbg}/>
</TabButton>
</div>
);
};

export default ActivityTabs;

0 comments on commit 283611e

Please sign in to comment.