diff --git a/src/app/api/generate/route.ts b/src/app/api/generate/route.ts index 0d4a910..384445b 100644 --- a/src/app/api/generate/route.ts +++ b/src/app/api/generate/route.ts @@ -112,12 +112,16 @@ Use this exact structure: "protein": 30, "carbs": 45, "fat": 20 - } + }, + "estimatedCost": 12.50, + "takeoutEquivalent": 25.00 } ] } -Generate 5 diverse recipes with realistic nutritional information and accurate prep/cook times in minutes. Make them practical and delicious.`, +Generate 5 diverse recipes with realistic nutritional information and accurate prep/cook times in minutes. Make them practical and delicious. + +For each recipe, include estimatedCost (realistic total grocery cost for ingredients in USD) and takeoutEquivalent (what a similar meal would cost at a restaurant or delivery service in USD). Be realistic with pricing.`, }, ], }, diff --git a/src/app/generate/page.tsx b/src/app/generate/page.tsx index 5680b0e..892c25b 100644 --- a/src/app/generate/page.tsx +++ b/src/app/generate/page.tsx @@ -23,6 +23,8 @@ interface Recipe { carbs: number; fat: number; }; + estimatedCost: number; + takeoutEquivalent: number; } export default function GeneratePage() { diff --git a/src/components/InstructionsSection.tsx b/src/components/InstructionsSection.tsx index d2cbe69..17f712d 100644 --- a/src/components/InstructionsSection.tsx +++ b/src/components/InstructionsSection.tsx @@ -1,6 +1,6 @@ "use client"; -import { useState } from "react"; +import { useState, ReactNode } from "react"; interface InstructionsSectionProps { recipeName: string; @@ -8,6 +8,7 @@ interface InstructionsSectionProps { instructions: string[]; detailedInstructions: string[] | null; onDetailedInstructionsLoaded: (instructions: string[]) => void; + additionalButtons?: ReactNode; } export default function InstructionsSection({ @@ -16,6 +17,7 @@ export default function InstructionsSection({ instructions, detailedInstructions, onDetailedInstructionsLoaded, + additionalButtons, }: InstructionsSectionProps) { const [isLoadingDetails, setIsLoadingDetails] = useState(false); const [detailsError, setDetailsError] = useState(null); @@ -61,24 +63,30 @@ export default function InstructionsSection({ ))} - {/* Detailed Instructions Button */} - {!detailedInstructions && ( - - )} + {/* Action Buttons Row */} +
+ {/* Detailed Instructions Button */} + {!detailedInstructions && ( + + )} - {/* Show label when detailed instructions are displayed */} - {detailedInstructions && ( -

✓ Showing detailed instructions

- )} + {/* Show label when detailed instructions are displayed */} + {detailedInstructions && ( +

✓ Showing detailed instructions

+ )} + + {/* Additional buttons passed from parent */} + {additionalButtons} +
{/* Error message */} {detailsError &&

{detailsError}

} diff --git a/src/components/RecipeCard.tsx b/src/components/RecipeCard.tsx index b496950..4cf860c 100644 --- a/src/components/RecipeCard.tsx +++ b/src/components/RecipeCard.tsx @@ -20,6 +20,8 @@ interface Recipe { carbs: number; fat: number; }; + estimatedCost: number; + takeoutEquivalent: number; } interface RecipeCardProps { @@ -30,11 +32,13 @@ export default function RecipeCard({ recipe }: RecipeCardProps) { const [isOpen, setIsOpen] = useState(false); const [copied, setCopied] = useState(false); const [detailedInstructions, setDetailedInstructions] = useState(null); + const [showCostBreakdown, setShowCostBreakdown] = useState(false); const playClick = useClickSound(); const playPageTurn = usePageTurnSound(); const playPageBack = usePageBackSound(); const handleCopy = async () => { + const savings = recipe.takeoutEquivalent - recipe.estimatedCost; const recipeText = ` ${recipe.name} @@ -44,6 +48,8 @@ Time: Prep ${recipe.prepTime} min | Cook ${recipe.cookTime} min | Total ${recipe Nutrition: ${recipe.macros.calories} cal | ${recipe.macros.protein}g protein | ${recipe.macros.carbs}g carbs | ${recipe.macros.fat}g fat +Cost: ~$${recipe.estimatedCost.toFixed(2)} | Takeout: ~$${recipe.takeoutEquivalent.toFixed(2)} | You save: $${savings.toFixed(2)} + Ingredients: ${recipe.ingredients.map((ing) => `• ${ing}`).join("\n")} @@ -139,7 +145,34 @@ ${recipe.instructions.map((step, i) => `${i + 1}. ${step}`).join("\n")} instructions={recipe.instructions} detailedInstructions={detailedInstructions} onDetailedInstructionsLoaded={setDetailedInstructions} + additionalButtons={ + + } /> + + {/* Cost Breakdown Content */} + {showCostBreakdown && ( +
+ + 🛒 Grocery Cost: ~${recipe.estimatedCost.toFixed(2)} + + + 🍔 Takeout Equivalent: ~${recipe.takeoutEquivalent.toFixed(2)} + + + ✅ You Save: ${(recipe.takeoutEquivalent - recipe.estimatedCost).toFixed(2)} + +
+ )} )}