|
@@ -48,12 +48,13 @@
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
const addIngredient = ()=>{
|
|
const addIngredient = ()=>{
|
|
|
- if(quantity <= 0) return notify("error", "Quantity must be greater than 0");
|
|
|
|
|
- if(!unit) return notify("error", "Unit is required");
|
|
|
|
|
if(!ingredientName) return notify("error", "Ingredient name is required");
|
|
if(!ingredientName) return notify("error", "Ingredient name is required");
|
|
|
|
|
+ if(quantity !== undefined && quantity !== null && quantity !== "" && quantity <= 0){
|
|
|
|
|
+ return notify("error", "Quantity must be greater than 0");
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
ingredients.push({
|
|
ingredients.push({
|
|
|
- quantity: quantity,
|
|
|
|
|
|
|
+ quantity: quantity || undefined,
|
|
|
unit: unit,
|
|
unit: unit,
|
|
|
name: ingredientName
|
|
name: ingredientName
|
|
|
});
|
|
});
|
|
@@ -65,6 +66,13 @@
|
|
|
quantityInput.focus();
|
|
quantityInput.focus();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ const ingredientLabel = (ingredient)=>{
|
|
|
|
|
+ const measure = [ingredient.quantity, ingredient.unit]
|
|
|
|
|
+ .filter((part)=>part !== undefined && part !== null && part !== "")
|
|
|
|
|
+ .join(" ");
|
|
|
|
|
+ return measure ? `${ingredient.name}, ${measure}` : ingredient.name;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
const addStep = ()=>{
|
|
const addStep = ()=>{
|
|
|
if(!stepString) return notify("error", "Please enter some text");
|
|
if(!stepString) return notify("error", "Please enter some text");
|
|
|
steps.push(stepString);
|
|
steps.push(stepString);
|
|
@@ -92,7 +100,7 @@
|
|
|
<li><button
|
|
<li><button
|
|
|
onclick={()=>ingredients.splice(idx, 1)}
|
|
onclick={()=>ingredients.splice(idx, 1)}
|
|
|
type="button"
|
|
type="button"
|
|
|
- >{i.name}, {i.quantity} {i.unit}</button></li>
|
|
|
|
|
|
|
+ >{ingredientLabel(i)}</button></li>
|
|
|
{/each}
|
|
{/each}
|
|
|
</ul>
|
|
</ul>
|
|
|
|
|
|