@@ -70,7 +100,7 @@ function Account({ userName, userEmail, profilePic, friends }) {
Classes Rated:
- 20
+ {filteredPost.length}
diff --git a/src/components/PublicFeed/PublicFeed.jsx b/src/components/PublicFeed/PublicFeed.jsx
index 125e601..7d18bc6 100644
--- a/src/components/PublicFeed/PublicFeed.jsx
+++ b/src/components/PublicFeed/PublicFeed.jsx
@@ -14,18 +14,6 @@ import {db} from "../../utilities/firebase";
import "./PublicFeed.css";
import AppBar from '../AppBar/AppBar';
-const fake_post = {
- id: 1, // automatically assigned
- title: "I LOVE CS394",
- course_name: "CS 394",
- username: "john12nu", // no need to fill this out in the submission form
- quarter: "Fall 2024",
- body: "I had such an amazing time taking CS394. Highly recommend!",
- rating: "5",
- professor: "Prof. Riesbeck",
- date: "January 10th, 2024", // use JS object to retrieve the date posted
-};
-
async function getPostsFromDB() {
// get all the posts from the database
@@ -81,12 +69,12 @@ function PublicFeed() {
return (
-
+
} component={Link} to="/feed" />
} component={Link} to="/public" />
+
-
{ filteredposts.length === 0 ?
diff --git a/src/components/RatingHistory/RatingHistory.jsx b/src/components/RatingHistory/RatingHistory.jsx
index f4a48e8..c86e130 100644
--- a/src/components/RatingHistory/RatingHistory.jsx
+++ b/src/components/RatingHistory/RatingHistory.jsx
@@ -1,7 +1,4 @@
import Post from '../Post/Post';
-import { collection, getDocs } from "firebase/firestore";
-import { db } from "../../utilities/firebase";
-import { useState, useEffect } from 'react';
import { Container, Box, Stack, Typography } from '@mui/material';
import AppBar from '../AppBar/AppBar';
import NavigationBar from '../NavigationBar/NavigationBar';
@@ -9,39 +6,10 @@ import './RatingHistory.css';
import Avatar from '@mui/material/Avatar';
-function RatingHistory({ userName, profilePic }) {
- const [filteredPost, setFilteredPost] = useState([]);
+function RatingHistory({ userName, profilePic, filteredPost }) {
const fake_friends = ["Alice", "Bob", "Charlie", "David"];
-
- async function getPostsFromDB() {
- try {
- const querySnapshot = await getDocs(collection(db, "posts"));
- const posts = [];
- querySnapshot.forEach((doc) => {
- if (doc.data().username === userName?.displayName){
- posts.push({ id: doc.id, ...doc.data() });
- }
- });
- return posts;
- } catch (error) {
- console.log("Error: ", error);
- }
-
- }
-
- useEffect(() => {
- async function fetchPosts() {
- try {
- const fetchedPosts = await getPostsFromDB();
- setFilteredPost(fetchedPosts);
- // console.log("Filtered posts: ", fetchedPosts);
- } catch (error) {
- console.error("Error fetching posts: ", error);
- }
- }
- fetchPosts();
- }, [userName]); // Add userName as a dependency to prevent it from running infinitely
+ // Add userName as a dependency to prevent it from running infinitely
return (