remove foods/units from parser if they're invalid

This commit is contained in:
Michael Genson 2025-07-28 19:24:29 +00:00
commit 29b121a0ac

View file

@ -228,19 +228,19 @@ export default defineNuxtComponent({
let unitErrorMessage = ""; let unitErrorMessage = "";
let foodErrorMessage = ""; let foodErrorMessage = "";
if (unitError || foodError) { if (unitError) {
if (unitError) { if (ing?.ingredient?.unit?.name) {
if (ing?.ingredient?.unit?.name) { const unit = ing.ingredient.unit.name || i18n.t("recipe.parser.no-unit");
const unit = ing.ingredient.unit.name || i18n.t("recipe.parser.no-unit"); ing.ingredient.unit = undefined;
unitErrorMessage = i18n.t("recipe.parser.missing-unit", { unit }).toString(); unitErrorMessage = i18n.t("recipe.parser.missing-unit", { unit }).toString();
}
} }
}
if (foodError) { if (foodError) {
if (ing?.ingredient?.food?.name) { if (ing?.ingredient?.food?.name) {
const food = ing.ingredient.food.name || i18n.t("recipe.parser.no-food"); const food = ing.ingredient.food.name || i18n.t("recipe.parser.no-food");
foodErrorMessage = i18n.t("recipe.parser.missing-food", { food }).toString(); ing.ingredient.food = undefined;
} foodErrorMessage = i18n.t("recipe.parser.missing-food", { food }).toString();
} }
} }
panels.value.push(index); panels.value.push(index);