diff --git a/frontend/src/App.js b/frontend/src/App.js
index 7c5869b..d9dc85e 100644
--- a/frontend/src/App.js
+++ b/frontend/src/App.js
@@ -5,7 +5,7 @@ import Signin from "./components/auth/Signin";
import Signup from "./components/auth/Signup";
import Posts from "./components/Posts";
import Post from "./components/Post";
-
+import Event from "./components/Event";
import Events from "./components/Events";
import Profile from "./components/Profile";
@@ -22,7 +22,7 @@ function App() {
-
+
diff --git a/frontend/src/components/Event.js b/frontend/src/components/Event.js
index e69de29..d36b777 100644
--- a/frontend/src/components/Event.js
+++ b/frontend/src/components/Event.js
@@ -0,0 +1,56 @@
+import React, { useState, useEffect } from "react";
+
+const Event = (props) => {
+ const [state, setState] = useState({
+ user: { username: "HyperionLegion" },
+ event_title: "Green Earth",
+ event_text: "Plant trees with us at 2859258 drive 9 pm EST 3/26/2021",
+ topics: ["climate change", "global warming"],
+ website: "https://joshuahsueh.ml/",
+ });
+ const [stocks, setStocks] = useState([]);
+
+ const requestOptions = {
+ method: "GET",
+ headers: {
+ Authorization: `Bearer ${localStorage.getItem("token")}`,
+ },
+ };
+
+ const callAPI = () => {
+ fetch(`${process.env.REACT_APP_API_ENDPOINT}/event/`, requestOptions)
+ .then((response) => response.json())
+ .then((data) => {
+ if (data !== undefined) {
+ setState(data);
+ }
+ });
+ };
+
+ useEffect(() => {
+ callAPI();
+ }, []);
+ return (
+
+
+ Event {props.match.params.id}
+
+
+
Hello {state.user.username}!
+
Event {state.event_title}
+
{state.event_text}
+
Website
+
Tags:
+ {state.topics.map((topic) => {
+ return (
+
+ );
+ })}
+
+
+ );
+};
+
+export default Event;
diff --git a/frontend/src/components/Events.js b/frontend/src/components/Events.js
index e69de29..cbe0605 100644
--- a/frontend/src/components/Events.js
+++ b/frontend/src/components/Events.js
@@ -0,0 +1,49 @@
+import React, { useState, useEffect } from "react";
+
+const Events = (props) => {
+ const [state, setState] = useState({
+ user: { username: "" },
+ events: [{ id: 1, text: "Green Earth" }],
+ });
+ const [stocks, setStocks] = useState([]);
+
+ const requestOptions = {
+ method: "GET",
+ headers: {
+ Authorization: `Bearer ${localStorage.getItem("token")}`,
+ },
+ };
+
+ const callAPI = () => {
+ fetch(`${process.env.REACT_APP_API_ENDPOINT}/events/`, requestOptions)
+ .then((response) => response.json())
+ .then((data) => {
+ if (data !== undefined) {
+ setState(data);
+ }
+ });
+ };
+
+ useEffect(() => {
+ callAPI();
+ }, []);
+ return (
+
+
Events
+
+
Hello {state.user.username}!
+ {state.events.map((event) => {
+ return (
+
+ );
+ })}
+
+
+ );
+};
+
+export default Events;
diff --git a/frontend/src/components/Post.js b/frontend/src/components/Post.js
index 0366ae7..6bb2738 100644
--- a/frontend/src/components/Post.js
+++ b/frontend/src/components/Post.js
@@ -2,11 +2,12 @@ import React, { useState, useEffect } from "react";
const Post = (props) => {
const [state, setState] = useState({
- user: { username: "" },
- post_text: "",
+ user: { username: "HyperionLegion" },
+ post_title: "CLIMATE CHANGE",
+ post_text: "We are gonna die if we don't do anything about climate change!",
upvotes: 0,
- keywords: [],
- comments: [],
+ topics: ["climate change", "death"],
+ comments: ["this guy is weird", "no he is right"],
});
const [stocks, setStocks] = useState([]);
@@ -26,7 +27,22 @@ const Post = (props) => {
}
});
};
-
+ const onSubmit = (e) => {
+ e.preventDefault();
+ const requestOptions = {
+ method: "POST",
+ headers: {
+ "Content-Type": "application/json",
+ Authorization: `Bearer ${localStorage.getItem("token")}`,
+ },
+ body: JSON.stringify({ postid: props.id }),
+ };
+ fetch(`${process.env.REACT_APP_API_ENDPOINT}/post/upvote`, requestOptions)
+ .then((response) => response.json())
+ .then((data) => {
+ console.log(data);
+ });
+ };
useEffect(() => {
callAPI();
}, []);
@@ -36,6 +52,30 @@ const Post = (props) => {
Hello {state.user.username}!
Post {props.match.params.id}
+
{state.post_title}
+
{state.post_text}
+
+
Topics:
+ {state.topics.map((topic) => {
+ return (
+
+ );
+ })}
+
Comments:
+ {state.comments.map((comment) => {
+ return (
+
+ );
+ })}
);
diff --git a/frontend/src/components/Posts.js b/frontend/src/components/Posts.js
index e69de29..752bb8a 100644
--- a/frontend/src/components/Posts.js
+++ b/frontend/src/components/Posts.js
@@ -0,0 +1,48 @@
+import React, { useState, useEffect } from "react";
+
+const Posts = (props) => {
+ const [state, setState] = useState({
+ user: { username: "" },
+ posts: [{ id: 1, text: "monkeys" }],
+ });
+
+ const requestOptions = {
+ method: "GET",
+ headers: {
+ Authorization: `Bearer ${localStorage.getItem("token")}`,
+ },
+ };
+
+ const callAPI = () => {
+ fetch(`${process.env.REACT_APP_API_ENDPOINT}/posts/`, requestOptions)
+ .then((response) => response.json())
+ .then((data) => {
+ if (data !== undefined) {
+ setState(data);
+ }
+ });
+ };
+
+ useEffect(() => {
+ callAPI();
+ }, []);
+ return (
+
+
Posts
+
+
Hello {state.user.username}!
+ {state.posts.map((post) => {
+ return (
+
+ );
+ })}
+
+
+ );
+};
+
+export default Posts;
diff --git a/frontend/src/components/Profile.js b/frontend/src/components/Profile.js
index 0734793..d43fbd9 100644
--- a/frontend/src/components/Profile.js
+++ b/frontend/src/components/Profile.js
@@ -1,10 +1,9 @@
import React, { useState, useEffect } from "react";
-const Post = (props) => {
+const Profile = (props) => {
const [state, setState] = useState({
user: { username: "" },
- upvotes: 0,
- keywords: [],
+ topics: ["climate change", "covid19"],
});
const [stocks, setStocks] = useState([]);
@@ -16,7 +15,7 @@ const Post = (props) => {
};
const callAPI = () => {
- fetch(`${process.env.REACT_APP_API_ENDPOINT}/post/`, requestOptions)
+ fetch(`${process.env.REACT_APP_API_ENDPOINT}/profile/`, requestOptions)
.then((response) => response.json())
.then((data) => {
if (data !== undefined) {
@@ -33,9 +32,17 @@ const Post = (props) => {
Profile
Hello {state.user.username}!
+
Topics you are interested in:
+ {state.topics.map((topic) => {
+ return (
+
+ );
+ })}
);
};
-export default Post;
+export default Profile;