From 40f353853c88e49539baa596f527a2132cbd1571 Mon Sep 17 00:00:00 2001 From: Destin Cleo Kouamba <122533459+Destinek@users.noreply.github.com> Date: Mon, 3 Apr 2023 17:14:09 +0100 Subject: [PATCH 01/18] Update README.md --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 2c4d01a9c..cbeb33b37 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,8 @@ In this project, you are tasked with working on an existing application. A significant part of the challenge will be to familiarise yourself with the codebase you've inherited, as you work to **improve and extend** it. +Link to Trello Board - https://trello.com/b/JFnRqonB/acebook-team-earth + ## Videos These videos complement the docs below. From 7edbec952f65f396ed26fda7db45a7cbda23d842 Mon Sep 17 00:00:00 2001 From: Josh Neuwford Date: Sat, 8 Apr 2023 14:46:37 +0100 Subject: [PATCH 02/18] add new post from with bug --- frontend/src/components/feed/Feed.js | 16 +++++++++++++ frontend/src/components/post/Post.js | 29 +++++++++++++++++++++++- frontend/src/components/post/PostForm.js | 26 +++++++++++++++++++++ package-lock.json | 6 +++++ 4 files changed, 76 insertions(+), 1 deletion(-) create mode 100644 frontend/src/components/post/PostForm.js create mode 100644 package-lock.json diff --git a/frontend/src/components/feed/Feed.js b/frontend/src/components/feed/Feed.js index fc89c68fc..af3f3fa6b 100644 --- a/frontend/src/components/feed/Feed.js +++ b/frontend/src/components/feed/Feed.js @@ -1,5 +1,6 @@ import React, { useEffect, useState } from 'react'; import Post from '../post/Post' +import PostForm from '../post/PostForm' const Feed = ({ navigate }) => { const [posts, setPosts] = useState([]); @@ -20,6 +21,20 @@ const Feed = ({ navigate }) => { }) } }, []) + + const handlePostSubmit = (content) => { + fetch('/posts', { + method: 'POST', + headers: { + 'content-Type': 'application/json', + 'Authorization': `Bearer ${token}` + }, + body: JSON.stringify({content}) + }) + .then((response) => response.json()) + .then((data) => setPosts([...posts, data])) + .catch((error) => console.error(error)); + }; const logout = () => { @@ -31,6 +46,7 @@ const Feed = ({ navigate }) => { return( <>

Posts

+ diff --git a/frontend/src/components/post/Post.js b/frontend/src/components/post/Post.js index 87a77c109..f694c6573 100644 --- a/frontend/src/components/post/Post.js +++ b/frontend/src/components/post/Post.js @@ -1,9 +1,36 @@ -import React from 'react'; +import React, {useState } from 'react'; const Post = ({post}) => { + + const [message, setMessage] = useState(""); + + const handleSubmit = async (event) => { + event.preventDefault(); + + fetch( '/users,', { + method: 'post', + header: { + 'content-Type': 'application/json', + }, + body: JSON.stringify({message: message}) + }) + } + + + return( + <> +
{ post.message }
+ + ) } export default Post; + +// import useState + +// const [message, setmessage] = useState("") + +// const handleSubmit \ No newline at end of file diff --git a/frontend/src/components/post/PostForm.js b/frontend/src/components/post/PostForm.js new file mode 100644 index 000000000..1fc0e786b --- /dev/null +++ b/frontend/src/components/post/PostForm.js @@ -0,0 +1,26 @@ +import React, { useState } from 'react' + +const PostForm = ({ onSubmit }) => { + const [content ,setContent] = useState(""); + + const handleSubmit = (event) => { + event.preventDefault(); + onSubmit(content); + setContent('') + }; + + return ( +
+