|
|
@@ -1,38 +1,48 @@
|
|
|
import Layout from "@/components/Layout";
|
|
|
import { GetStaticProps, InferGetStaticPropsType } from "next";
|
|
|
-import { Recipe } from "types/recipes";
|
|
|
+import { getAllRecipes, getAllTags } from '@/utils/api';
|
|
|
+import Header from '@/components/Layout/Header';
|
|
|
+import Container from '@/components/Layout/Container';
|
|
|
+
|
|
|
import { Subtitle } from 'components/Typography';
|
|
|
import RecipeItem from "components/RecipeItem";
|
|
|
-import { TextInput } from "@/components/Forms";
|
|
|
-import { Button } from "@/components/Button";
|
|
|
+import { TextInput, ChipGroup, Chip } from "@/components/Forms";
|
|
|
+
|
|
|
|
|
|
export const getStaticProps = async () => {
|
|
|
- const res = await fetch("http://localhost:3000/recipes/all/");
|
|
|
- const recipeList: Recipe[] = await res.json();
|
|
|
+ const recipeList = await getAllRecipes();
|
|
|
+ const tags = await getAllTags();
|
|
|
return {
|
|
|
props: {
|
|
|
recipeList,
|
|
|
+ tags: tags.map(tag => tag.name),
|
|
|
},
|
|
|
};
|
|
|
};
|
|
|
|
|
|
const Recipes = ({
|
|
|
recipeList = [],
|
|
|
+ tags
|
|
|
}: InferGetStaticPropsType<typeof getStaticProps>) => {
|
|
|
return (
|
|
|
<Layout>
|
|
|
- <div>
|
|
|
+ <Header>
|
|
|
<TextInput placeholder='search' id='recipe-search' />
|
|
|
- </div>
|
|
|
- <div>
|
|
|
+ <ChipGroup>
|
|
|
+ {tags.map(tag => (
|
|
|
+ <Chip key={tag} label={tag} color='primary' />
|
|
|
+ ))}
|
|
|
+ </ChipGroup>
|
|
|
+ </Header>
|
|
|
+ <Container>
|
|
|
<Subtitle>Favorites</Subtitle>
|
|
|
- </div>
|
|
|
- <div>
|
|
|
+ </Container>
|
|
|
+ <Container>
|
|
|
<Subtitle>All</Subtitle>
|
|
|
{recipeList.map((recipe, index) => (
|
|
|
<RecipeItem recipe={recipe} key={index} onClick={() => console.log(recipe.name)} />
|
|
|
))}
|
|
|
- </div>
|
|
|
+ </Container>
|
|
|
</Layout>
|
|
|
);
|
|
|
};
|