-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Display today's recipe on the home page
- Loading branch information
1 parent
efe987a
commit 32c8e4c
Showing
4 changed files
with
41 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,8 @@ | ||
export default function loader() { | ||
return { | ||
id: "d8258fc3-db04-490f-9961-1624834c880b", | ||
name: "All-in-one roasted tomato & bay orzo", | ||
source: { | ||
type: "book", | ||
title: "The Green Roasting Tin", | ||
page: "28", | ||
}, | ||
ingredients: ["cherry tomatoes", "orzo", "basil"], | ||
tags: [], | ||
difficulty: "easy", | ||
length: "over_60", | ||
category: "vegan", | ||
}; | ||
import { toIsoDate } from "../../services/date"; | ||
import { apiClient } from "../../services/apiClient"; | ||
|
||
export default async function loader() { | ||
const today = toIsoDate(new Date()); | ||
const plan = await apiClient.getPlan(); | ||
return today in plan ? plan[today] : null; | ||
} |
19 changes: 0 additions & 19 deletions
19
frontend/src/components/RecipeSummaryCard/RecipeSummaryCard.jsx
This file was deleted.
Oops, something went wrong.
31 changes: 31 additions & 0 deletions
31
frontend/src/components/TodaySummaryCard/TodaySummaryCard.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { Heading } from "@primer/react"; | ||
import { Link } from "react-router-dom"; | ||
import BorderBox from "../BorderBox/BorderBox"; | ||
import Source from "../Source/Source"; | ||
|
||
function TodaySummaryCard({ plan }) { | ||
const link = | ||
plan && plan.recipe && plan.recipe.id && plan.recipe.name ? ( | ||
<Link to={`/recipes/${plan.recipe.id}`}>{plan.recipe.name}</Link> | ||
) : null; | ||
const source = | ||
plan && plan.recipe && plan.recipe.source ? ( | ||
<Source source={plan.recipe.source} /> | ||
) : null; | ||
const notes = | ||
plan && plan.notes | ||
? `${plan.recipe && plan.recipe.name ? "Notes: " : ""}${plan.notes}` | ||
: null; | ||
return ( | ||
<BorderBox> | ||
<Heading as="h3" variant="small"> | ||
{plan ? "Today's recipe:" : "Nothing planned for today"} | ||
</Heading> | ||
{link} | ||
{source} | ||
{notes} | ||
</BorderBox> | ||
); | ||
} | ||
|
||
export default TodaySummaryCard; |