diff --git a/frontend/src/App.tsx b/frontend/src/App.tsx index 8c8d13b..5b675b4 100644 --- a/frontend/src/App.tsx +++ b/frontend/src/App.tsx @@ -1,4 +1,5 @@ -import React, { useState } from "react"; +import React, { useState, useEffect } from "react"; +import ListView from "./components/ListView"; import Header from "./components/Header"; import Footer from "./components/Footer"; import MultiForm from "./components/MultiForm"; @@ -8,28 +9,44 @@ import hero from "./assets/hero-img.png"; import Modal from "./components/Modal"; const App: React.FC = () => { - const [openModal, setOpenModal] = useState(false); - return ( - <> - - - - - - - - - - - - - - - {openModal && } - > - ); + const [openModal, setOpenModal] = useState(false); + const [items, setItems] = useState([]); + + useEffect(() => { + fetch("/api/list") + .then((res) => res.json()) + .then((data) => setItems(data)) + .catch((err) => console.error(err)); + }, []); + + return ( + <> + + + + + + + + + + + {/* LIST RENDERED HERE */} + + + + + + + + + + + {openModal && } + > + ); }; export default App; diff --git a/frontend/src/components/ListView.tsx b/frontend/src/components/ListView.tsx new file mode 100644 index 0000000..26048b5 --- /dev/null +++ b/frontend/src/components/ListView.tsx @@ -0,0 +1,27 @@ +import React from "react"; + +interface ListViewProps { + items: any[]; +} + +const ListView: React.FC = ({ items }) => { + if (!items || items.length === 0) { + return No items found.; + } + + return ( + + Items List + + {items.map((item, index) => ( + + {typeof item === "string" ? item : JSON.stringify(item)} + + ))} + + + ); +}; + +export default ListView; +
No items found.