From 6ad2d6d7d3c3279e056c3661a458f7ea1711e962 Mon Sep 17 00:00:00 2001 From: fred <> Date: Thu, 17 Jul 2025 09:17:10 -0700 Subject: [PATCH] tidy up --- docker-compose.yaml | 2 +- frontend/src/App.css | 2 +- frontend/src/App.tsx | 8 +-- frontend/src/components/RecipeBookTabs.tsx | 1 - frontend/src/pages/About.tsx | 13 +++++ frontend/src/pages/AddRecipe.tsx | 2 +- frontend/src/pages/Cookbook.tsx | 58 -------------------- frontend/src/pages/{Search.tsx => Index.tsx} | 7 ++- frontend/src/pages/RecipePage.tsx | 4 +- 9 files changed, 26 insertions(+), 71 deletions(-) delete mode 100644 frontend/src/pages/Cookbook.tsx rename frontend/src/pages/{Search.tsx => Index.tsx} (93%) diff --git a/docker-compose.yaml b/docker-compose.yaml index 4682f1e..6ea828c 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -2,7 +2,7 @@ services: db: container_name: recipes_postgres image: docker.io/library/postgres:17 - restart: always + # restart: always env_file: - .env environment: diff --git a/frontend/src/App.css b/frontend/src/App.css index 2eb7092..b342a6f 100644 --- a/frontend/src/App.css +++ b/frontend/src/App.css @@ -6,6 +6,6 @@ @apply mx-auto text-center; } -page-outer { +.page-outer { @apply bg-amber-100 border border-amber-200 rounded-bl-lg rounded-br-lg p-6 md:p-8 lg:p-10 max-w-6xl mx-auto font-serif; } diff --git a/frontend/src/App.tsx b/frontend/src/App.tsx index c1daca6..1ef37fe 100644 --- a/frontend/src/App.tsx +++ b/frontend/src/App.tsx @@ -1,8 +1,8 @@ import "./App.css"; -import Cookbook from "./pages/Cookbook.tsx"; +import Index from "./pages/Index.tsx"; import RecipePage from "./pages/RecipePage.tsx"; import AddRecipe from "./pages/AddRecipe.tsx"; -import Search from "./pages/Search.tsx" +import About from "./pages/About.tsx" import RecipeBookTabs from "./components/RecipeBookTabs.tsx"; import { Routes, Route } from "react-router-dom"; @@ -13,10 +13,10 @@ function App() {
- } /> + } /> } /> } /> - } /> + } />
diff --git a/frontend/src/components/RecipeBookTabs.tsx b/frontend/src/components/RecipeBookTabs.tsx index 472f6cd..f5d8b26 100644 --- a/frontend/src/components/RecipeBookTabs.tsx +++ b/frontend/src/components/RecipeBookTabs.tsx @@ -7,7 +7,6 @@ const RecipeBookTabs = () => { const tabs = [ { id: '/', label: 'All Recipes', icon: '📚' }, { id: '/recipe/', label: 'Recipe', icon: '🥗' }, - { id: '/search', label: 'Search', icon: '🔎' }, { id: '/add-recipe', label: 'Add Recipe', icon: '➕' }, { id: '/about', label: 'About', icon: '🍽️' }, ]; diff --git a/frontend/src/pages/About.tsx b/frontend/src/pages/About.tsx index e69de29..6925fcf 100644 --- a/frontend/src/pages/About.tsx +++ b/frontend/src/pages/About.tsx @@ -0,0 +1,13 @@ +function About() { + + return ( +
+
+ Hello World +
+
+ ) + +} + +export default About diff --git a/frontend/src/pages/AddRecipe.tsx b/frontend/src/pages/AddRecipe.tsx index b878df6..62624a3 100644 --- a/frontend/src/pages/AddRecipe.tsx +++ b/frontend/src/pages/AddRecipe.tsx @@ -43,7 +43,7 @@ function AddRecipe() { }, [newRecipeId, navigate]); return ( -
+
(null); - const [loading, setLoading] = useState(true); - const [shouldFetchRecipes, setShouldFetchRecipes] = useState(true); - - useEffect(() => { - const loadRecipes = async () => { - try { - const recipes = await getRecipes(); - setRecipes(recipes); - } catch (error) { - console.log(error); - setError("Failed to load recipes..."); - } finally { - setLoading(false); - } - }; - if (shouldFetchRecipes) { - loadRecipes().then(() => setShouldFetchRecipes(false)); - } - }, [shouldFetchRecipes]); - - const handleDelete = async (id: number | void) => { - try { - await deleteRecipe(id); - setShouldFetchRecipes(true); - } catch (error) { - console.error("Error deleting recipe:", error); - } - }; - - - return ( -
- {error &&
{error}
} - {loading ? ( -
Loading...
- ) : ( -
-

Recipe Index

-
- {recipes.map((recipe) => ( - - ))} -
-
- )} -
- ); -} - -export default Cookbook; diff --git a/frontend/src/pages/Search.tsx b/frontend/src/pages/Index.tsx similarity index 93% rename from frontend/src/pages/Search.tsx rename to frontend/src/pages/Index.tsx index 3512237..6afcbc3 100644 --- a/frontend/src/pages/Search.tsx +++ b/frontend/src/pages/Index.tsx @@ -5,7 +5,7 @@ import { getRecipes, deleteRecipe } from "../services/frontendApi.js"; -function Search() { +function AllRecipes() { const [searchQuery, setSearchQuery] = useState(""); const [recipes, setRecipes] = useState([]); const [cuisines, setCuisines] = useState([]); @@ -47,10 +47,11 @@ function Search() { return (
+

Recipe Index

setSearchQuery(e.target.value)} @@ -81,4 +82,4 @@ function Search() { ); } -export default Search +export default AllRecipes diff --git a/frontend/src/pages/RecipePage.tsx b/frontend/src/pages/RecipePage.tsx index 7be4a34..94ba10d 100644 --- a/frontend/src/pages/RecipePage.tsx +++ b/frontend/src/pages/RecipePage.tsx @@ -30,7 +30,7 @@ function RecipePage() { }, [id]); console.log(recipe) return ( -
+
{error &&
{error}
} @@ -38,7 +38,7 @@ function RecipePage() {
Loading...
) : ( -
+

{recipe.details.name}

{recipe.details.cuisine}