Skip to content

Commit

Permalink
#167 tournament result rest api
Browse files Browse the repository at this point in the history
  • Loading branch information
tomaszdworniczak committed Apr 15, 2021
1 parent a3d9556 commit 5197bbf
Show file tree
Hide file tree
Showing 3 changed files with 86 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,28 +49,7 @@ export default function MatchesAndResultsTabs(props: LabTabsProps) {
<MatchesList tournamentId={props.tournamentId}/>
</TabPanel>
<TabPanel value="2">
<Alert severity="info">
<AlertTitle><strong>Turniej w trakcie</strong></AlertTitle>
Wyniki będą dostępne po zakończeniu wszystkich meczy
</Alert>

<div style={{display: "flex", justifyContent: "center"}}>
<Centered>
<EmojiEventsIcon color={"primary"} style={{fontSize: '3rem'}}/>
<Typography variant={"h5"} component={"h5"}>Zwycięzca</Typography>
<Box>
<Tabs
value={0}
orientation="vertical"
variant="scrollable"
aria-label="Vertical tabs example"
>
<Tab label="Gracz1"/>
<Tab label="Gracz2"/>
</Tabs>
</Box>
</Centered>
</div>
</TabPanel>
</TabContext>
</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
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 Tab from "@material-ui/core/Tab";
import React, {useState} from "react";

function TournamentsResults() {
const [tournamentStatus, setTournamentStatus] = useState(undefined);

useEffect(() => {
return () => {
effect
};
}, [input]);


return (
<>
<Alert severity="info">
<AlertTitle><strong>Turniej w trakcie</strong></AlertTitle>
Wyniki będą dostępne po zakończeniu wszystkich meczy
</Alert>

<div style={{display: "flex", justifyContent: "center"}}>
<Centered>
<EmojiEventsIcon color={"primary"} style={{fontSize: '3rem'}}/>
<Typography variant={"h5"} component={"h5"}>Zwycięzca</Typography>
<Box>
<Tabs
value={0}
orientation="vertical"
variant="scrollable"
aria-label="Vertical tabs example"
>
<Tab label="Gracz1"/>
<Tab label="Gracz2"/>
</Tabs>
</Box>
</Centered>
</div>
</>
);
}

export default TournamentsResults;
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import axios from "axios";
import { PATH_BASE_URL } from "../../components/atoms/constants/apiPaths";
import { MatchDetailsDto } from "./MatchDetailsDto";

export type DoublesTournamentRestApiConfig = {
readonly baseUrl: string;
};

const defaultConfig: DoublesTournamentRestApiConfig = {
baseUrl: PATH_BASE_URL,
};

export const MatchDetailsRestAPI = (
config?: Partial<DoublesTournamentRestApiConfig>
) => {
const currentConfig = {
...defaultConfig,
config,
baseUrl:
process.env.REACT_APP_REST_API_BASE_URL ??
config?.baseUrl ??
defaultConfig.baseUrl,
};
return {
getTournamentMatch(matchId: string): Promise<MatchDetailsDto> {
return axios
.get<MatchDetailsDto>(`${currentConfig.baseUrl}/matches/${matchId}`)
.then((res) => res.data)
},

async postMatchWinner(
matchId: string,
winnerPlayerId: string
): Promise<void> {
await axios.post(`${currentConfig.baseUrl}/matches/${matchId}/result`, {
winnerId: winnerPlayerId,
});
},
};
};

0 comments on commit 5197bbf

Please sign in to comment.