diff --git a/src/components/MatchFull.tsx b/src/components/MatchFull.tsx
new file mode 100644
index 0000000..015d529
--- /dev/null
+++ b/src/components/MatchFull.tsx
@@ -0,0 +1,22 @@
+import React, { FC } from "react";
+import Moment from "react-moment";
+import { Container, Typography } from "@material-ui/core";
+
+import IGame from "../types/Game";
+
+const MatchFull: FC<{ game: IGame }> = ({ game }) => (
+
+
+ {game.title}
+
+
+ {game.competition.name}
+
+ {game.date}
+
+
+
+
+);
+
+export default MatchFull;
diff --git a/src/pages/Detail.tsx b/src/pages/Detail.tsx
index a1c3d77..c271183 100644
--- a/src/pages/Detail.tsx
+++ b/src/pages/Detail.tsx
@@ -1,18 +1,16 @@
-import React, { FC, useState, useEffect } from "react";
+import React, { FC } from "react";
import { useRouteMatch } from "react-router-dom";
+import { withGame, IGameState } from "../store/GameProvider";
+
import Loader from "../components/Loader";
-// import MatchItem from "../components/MatchItem";
+import MatchFull from "../components/MatchFull";
-const Detail: FC = () => {
- // const [game, setGame] = useState([]);
- const [loading, _] = useState(true);
+const Detail: FC
= ({ loading, selectGameByID }) => {
const { params } = useRouteMatch<{ slug: string }>();
+ const game = selectGameByID(params.slug);
- useEffect(() => {}, []);
- console.log(params.slug);
-
- return loading ? : {/* */}
;
+ return loading ? : ;
};
-export default Detail;
+export default withGame((props: IGameState) => );
diff --git a/src/pages/Index.tsx b/src/pages/Index.tsx
index b55af1c..e9a0a14 100644
--- a/src/pages/Index.tsx
+++ b/src/pages/Index.tsx
@@ -1,12 +1,7 @@
import React, { FC } from "react";
import MatchList from "../components/MatchList";
-import MainLayout from "../layouts/MainLayout";
-const Index: FC = () => (
-
-
-
-);
+const Index: FC = () => ;
export default Index;
diff --git a/src/store/GameProvider.tsx b/src/store/GameProvider.tsx
index 1898ac5..ca414a6 100644
--- a/src/store/GameProvider.tsx
+++ b/src/store/GameProvider.tsx
@@ -8,24 +8,34 @@ export interface IGameState {
games: IGame[];
loading: boolean;
setGames: React.Dispatch>;
+ selectGameByID: (slug: string) => IGame;
}
export const GameContext = createContext({
games: [],
loading: true,
setGames: () => {},
+ selectGameByID: () => {
+ return {} as IGame;
+ },
});
const GameProvider: FC = ({ children }) => {
const [games, setGames] = useState([]);
const [loading, setLoading] = useState(true);
+ const selectGameByID = (slug: string): IGame => {
+ const id = parseInt(slug);
+ const game = games[id];
+ return game;
+ };
+
useEffect(() => {
apiClient
.get("/")
.then(({ data }) => {
- setLoading(false);
setGames(data);
+ setLoading(false);
})
.catch((err) => {
setLoading(false);
@@ -35,7 +45,7 @@ const GameProvider: FC = ({ children }) => {
}, []);
return (
-
+
{children}
);