Skip to content
This repository was archived by the owner on Aug 8, 2019. It is now read-only.

Commit 660227a

Browse files
author
condef5
committed
Get favorite clubs
1 parent 57ba71d commit 660227a

4 files changed

Lines changed: 118 additions & 30 deletions

File tree

client/src/components/navbar.js

Lines changed: 68 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,80 @@
11
/** @jsx jsx */
2+
import React from "react";
23
import { jsx } from "@emotion/core";
34
import { Link } from "@reach/router";
45

56
function Navbar() {
7+
const styleMenu = {
8+
textDecoration: "none",
9+
color: "inherit",
10+
padding: "15px",
11+
borderRight: "1px solid #ddd",
12+
flex: "auto",
13+
":last-child": {
14+
border: "none"
15+
}
16+
};
17+
618
return (
7-
<nav
8-
css={{
9-
background: "#fff",
10-
borderBottom: "1px solid #e5edef",
11-
padding: "15px",
12-
marginBottom: "2em"
13-
}}
14-
>
15-
<div
19+
<>
20+
<nav
1621
css={{
17-
maxWidth: "900px",
18-
margin: "auto"
22+
background: "#fff",
23+
borderBottom: "1px solid #e5edef",
24+
padding: "15px",
25+
marginBottom: "2em",
26+
flex: 1
1927
}}
2028
>
21-
<Link to="/" css={{ textDecoration: "none" }}>
22-
<h2
23-
css={{
24-
textDecoration: "none",
25-
margin: "0",
26-
fontSize: "35px",
27-
fontWeight: "500",
28-
backgroundImage:
29-
"-webkit-gradient(linear, 0% 0%, 25% 100%,from(#c5e9a1), to(#00b7c6))",
30-
WebkitBackgroundClip: "text",
31-
WebkitTextFillColor: "transparent"
32-
}}
33-
>
34-
Kampu
35-
</h2>
36-
</Link>
37-
</div>
38-
</nav>
29+
<div
30+
css={{
31+
maxWidth: "900px",
32+
margin: "auto"
33+
}}
34+
>
35+
<Link to="/" css={{ textDecoration: "none" }}>
36+
<h2
37+
css={{
38+
textDecoration: "none",
39+
margin: "0",
40+
fontSize: "35px",
41+
fontWeight: "500",
42+
backgroundImage:
43+
"-webkit-gradient(linear, 0% 0%, 25% 100%,from(#c5e9a1), to(#00b7c6))",
44+
WebkitBackgroundClip: "text",
45+
WebkitTextFillColor: "transparent"
46+
}}
47+
>
48+
Kampu
49+
</h2>
50+
</Link>
51+
</div>
52+
<div
53+
css={{
54+
position: "fixed",
55+
display: "flex",
56+
bottom: "1px",
57+
background: "#fff",
58+
border: "1px solid #ddd",
59+
right: "0",
60+
left: "0",
61+
alignItems: "center",
62+
justifyContent: "space-around",
63+
textAlign: "center"
64+
}}
65+
>
66+
<Link to="/" css={styleMenu}>
67+
Home
68+
</Link>
69+
<Link to="/favorites" css={styleMenu}>
70+
Heart
71+
</Link>
72+
<Link to="/" css={styleMenu}>
73+
Profile
74+
</Link>
75+
</div>
76+
</nav>
77+
</>
3978
);
4079
}
4180

client/src/index.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import OwnerHome from "./views/owner-home";
1414
import CreateClub from "./views/create-club";
1515
import CreateSportField from "./views/create-sport-field";
1616
import OwnerSportField from "./views/owner-sport-field";
17+
import Favorites from "./views/favorites";
1718
import Navbar from "./components/navbar";
1819
import { register } from "./service-worker";
1920

@@ -26,6 +27,7 @@ function App() {
2627
maxWidth: "900px",
2728
margin: "0 auto",
2829
boxSizing: "border-box",
30+
marginBottom: "80px",
2931
"@media (max-width: 720px)": {
3032
padding: "0px 15px"
3133
}
@@ -48,7 +50,11 @@ function App() {
4850
<OwnerHome path="/owner" />
4951
<CreateClub path="/create-club" />
5052
<CreateSportField path="/create-sport-field" />
53+
<<<<<<< HEAD
5154
<OwnerSportField path="/owner-sport-field/:id" />
55+
=======
56+
<Favorites path="/favorites" />
57+
>>>>>>> Get favorite clubs
5258
</Router>
5359
</main>
5460
</>

client/src/services/club.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,15 @@ async function getClubs() {
2626
return response.json();
2727
}
2828

29+
async function getFavoriteClubs() {
30+
const response = await fetch(`${apiUrl}/clubs`, {
31+
credentials: "include"
32+
});
33+
34+
if (!response.ok) throw new Error(response.statusText);
35+
return response.json();
36+
}
37+
2938
async function favorite(clubId) {
3039
const response = await fetch(`${apiUrl}/clubs/${clubId}/favorites`, {
3140
credentials: "include",
@@ -48,4 +57,4 @@ async function unfavorite(clubId) {
4857
return response.json();
4958
}
5059

51-
export { getClubs, postClub, favorite, unfavorite };
60+
export { getClubs, postClub, favorite, unfavorite, getFavoriteClubs };

client/src/views/favorites.js

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/** @jsx jsx */
2+
import React from "react";
3+
import { jsx } from "@emotion/core";
4+
import { getFavoriteClubs } from "../services/club";
5+
import { useClubs } from "../selectors/selectors";
6+
import { useSetClubs } from "../actions/action-hooks";
7+
import Club from "../components/club";
8+
9+
function Home() {
10+
const [loading, setLoading] = React.useState(false);
11+
const [clubs, setClubs] = React.useState([]);
12+
// const setClubs = useSetClubs();
13+
14+
React.useEffect(() => {
15+
setLoading(true);
16+
getFavoriteClubs().then(clubs => {
17+
console.log(clubs);
18+
setClubs(clubs);
19+
setLoading(false);
20+
});
21+
}, []);
22+
23+
return (
24+
<div>
25+
<h2>Favorites Clubs</h2>
26+
{loading && <div>Loading</div>}
27+
{clubs.map(club => (
28+
<Club club={club} key={club.id} />
29+
))}
30+
</div>
31+
);
32+
}
33+
34+
export default Home;

0 commit comments

Comments
 (0)