Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error messages #21

Open
wants to merge 126 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
126 commits
Select commit Hold shift + click to select a range
38a4c22
Linked Trello Board in the Card Wall section
kateusacova Oct 31, 2022
51056fa
sign up css file linking with react
Oct 31, 2022
3797f13
Login page css
Ollie-HB Oct 31, 2022
57ecdb9
Signup form styled
tauqeer92 Oct 31, 2022
0eb6647
deleting html file
Oct 31, 2022
59ff09b
Basic CSS for post, feed and app
kateusacova Oct 31, 2022
3681ed6
Merge pull request #1 from kateusacova/css-feed-and-post
kateusacova Oct 31, 2022
9b651d5
Merge pull request #2 from kateusacova/Login-page-css
kateusacova Oct 31, 2022
e85b8e9
deleting screen shot
Nov 1, 2022
64c64e2
Merge pull request #3 from kateusacova/signup-css
kateusacova Nov 1, 2022
17f0389
renaming sumbit button back to submit for signup page
Nov 1, 2022
c2f7fd2
adding sign up button
Nov 1, 2022
5e62c21
post schema
paulinejdavis Nov 1, 2022
193dffa
Merge pull request #4 from kateusacova/post_schema
paulinejdavis Nov 1, 2022
258f061
css aligned across login, signup, posts
Nov 1, 2022
8f445e7
centering the pages
Nov 1, 2022
d2b2ebf
moved body css to app.css
Nov 1, 2022
7587eee
likes and comments schema skeleton created
Nov 1, 2022
304392e
Merge pull request #5 from kateusacova/css-merge
laurenbrabbin Nov 1, 2022
7798518
Name field created on schema and form
tauqeer92 Nov 1, 2022
65d27f5
post model
Nameo91 Nov 1, 2022
e0946af
Merge pull request #6 from kateusacova/post
Nameo91 Nov 1, 2022
1260a4e
Merge branch 'main' into signup_form_schema
tauqeer92 Nov 1, 2022
718f104
Merge pull request #7 from kateusacova/signup_form_schema
tauqeer92 Nov 1, 2022
e4686a8
Merge pull request #8 from kateusacova/likes-and-comments-schemas
laurenbrabbin Nov 1, 2022
203cd76
name added to the form and schema
tauqeer92 Nov 1, 2022
ecce733
adding name to user
Nov 1, 2022
720360d
adding name to user
Nov 1, 2022
f4ebdb6
adding name to user
Nov 1, 2022
f697bed
Merge pull request #9 from kateusacova/user-name
laurenbrabbin Nov 1, 2022
4645a42
finally everything works
tauqeer92 Nov 2, 2022
2a1dda9
fixed signup
tauqeer92 Nov 2, 2022
afab3b5
creating new branch
Nov 2, 2022
6941a6f
created the create post button
Nov 2, 2022
d47065d
created postForm page
Nov 2, 2022
6c35678
create post box
Nameo91 Nov 2, 2022
04780a1
Merge pull request #10 from kateusacova/postfeed
Nameo91 Nov 2, 2022
5e5fec7
Merge branch 'main' into post-interface
laurenbrabbin Nov 2, 2022
9655ddb
Merge pull request #11 from kateusacova/post-interface
laurenbrabbin Nov 2, 2022
389b8e7
removing duplicate handleNameChange in signup form
Nov 2, 2022
fefc52b
updating feed.js frontend
Nov 2, 2022
616217e
create post frontend
Nameo91 Nov 3, 2022
d8d1aec
Merge pull request #12 from kateusacova/create_post_frontend
Nameo91 Nov 3, 2022
9990463
merging signup and login body into the same class
Nov 3, 2022
2e2cbf2
sign up form test working
paulinejdavis Nov 3, 2022
f358c2f
login and sign up page consistent
Nov 3, 2022
b671163
Merge pull request #13 from kateusacova/signup_test
paulinejdavis Nov 3, 2022
83fa46f
splitting post webpage into 3 classes
Nov 3, 2022
9715b3d
merging to main branch
Nov 3, 2022
61f8aa2
Merge pull request #14 from kateusacova/css-classes
laurenbrabbin Nov 3, 2022
c10bb62
API tests pass except posts
tauqeer92 Nov 3, 2022
d25676b
Merge pull request #15 from kateusacova/tests
tauqeer92 Nov 3, 2022
3b5ea0c
fetching api for post
Nameo91 Nov 3, 2022
46df689
Merge branch 'main' into post_fectching_api
Nameo91 Nov 3, 2022
31b28a1
Merge pull request #16 from kateusacova/post_fectching_api
Nameo91 Nov 3, 2022
0ef18ed
resolving merge conflicts in feed.js
Nov 3, 2022
37149bb
footer put into app.js
Nov 3, 2022
c4d1b4e
post css looking better
Nov 3, 2022
149cffb
password encryption
paulinejdavis Nov 3, 2022
35f63d5
nav bar framework set up
Nov 3, 2022
494c548
nav bar framework set up
Nov 3, 2022
2a3d9ac
print user name and image
Nameo91 Nov 3, 2022
5acc811
including post and user in likes and comment schema
Nov 4, 2022
e3deefd
basic navbar set up
Nov 4, 2022
125e7fe
creating nav bar css folder
Nov 4, 2022
9433c26
creating navbar css file
Nov 4, 2022
da9bddf
Merge branch 'main' into populate_user
Nameo91 Nov 4, 2022
6ebee50
Merge pull request #20 from kateusacova/populate_user
Nameo91 Nov 4, 2022
1b7163a
Merge branch 'main' into css-nav
laurenbrabbin Nov 4, 2022
75713ba
Merge pull request #21 from kateusacova/css-nav
laurenbrabbin Nov 4, 2022
e582e3c
hassle
paulinejdavis Nov 4, 2022
3356924
more hassle
paulinejdavis Nov 4, 2022
97569c7
renaming navbar files
Nov 4, 2022
b2d980d
Merge branch 'main' into bcrypt_pd
kateusacova Nov 4, 2022
02e4077
Merge pull request #24 from kateusacova/bcrypt_pd
kateusacova Nov 4, 2022
76af487
bcrypt bug
Nameo91 Nov 4, 2022
89c00fe
Merge pull request #25 from kateusacova/bcrypt_problem
Nameo91 Nov 4, 2022
6446a1b
Latest main branch - all working
kateusacova Nov 4, 2022
676910a
Likes added to Post model, basic model test passing
Ollie-HB Nov 4, 2022
e91bd8c
debug log in encryption
Nameo91 Nov 4, 2022
3369520
Merge pull request #26 from kateusacova/log_in_encryption
Nameo91 Nov 4, 2022
57022b2
Partly completed css for posts and comments
kateusacova Nov 5, 2022
ebf350a
Merge pull request #27 from kateusacova/comments-css
kateusacova Nov 5, 2022
80817a4
Merge branch 'main' into likes
kateusacova Nov 5, 2022
6584645
Merge pull request #28 from kateusacova/likes
kateusacova Nov 5, 2022
72435a1
comments show on console
tauqeer92 Nov 6, 2022
1126d37
adding like count from database into post.js
Nov 7, 2022
dd59614
updating css so create a post element does not overlap with posts
Nov 7, 2022
13c6809
recentering login and signup box
Nov 7, 2022
c6d1d22
CSS and encryption fix
kateusacova Nov 7, 2022
c983b5d
CSS and encryption fix
kateusacova Nov 7, 2022
5b9da6b
Merge branch 'main' into css-rework
kateusacova Nov 7, 2022
1634b47
Merge pull request #29 from kateusacova/css-rework
kateusacova Nov 7, 2022
8b5fedf
shaded heart comment
Nov 7, 2022
1f35fdc
Merge branch 'main' into comments
kateusacova Nov 7, 2022
d749155
Merge pull request #30 from kateusacova/comments
kateusacova Nov 7, 2022
d018ea1
id adding to like count in console but not database
Nov 7, 2022
e09c6ae
displaying comments in progress
Nameo91 Nov 7, 2022
c993def
Merge pull request #31 from kateusacova/display_comments
Nameo91 Nov 7, 2022
a5270b7
commiting end of day work
Nov 7, 2022
ddf2114
deleting likes model
Nov 7, 2022
5a9e9f4
adding upload image on sign up form
Nov 7, 2022
ba8d4bc
posting image in progress
Nameo91 Nov 7, 2022
29f4109
renaming as img
Nov 7, 2022
925bab9
Merge pull request #32 from kateusacova/signup-image
laurenbrabbin Nov 7, 2022
f7e5c57
Merge pull request #33 from kateusacova/post_image
Nameo91 Nov 7, 2022
f589d7a
Fixes done
kateusacova Nov 8, 2022
949d143
Merge pull request #34 from kateusacova/image-buttons-and-post-messag…
kateusacova Nov 8, 2022
315ff27
likes now adding to database
Nov 8, 2022
714f4e0
likes count increasing with every like without refreshing page
Nov 8, 2022
023b722
importing both shaded and regular heart
Nov 8, 2022
e1f06ab
shaded button implemented but not fully working
Nov 8, 2022
9324bd4
All working
kateusacova Nov 8, 2022
37a6f78
upload image
Nameo91 Nov 8, 2022
8f6c184
shaded heart working
Nov 9, 2022
f59c8e7
Merge pull request #35 from kateusacova/comments-and-session-info
kateusacova Nov 9, 2022
4e8f357
Merge branch 'main' into likes
kateusacova Nov 9, 2022
e66317f
Merge pull request #36 from kateusacova/likes
kateusacova Nov 9, 2022
10d390c
Merge branch 'main' into upload_image
kateusacova Nov 9, 2022
4b86b03
Merge pull request #37 from kateusacova/upload_image
kateusacova Nov 9, 2022
c70db97
Session info imported into Post
kateusacova Nov 9, 2022
8217923
Sign up error fixed and sessions added
kateusacova Nov 9, 2022
15eee0e
user can only like once
Nov 9, 2022
3af3bfc
unliking works
Nov 9, 2022
d92d32a
Merge pull request #38 from kateusacova/unliking
laurenbrabbin Nov 9, 2022
57c29a7
Error messages completed
tauqeer92 Nov 9, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
displaying comments in progress
Nameo91 committed Nov 7, 2022
commit e09c6ae57b4570d14d0cc3633d94da03da8ab218
12 changes: 7 additions & 5 deletions api/controllers/comments.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
const { request } = require("express");
const Comment = require("../models/comment");
const TokenGenerator = require("../models/token_generator");

const CommentsController = {




Create: (req, res) => {
const commentData = {message: req.body.message, user: req.user_id, post: req.post_id, token: req.body.token};
console.log(req);
const commentData = {
message: req.body.message,
user: req.user_id,
token: req.body.token };

const comment = new Comment(commentData);
comment.save(async (err) => {
if(err) {
1 change: 1 addition & 0 deletions api/controllers/posts.js
Original file line number Diff line number Diff line change
@@ -13,6 +13,7 @@ const PostsController = {
res.status(200).json({ posts: posts, token: token, user: req.user_id });
});
},

Create: (req, res) => {
const postData = {message: req.body.message, user: req.user_id, token: req.body.token};
console.log(postData);
12 changes: 10 additions & 2 deletions api/models/post.js
Original file line number Diff line number Diff line change
@@ -16,8 +16,16 @@ const PostSchema = new mongoose.Schema({
type: Schema.Types.ObjectId,
ref: "User"
},
likes: Array
});
likes: Array,
comments: [{
type: mongoose.Schema.Types.ObjectId,
ref: 'Comment'
}]
});

PostSchema.virtual('url').get(() => {
return '/post/' + this._id
})

const Post = mongoose.model("Post", PostSchema);

2 changes: 0 additions & 2 deletions api/routes/comments.js
Original file line number Diff line number Diff line change
@@ -3,8 +3,6 @@ const router = express.Router();

const CommentsController = require("../controllers/comments");


router.post("/", CommentsController.Create);


module.exports = router;
80 changes: 80 additions & 0 deletions frontend/src/components/comment/CommentForm.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
import React, {useEffect, useState} from 'react';

import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
import { faPaperPlane } from '@fortawesome/free-solid-svg-icons'

const elementPaperPlane = <FontAwesomeIcon icon={ faPaperPlane } size = '2x' />

const CommentForm = ({ navigate }) => {

const [comment, setComment] = useState("");
const [token, setToken] = useState(window.localStorage.getItem("token"));

// const loadComments = () => {
// if(token) {
// fetch("/comments", {
// headers: {
// 'Authorization': `Bearer ${token}`
// }
// })
// .then(response => response.json())
// .then(async data => {
// window.localStorage.setItem("token", data.token)
// setToken(window.localStorage.getItem("token"))
// console.log(data);
// setComment(data.comments);
// ;
// })
// }
// }

const handleCommentSubmit = async (event) => {
event.preventDefault();

if (token) fetch('/comments', {
method: 'post',
headers: {
'Authorization': `Bearer ${token}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({token: token, message: comment})
})
.then(response => response.json())
.then(
data => {
console.log(data);
})
}

const handleCommentChange = (event) => {
setComment(event.target.value)
}

return(
<>
{/* WRITE COMMENT*/}
<div className="comments">
<div className="comments-box">
<div className="box-profile">
<img src="/images/bird-avator.png" alt="avatar" className="profile-pic" ></img>
</div>
<div className="box-bar">
<input type="text" placeholder='Write a comment...' className="bar-input" value={ comment } onChange={ handleCommentChange }></input>
<button onClick={ handleCommentSubmit } className="write-comment-btn">{ elementPaperPlane }</button>
</div>
</div>
{/* SEE COMMENTS*/}
</div>
{/* <div className="all-comments-section">
<img src="/images/bird-avator.png" alt="avatar" className="comment-author-pic" ></img>
<div id="single-comment-wrapper">
<span className="comment-author">Comment Author</span>
<span className="comment-content">Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. </span>
</div>
</div> */}
</>

)
}

export default CommentForm;
85 changes: 32 additions & 53 deletions frontend/src/components/comment/comment.js
Original file line number Diff line number Diff line change
@@ -1,65 +1,44 @@
import React, {useEffect, useState} from 'react';

const Comment = ({comment}) => {
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
import { faPaperPlane } from '@fortawesome/free-solid-svg-icons'

const [comments, setComment] = useState("");
const [token, setToken] = useState(window.localStorage.getItem("token"));
const elementPaperPlane = <FontAwesomeIcon icon={ faPaperPlane } size = '2x' />

const handleCommentChange = (event) => {
setComment(event.target.value)
}
const Comment = ({ navigate }) => {

const [comment, setComment] = useState("");
const [token, setToken] = useState(window.localStorage.getItem("token"));

const loadComments = () => {
if(token) {
fetch("/comments", {
headers: {
'Authorization': `Bearer ${token}`
}
})
.then(response => response.json())
.then(async data => {
window.localStorage.setItem("token", data.token)
setToken(window.localStorage.getItem("token"))
console.log(data);
setComment(data.comments);
;
})
const loadComments = () => {
if(token) {
fetch("/comments", {
headers: {
'Authorization': `Bearer ${token}`
}
}

const handleCommentSubmit = async (event) => {
event.preventDefault();

if (token) fetch('/comments', {
method: 'post',
headers: {
'Authorization': `Bearer ${token}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({token: token, message: comments})
})
.then(response => response.json())
.then(
data => {
console.log(data);
})


}
})
.then(response => response.json())
.then(async data => {
window.localStorage.setItem("token", data.token)
setToken(window.localStorage.getItem("token"))
console.log(data);
setComment(data.comments);
;
})
}
}

return(
<body>
<div class="comments">
<form onSubmit={handleCommentSubmit}>
<input id='commentMessage' placeholder="Add a comment.." type="text" value={comment} onChange={handleCommentChange}/>
<input id='submitComment' type="submit" value="Submit"/>
</form>
</div>


</body>

<>
{/* SEE COMMENTS*/}
{/* <div className="all-comments-section">
<img src="/images/bird-avator.png" alt="avatar" className="comment-author-pic" ></img>
<div id="single-comment-wrapper">
<span className="comment-author">Comment Author</span>
<span className="comment-content">Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. </span>
</div>
</div> */}
</>

)
}
3 changes: 1 addition & 2 deletions frontend/src/components/feed/Feed.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import React, { useEffect, useState } from 'react';
import Navbar from '../Navbar/Navbar';
import Post from '../post/Post';
import Comment from '../comment/comment';
import './Feed.css';

const Feed = ({ navigate }) => {
@@ -28,7 +27,6 @@ const Feed = ({ navigate }) => {

useEffect(loadPosts, [])


const handlePostSubmit = async (event) => {
event.preventDefault();

@@ -97,6 +95,7 @@ const Feed = ({ navigate }) => {
{posts.map(
(post) => (
<Post post={ post } key={ post._id }/> )

)}
</div>
</>
22 changes: 11 additions & 11 deletions frontend/src/components/post/Post.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import React from 'react';
import './Post.css';
import Comment from '../comment/comment';
import CommentForm from '../comment/CommentForm';
import { useNavigate } from "react-router-dom";

import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
import { faHeart } from '@fortawesome/free-regular-svg-icons'
import { faPaperPlane } from '@fortawesome/free-solid-svg-icons'

const elementHeartOutline = <FontAwesomeIcon icon={ faHeart } size = '2x' />
const elementPaperPlane = <FontAwesomeIcon icon={ faPaperPlane } size = '2x' />


// const loadLikes = () => {
// fetch('/posts/likes', {
@@ -20,10 +20,9 @@ const elementPaperPlane = <FontAwesomeIcon icon={ faPaperPlane } size = '2x' />
// data.likes)
// }


const Post = ({post}) => {
return(
<div className="posts-container" data-cy="post" key={ post._id}>
<div className="posts-container" data-cy="post" key={ post._id }>
<div className="post">
{/* POST HEADER */}
<div className="post-header">
@@ -54,7 +53,8 @@ const Post = ({post}) => {
<div className="saparator"></div>
</div>
{/* WRITE COMMENT*/}
<div className="comments">
<CommentForm navigate={ useNavigate() }/>
{/* <div className="comments">
<div className="comments-box">
<div className="box-profile">
<img src="/images/bird-avator.png" alt="avatar" className="profile-pic" ></img>
@@ -64,24 +64,24 @@ const Post = ({post}) => {
<button className="write-comment-btn">{ elementPaperPlane }</button>
</div>
</div>
</div>
</div> */}
{/* SEE COMMENTS - will need to be a separate component */}
<div className="all-comments-section">
{/* <div className="all-comments-section">
<img src="/images/bird-avator.png" alt="avatar" className="comment-author-pic" ></img>
<div id="single-comment-wrapper">
<span className="comment-author">Comment Author</span>
<span className="comment-content">Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. </span>
</div>
</div>
</div> */}

{/* SEE COMMENTS - duplicate to display as example */}
<div className="all-comments-section">
{/* <div className="all-comments-section">
<img src="/images/bird-avator.png" alt="avatar" className="comment-author-pic" ></img>
<div id="single-comment-wrapper">
<span className="comment-author">Comment Author</span>
<span className="comment-content">Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. </span>
</div>
</div>
</div> */}

</div>
</div>