From 1a839218e637a8df66a4f5e9ee2ad6b62b7029f5 Mon Sep 17 00:00:00 2001 From: reiyua Date: Tue, 2 Jan 2024 07:37:39 +0000 Subject: [PATCH] Create DisplayEntries component for existing reviews --- src/components/DisplayEntries.js | 39 ++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 src/components/DisplayEntries.js diff --git a/src/components/DisplayEntries.js b/src/components/DisplayEntries.js new file mode 100644 index 0000000..18c9ad0 --- /dev/null +++ b/src/components/DisplayEntries.js @@ -0,0 +1,39 @@ +// Import required components from Bootstrap and React-Bootstrap +import Card from 'react-bootstrap/Card'; +import ListGroup from 'react-bootstrap/ListGroup'; +import 'bootstrap/dist/css/bootstrap.min.css'; + +// Import required components from Firebase Firestore +import { getFirestore, collection, getDocs } from "firebase/firestore"; + +// Create DsiplayEntries component which displays existing entries which have been submitted in a modern card format. +export function DisplayEntries() { + const [entries, setEntries] = useState([]); + const db = getFirestore(); + + useEffect(() => { + const entryRef = collection(db, "unbasedtakes"); + getDocs(entryRef).then((snapshot) => { + const entryArray = snapshot.docs.map((doc) => ({ id: doc.id, ...doc.data() })); + setEntries(entryArray); + }); + }, []); + + return ( +
+ {entries.map((entry) => ( + + + {entry.submitter} + {entry.date} + {entry.context} + {entry.fileUrl && View Evidence} + + + ))} +
+ ); + } + + + export default DisplayEntries; \ No newline at end of file