Skip to content

Commit

Permalink
Debug
Browse files Browse the repository at this point in the history
  • Loading branch information
Edward-J-Xu committed Mar 27, 2023
1 parent cde5f5d commit 27370d2
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 16 deletions.
16 changes: 8 additions & 8 deletions SQL/createtables.sql
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ create table if not exists post
gid int not null,
title varchar(512) not null,
postText varchar(512) not null,
foreign key(username) references userA(username),
foreign key(gid) references game(game_id)
foreign key(username) references userA(username) on delete cascade,
foreign key(gid) references game(game_id) on delete cascade
);

create table if not exists comment
Expand All @@ -44,24 +44,24 @@ create table if not exists comment
comment_body varchar(512) not null,
post_id int not null,
username varchar(15) not null,
foreign key(username) references userA(username),
foreign key(post_id) references post(id)
foreign key(username) references userA(username) on delete cascade,
foreign key(post_id) references post(id) on delete cascade
);

create table if not exists likes
(
post_id int not null,
user_id int not null,
primary key(post_id, user_id),
foreign key(post_id) references post(id),
foreign key(user_id) references userA(id)
foreign key(post_id) references post(id) on delete cascade,
foreign key(user_id) references userA(id) on delete cascade
);

create table if not exists own
(
username varchar(15) not null,
gid int not null,
primary key(username, gid),
foreign key(username) references userA(username),
foreign key(gid) references game(game_id)
foreign key(username) references userA(username) on delete cascade,
foreign key(gid) references game(game_id) on delete cascade
);
4 changes: 0 additions & 4 deletions client/src/pages/posts/Post.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,9 +153,6 @@ function Post() {
<div key={key} className="comment">
{comment.comment_body}
<label> Username: {comment.username}</label>
{/* <AuthContext.Provider value={{ authState, setAuthState }}> */}
{/* {console.log("Auth User: ", authState.username)} */}
{/* <h1> Logged in: {authState.username} </h1> */}
{authState.username === comment.username && (
<button
onClick={() => {
Expand All @@ -165,7 +162,6 @@ function Post() {
X
</button>
)}
{/* </AuthContext.Provider> */}
</div>
);
})}
Expand Down
4 changes: 2 additions & 2 deletions client/src/pages/posts/createPost.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ function CreatePost() {
postText: Yup.string().required(),
gameId: Yup.number()
.required()
.max(199, "Game ID must be less than 200"),
.max(153, "Game ID must be less than 154"),
});

const onSubmit = (data) => {
Expand Down Expand Up @@ -89,7 +89,7 @@ function CreatePost() {
autoComplete="off"
id="inputCreatePost"
name="gameId"
placeholder="(Between 1 and 199)"
placeholder="(Between 1 and 153)"
/>

<button type="submit"> Create Post</button>
Expand Down
1 change: 0 additions & 1 deletion client/src/pages/posts/postApp.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,6 @@ const PostApp = () => {
: "likeBttn"
}
/>
{/* {console.log("Liked[0]: ", value.Likes[0].id)} */}
<label>{value.Likes.length}</label>
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion server/routes/Posts.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ router.post("/", validateToken, async (req, res) => {
router.delete("/:postId", validateToken, async (req, res) => {
const postId = req.params.postId;
try {
await db.pool.query("delete from posts where id = (?)", [postId]);
await db.pool.query("delete from post where id = (?)", [postId]);
res.json("DELETED SUCCESSFULLY");
} catch (e) {
console.log(e);
Expand Down

0 comments on commit 27370d2

Please sign in to comment.