diff --git a/src/App.jsx b/src/App.jsx
index caf304f..125e2a6 100644
--- a/src/App.jsx
+++ b/src/App.jsx
@@ -38,7 +38,7 @@ const App = () => {
: } />
: } />
: } />
- : } />
+ : } />
diff --git a/src/components/Comment/Comment.jsx b/src/components/Comment/Comment.jsx
index c6cc1d3..7b7b60f 100644
--- a/src/components/Comment/Comment.jsx
+++ b/src/components/Comment/Comment.jsx
@@ -1,16 +1,23 @@
import { useState, useEffect } from 'react';
-import { collection, getDocs } from "firebase/firestore";
+import { collection, getDocs, addDoc } from "firebase/firestore";
import { db } from "../../utilities/firebase";
-import { Container, Box, Stack, Typography, Button, Textfield } from '@mui/material';
+import { Container, Box, Stack, Typography, Button } from '@mui/material';
+import TextField from '@mui/material/TextField';
import AppBar from '../AppBar/AppBar';
import NavigationBar from '../NavigationBar/NavigationBar';
// import TextFields from '@mui/icons-material/TextFields';
import Post from '../Post/Post';
+import { useNavigate } from "react-router-dom";
import { useParams } from 'react-router-dom';
-function Comment({ userName }) {
+function Comment({ userName, profilePic }) {
+ console.log("userName: ", userName);
+ // console.log("profilePic: ", profilePic);
+ const navigate = useNavigate();
const post_id = useParams().post_id;
const [postInfo, setPostInfo] = useState(null);
+ const [body, setBody] = useState("");
+ const [fillInFields, setFillInFields] = useState(false);
async function getPostInfoFromDB(post_id) {
try {
@@ -40,6 +47,29 @@ function Comment({ userName }) {
fetchPosts();
}, [post_id]);
+ async function handleSubmit() {
+ try {
+ const collectionRef = collection(db, 'comments');
+ const comment = {
+ post_id: post_id,
+ body: body,
+ username: userName.displayName,
+ profilePic: profilePic,
+ date: new Date()
+ };
+
+ if (!body) {
+ setFillInFields(true);
+ } else {
+ await addDoc(collectionRef, comment);
+ navigate('/feed');
+ console.log('Comment added!');
+ }
+ } catch (error) {
+ console.error('Error adding comments:', error);
+ }
+ }
+
return (
@@ -56,14 +86,8 @@ function Comment({ userName }) {
Add a Comment
-
-