From 9ebca7331a643899b1fb3d63c4f4c27f1458ffcc Mon Sep 17 00:00:00 2001 From: Frank-Gu-81 Date: Sat, 18 Jan 2025 16:41:16 -0600 Subject: [PATCH] UI for comment page -- code cleanup --- src/components/Comment/Comment.jsx | 102 ----------------------------- 1 file changed, 102 deletions(-) diff --git a/src/components/Comment/Comment.jsx b/src/components/Comment/Comment.jsx index 8882848..b0b5663 100644 --- a/src/components/Comment/Comment.jsx +++ b/src/components/Comment/Comment.jsx @@ -1,105 +1,3 @@ -// import { useState, useEffect } from 'react'; -// import { collection, getDocs, addDoc } from "firebase/firestore"; -// import { db } from "../../utilities/firebase"; -// 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, 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 { -// const doc = await getDocs(collection(db, "posts")); -// const posts = []; -// doc.forEach((doc) => { -// if (doc.id === post_id) { -// posts.push({ id: doc.id, ...doc.data() }); -// } -// }); -// return posts[0]; -// } catch (error) { -// console.log("Error: ", error); -// } -// } - -// useEffect(() => { -// async function fetchPosts() { -// try { -// const fetchedPosts = await getPostInfoFromDB(post_id); -// setPostInfo(fetchedPosts); -// } -// catch (error) { -// console.error("Error fetching posts: ", error); -// } -// } -// 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 ( -//
-// -// -//

Comments for {post_id}

-// {postInfo ? ( -// -// ) : ( -//

Loading post information...

-// )} -//
- -// -// -// Add a Comment -// -// setBody(e.target.value)}/> -// -// -// -// -// -//
-// ) -// } - -// export default Comment - import { useState, useEffect } from 'react'; import { collection, getDocs, addDoc, query, where, orderBy, onSnapshot } from "firebase/firestore"; import { db } from "../../utilities/firebase";