Skip to content

Commit

Permalink
#167 Refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
tomaszdworniczak committed Apr 15, 2021
1 parent 23f2249 commit a3d9556
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 8 deletions.
2 changes: 1 addition & 1 deletion frontend/src/components/atoms/constants/routerPaths.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ export const PATH_FOR_TOURNAMENT_REGISTRATIONS_VIEW : string = "/tournament-reg
export const PATH_FOR_PLAYERS_PROFILES_VIEW : string = "/players-profiles";
export const PATH_FOR_PLAYER_PROFILE_CREATION_VIEW : string = "/new-player-profiles";
export const PATH_FOR_PLAYER_MATCHES_VIEW : string = "/tournament/:tournamentId/matches";
export const PATH_FOR_MATCHES_AND_RESULTS : string = "/tournament/matches-and-results";
export const PATH_FOR_MATCHES_AND_RESULTS : string = "/tournament/:tournamentId/matches-and-results";

Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {Alert, AlertTitle} from "@material-ui/lab";
import {Centered} from "../../atoms/Shared/Centered";
import EmojiEventsIcon from '@material-ui/icons/EmojiEvents';
import {Box, Tabs, Typography} from "@material-ui/core";
import {MatchesList} from "../../organisms/MatchesList/MatchesList";

const useStyles = makeStyles((theme: Theme) => ({
root: {
Expand All @@ -21,7 +22,11 @@ const useStyles = makeStyles((theme: Theme) => ({
}
}));

export default function LabTabs() {
type LabTabsProps = {
readonly tournamentId: string;
}

export default function MatchesAndResultsTabs(props: LabTabsProps) {
const classes = useStyles();
const [value, setValue] = React.useState('1');

Expand All @@ -40,7 +45,9 @@ export default function LabTabs() {
</TabList>
</Centered>
</AppBar>
<TabPanel value="1">Mecze</TabPanel>
<TabPanel value="1">
<MatchesList tournamentId={props.tournamentId}/>
</TabPanel>
<TabPanel value="2">
<Alert severity="info">
<AlertTitle><strong>Turniej w trakcie</strong></AlertTitle>
Expand All @@ -53,6 +60,7 @@ export default function LabTabs() {
<Typography variant={"h5"} component={"h5"}>Zwycięzca</Typography>
<Box>
<Tabs
value={0}
orientation="vertical"
variant="scrollable"
aria-label="Vertical tabs example"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {makeStyles} from "@material-ui/core/styles";
import {useHistory} from "react-router-dom";
import {Centered} from "../../atoms/Shared/Centered";
import {VerticalSpace} from "../../atoms/Shared/VerticalSpace";
import LabTabs from "../../molecules/LabTabs/LabTabs";
import MatchesAndResultsTabs from "../../molecules/LabTabs/MatchesAndResultsTabs";
import {MIN_CARD_COMPONENT_WIDTH} from "../../atoms/constants/sizes";

export const MatchesAndResults = (props: { tournamentId: string }) => {
Expand All @@ -23,6 +23,7 @@ export const MatchesAndResults = (props: { tournamentId: string }) => {
card: {
minWidth: MIN_CARD_COMPONENT_WIDTH,
width: MIN_CARD_COMPONENT_WIDTH,
padding: 0,
},
}));
const classes = useStyles();
Expand All @@ -45,7 +46,7 @@ export const MatchesAndResults = (props: { tournamentId: string }) => {
</Box>
<VerticalSpace height={30}/>
<Box>
<LabTabs/>
<MatchesAndResultsTabs tournamentId={props.tournamentId}/>
</Box>
</Centered>
</CardContent>
Expand Down
19 changes: 19 additions & 0 deletions frontend/src/components/pages/Routes/MatchesAndResultsRoute.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import {useRouteMatch} from "react-router-dom";
import React from "react";
import {PATH_FOR_MATCHES_AND_RESULTS} from "../../atoms/constants/routerPaths";
import {MatchesAndResults} from "../MatchesAndResults/MatchesAndResults";

export interface MatchesAndResultsRouteParams {
readonly tournamentId: string;
}

export const MatchesAndResultsRoute = () => {
const match = useRouteMatch<MatchesAndResultsRouteParams>(
PATH_FOR_MATCHES_AND_RESULTS
);
const tournamentId = match?.params.tournamentId;
if (!tournamentId) {
return null;
}
return <MatchesAndResults tournamentId={tournamentId} />;
};
7 changes: 4 additions & 3 deletions frontend/src/components/pages/TourDeFoos/TourDeFoos.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ import {StyledBackground} from "../../atoms/Background/StyledBackground";
import {
PATH_FOR_CREATING_NEW_TOURNAMENT_VIEW,
PATH_FOR_HOME_VIEW,
PATH_FOR_LOGIN_VIEW, PATH_FOR_MATCHES_AND_RESULTS,
PATH_FOR_LOGIN_VIEW,
PATH_FOR_MATCHES_AND_RESULTS,
PATH_FOR_PLAYER_MATCHES_VIEW,
PATH_FOR_PLAYER_PROFILE_CREATION_VIEW,
PATH_FOR_PLAYERS_PROFILES_VIEW,
Expand All @@ -21,7 +22,7 @@ import {
} from "../../atoms/constants/routerPaths";
import {MatchesListRoute} from "../Routes/MatchesListRoutes";
import TournamentsList from "../TournamentsList/TournamentsList";
import {MatchesAndResults} from "../MatchesAndResults/MatchesAndResults";
import {MatchesAndResultsRoute} from "../Routes/MatchesAndResultsRoute";

function TourDeFoos() {
return (
Expand Down Expand Up @@ -68,7 +69,7 @@ function TourDeFoos() {
</Centered>
</Route>
<Route path={PATH_FOR_MATCHES_AND_RESULTS} exact>
<MatchesAndResults tournamentId={'asd'}/>
<MatchesAndResultsRoute/>
</Route>

<Route path={PATH_FOR_HOME_VIEW} exact>
Expand Down

0 comments on commit a3d9556

Please sign in to comment.