+
+
+
+ {isEditingRecipe ? (
+
+ ) : (
+ <>
+
+ {recipe?.name ?? "Recipe"}
+
+ {recipe?.link && isSafeUrl(recipe.link) && (
+
+ {recipe.link}
+
+ )}
+ {recipe?.notes && (
+
+ {recipe.notes}
+
+ )}
+ >
+ )}
+
+
+ {isEditMode && !isEditingRecipe && (
+
+ )}
+
+
+
+
+ {isLoading && (
+
+ Loading...
+
+ )}
+
+ {error && (
+
+ Failed to load recipe. Make sure the API is running on port 5000.
+
+ )}
+
+ {/* Ingredients Section */}
+
+
+ Ingredients
+
+
+ {isEditMode && (
+
+ )}
+
+ {ingredients && ingredients.length === 0 && (
+
+ {isEditMode ? "No ingredients yet. Add some above!" : "No ingredients yet."}
+
+ )}
+
+ {ingredients && ingredients.length > 0 && (
+
+ {ingredients.map((ingredient) => (
+ -
+
+ {ingredient.amount} {ingredient.unit && `${ingredient.unit} `}{ingredient.name}
+ {ingredient.group && (
+
+ ({ingredient.group})
+
+ )}
+
+ {isEditMode && (
+
+ )}
+
+ ))}
+
+ )}
+
+ {/* Add to Shopping List */}
+ {ingredients && ingredients.length > 0 && shoppingLists && shoppingLists.length > 0 && (
+
+
+ Add to Shopping List
+
+
+
+
+
+
+ )}
+
+
+ {/* Steps Section */}
+
+
+ Steps
+
+
+ {isEditMode && (
+
+ )}
+
+ {sortedSteps.length === 0 && (
+
+ {isEditMode ? "No steps yet. Add some above!" : "No steps yet."}
+
+ )}
+
+ {sortedSteps.length > 0 && (
+
+ {sortedSteps.map((step) => (
+ -
+
+ {step.text}
+
+ {isEditMode && (
+
+ )}
+
+ ))}
+
+ )}
+
+
+ {/* Images Section */}
+
+
+ Images
+
+
+ {isEditMode && (
+
+ )}
+
+ {images && images.length === 0 && (
+
+ {isEditMode ? "No images yet. Add some above!" : "No images yet."}
+
+ )}
+
+ {images && images.length > 0 && (
+
+ {images.map((image) => {
+ const imageUrl = image.url ?? "";
+ const safeSrc = isSafeUrl(imageUrl) ? imageUrl : "";
+ const safeHref = isSafeUrl(imageUrl) ? imageUrl : "#";
+ return (
+
+ {/* eslint-disable-next-line @next/next/no-img-element */}
+

{
+ const target = e.currentTarget;
+ target.style.display = "none";
+ const fallback = target.nextElementSibling as HTMLElement;
+ if (fallback) fallback.style.display = "block";
+ }}
+ />
+
+ {image.url}
+
+ {isEditMode && (
+
+ )}
+
+ );
+ })}
+
+ )}
+
+
+