Updates an existing ingredient at the specified index. If the ingredient name changes, triggers validation workflow for fuzzy matching. If only quantity/unit changes, updates the ingredient in place.
Does not touch RHF state directly. The caller supplies applyPatch, which
the hook invokes with IngredientEditPatch values so the caller can apply
each change via the local RHF field-array API (fieldArray.update /
fieldArray.remove). Sibling rows retain object identity.
Adds a validated ingredient to the recipe or merges its quantity if the same ingredient exists. If the ingredient exists with the same unit, quantities are summed. If units differ, the new ingredient replaces the existing one.
Replaces ALL FormIngredients named originalName (defaults to the
validated ingredient's name) with the validated database ingredient, in
place. Preserves each row's own quantity/note while applying database
metadata. Used by scraper validation when the same ingredient appears
multiple times, including when the user picks a database ingredient whose
name differs from the scraped one.
Removes every form ingredient whose name matches name, emitting one
remove patch per match (highest index first so earlier removals don't
shift the indices still pending). Used by scraper validation when the user
dismisses an ingredient from the queue. No-ops on an empty / undefined name.
Resolves the placeholder row named originalName with the validated
ingredient, in place, so row order is preserved. Merges with another row
holding the validated name like editIngredients does; falls back to
addOrMergeIngredient when no placeholder exists.
Return value of the useRecipeIngredients hook.