diff --git a/frontend/src/pages/HomePage.tsx b/frontend/src/pages/HomePage.tsx index b090cdec..16c576bf 100644 --- a/frontend/src/pages/HomePage.tsx +++ b/frontend/src/pages/HomePage.tsx @@ -58,7 +58,9 @@ export default function HomePage() { published: true, }) .then((response) => { - setResults(response); + setResults( + response.filter((book) => !book.tags.includes("teacher_resource")), + ); setLoading(false); }) .catch((error) => { diff --git a/frontend/src/pages/TeacherResources.tsx b/frontend/src/pages/TeacherResources.tsx index e1959607..4f9ebc73 100644 --- a/frontend/src/pages/TeacherResources.tsx +++ b/frontend/src/pages/TeacherResources.tsx @@ -2,8 +2,40 @@ import Navbar from "../components/Navbar"; import Footer from "../components/Footer"; import Background from "../components/Background"; import PostPreview from "../components/PostPreview"; +import { useCallback, useEffect, useState } from "react"; +import { Book, BooksService } from "../api"; +import ActivityBookList from "../components/ActivityBookList"; export default function ActivityPostList() { + const [results, setResults] = useState([]); + const [loading, setLoading] = useState(false); + + const loadBookResults = useCallback( + (topic: string | null, query: string | null) => { + setLoading(true); + BooksService.searchBooksBooksSearchPost({ + categories: null, + query, + published: true, + }) + .then((response) => { + setResults( + response.filter((book) => book.tags.includes("teacher_resource")), + ); + setLoading(false); + }) + .catch((error) => { + console.error(error); + setLoading(false); + }); + }, + [], + ); + + // The initial load of all books + useEffect(() => { + loadBookResults(null, null); + }, [loadBookResults]); const otherPostsData = [ { image: "/lego-sort-example-clumping.png", @@ -37,6 +69,15 @@ export default function ActivityPostList() { ))} +
+

Books for Teachers

+ +