From 9b0679278cbe723f78f01191abed6d0f4700c5dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20Gr=C3=B6ger?= Date: Mon, 12 Apr 2021 06:45:18 +0200 Subject: [PATCH] [pricelist][cocktailbuilder] fix new ingredient component --- .../pricelist/pages/CocktailBuilder.vue | 43 ++++--------------- 1 file changed, 8 insertions(+), 35 deletions(-) diff --git a/src/plugins/pricelist/pages/CocktailBuilder.vue b/src/plugins/pricelist/pages/CocktailBuilder.vue index eb572e7..3193fd6 100644 --- a/src/plugins/pricelist/pages/CocktailBuilder.vue +++ b/src/plugins/pricelist/pages/CocktailBuilder.vue @@ -5,11 +5,10 @@ @@ -30,34 +29,14 @@ import { defineComponent, onBeforeMount, ref } from 'vue'; import Ingredients from 'src/plugins/pricelist/components/CalculationTable/Ingredients.vue'; import { DrinkPriceVolume, usePricelistStore } from 'src/plugins/pricelist/store'; +import { calc_min_prices } from '../utils/utils'; export default defineComponent({ name: 'CocktailBuilder', components: { Ingredients }, setup() { onBeforeMount(() => { void store.get_min_prices().finally(() => { - store.min_prices.forEach((min_price) => { - (volume.value).min_prices.push({ - percentage: min_price, - price: /*computed(() => { - let retVal = 0; - let extraIngredientPrice = 0; - volume.value.ingredients.forEach((ingredient) => { - if (ingredient.drink_ingredient) { - const _drink = store.drinks.find( - (a) => a.id === ingredient.drink_ingredient?.ingredient_id - ); - retVal += - ingredient.drink_ingredient.volume * (_drink?.cost_per_volume); - } - if (ingredient.extra_ingredient) { - extraIngredientPrice += ingredient.extra_ingredient.price; - } - }); - return (retVal * min_price) / 100 + extraIngredientPrice; - }) */ 0, - }); - }); + volume.value.min_prices = calc_min_prices(volume.value, undefined, store.min_prices); }); void store.getDrinks(); void store.getDrinkTypes(); @@ -74,17 +53,11 @@ export default defineComponent({ }; const volume = ref(emptyVolume); - function addIngredient(ingredient: FG.Ingredient) { - volume.value.ingredients.push(ingredient); - } - function deleteIngredient(ingredient: FG.Ingredient) { - const index = volume.value.ingredients.findIndex((a) => a.id === ingredient.id); - if (index > -1) { - volume.value.ingredients.splice(index, 1); - } + function update() { + volume.value.min_prices = calc_min_prices(volume.value, undefined, store.min_prices); } - return { volume, addIngredient, deleteIngredient }; + return { volume, update }; }, });