Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 | 5x 5x 2x 5x 1x 4x 10x | import { type RecipeDetail, type ScaleResponse } from '../../api/client'
interface RecipeInstructionsProps {
recipe: RecipeDetail
scaledData: ScaleResponse | null
}
export default function RecipeInstructions({
recipe,
scaledData,
}: RecipeInstructionsProps) {
// Use scaled instructions if available, otherwise fall back to original
const hasScaledInstructions = scaledData?.instructions && scaledData.instructions.length > 0
const instructions = hasScaledInstructions
? scaledData.instructions
: recipe.instructions.length > 0
? recipe.instructions
: recipe.instructions_text
? recipe.instructions_text.split('\n').filter((s) => s.trim())
: []
if (instructions.length === 0) {
return (
<p className="text-muted-foreground">
No instructions available for this recipe.
</p>
)
}
return (
<div className="space-y-4">
{hasScaledInstructions && (
<p className="text-sm text-muted-foreground">
Instructions adjusted for {scaledData.target_servings} servings
</p>
)}
<ol className="space-y-4">
{instructions.map((step, index) => (
<li key={index} className="flex items-start gap-4">
<span className="flex h-7 w-7 shrink-0 items-center justify-center rounded-full bg-primary text-sm font-medium text-primary-foreground">
{index + 1}
</span>
<p className="pt-0.5 text-foreground">{step}</p>
</li>
))}
</ol>
</div>
)
}
|