+
+
+
@@ -60,37 +96,90 @@
diff --git a/src/plugins/pricelist/store.ts b/src/plugins/pricelist/store.ts
index 28dde0b..d9cc121 100644
--- a/src/plugins/pricelist/store.ts
+++ b/src/plugins/pricelist/store.ts
@@ -146,8 +146,8 @@ export const usePricelistStore = defineStore({
return 0;
});
},
- deletePrice(price: FG.DrinkPrice, volume: FG.DrinkPriceVolume) {
- api
+ async deletePrice(price: FG.DrinkPrice) {
+ /*api
.delete(`pricelist/prices/${price.id}`)
.then(() => {
const index = volume.prices.findIndex((a) => a.id == price.id);
@@ -155,21 +155,18 @@ export const usePricelistStore = defineStore({
volume.prices.splice(index, 1);
}
})
- .catch((err) => console.warn(err));
+ .catch((err) => console.warn(err));*/
+ await api.delete(`pricelist/prices/${price.id}`);
},
- deleteVolume(volume: FG.DrinkPriceVolume, drink: FG.Drink) {
- api
- .delete(`pricelist/volumes/${volume.id}`)
- .then(() => {
- const index = drink.volumes.findIndex((a) => a.id === volume.id);
- if (index > -1) {
- drink.volumes.splice(index, 1);
- }
- })
- .catch((err) => console.warn(err));
+ async deleteVolume(volume: DrinkPriceVolume, drink: Drink) {
+ await api.delete(`pricelist/volumes/${volume.id}`);
+ const index = drink.volumes.findIndex((a) => a.id === volume.id);
+ if (index > -1) {
+ drink.volumes.splice(index, 1);
+ }
},
- deleteIngredient(ingredient: FG.Ingredient, volume: DrinkPriceVolume) {
- api
+ async deleteIngredient(ingredient: FG.Ingredient) {
+ /*api
.delete(`pricelist/ingredients/${ingredient.id}`)
.then(() => {
const index = volume.ingredients.findIndex((a) => a.id === ingredient.id);
@@ -178,6 +175,8 @@ export const usePricelistStore = defineStore({
}
})
.catch((err) => console.warn(err));
+ */
+ await api.delete(`pricelist/ingredients/${ingredient.id}`);
},
async setDrink(drink: FG.Drink) {
const { data } = await api.post('pricelist/drinks', {
@@ -192,10 +191,8 @@ export const usePricelistStore = defineStore({
calc_all_min_prices(this.drinks, this.min_prices);
},
async updateDrink(drink: Drink) {
- console.log(drink);
const { data } = await api.put(`pricelist/drinks/${drink.id}`, {
...drink,
- cost_per_volume: drink._cost_per_volume,
});
const index = this.drinks.findIndex((a) => a.id === data.id);
if (index > -1) {
diff --git a/src/plugins/pricelist/utils/utils.ts b/src/plugins/pricelist/utils/utils.ts
index 8c24234..7db2ec4 100644
--- a/src/plugins/pricelist/utils/utils.ts
+++ b/src/plugins/pricelist/utils/utils.ts
@@ -72,4 +72,11 @@ function clone(o: T): T {
return JSON.parse(JSON.stringify(o));
}
+interface DeleteObjects {
+ prices: Array;
+ volumes: Array;
+ ingredients: Array;
+}
+export { DeleteObjects };
+
export { calc_volume, calc_cost_per_volume, calc_all_min_prices, calc_min_prices, clone };