refactor: changed addSyrup() paramaters
Now addSyrup() takes in the currentDrink.recipe,makes a new one and returns that value
This commit is contained in:
parent
75f24043b3
commit
3d6d7644be
@ -34,7 +34,7 @@ document.addEventListener('DOMContentLoaded', function(){
|
||||
currentDrink = addRecipe(currentDrink, dataValue);
|
||||
break;
|
||||
case "SYRUP":
|
||||
currentDrink = addSyrup(currentDrink, dataValue);
|
||||
Object.assign(currentDrink.recipe, addSyrup(currentDrink.recipe, dataValue, currentDrink.size));
|
||||
break;
|
||||
case "CONTROL":
|
||||
changeMenu(dataValue);
|
||||
|
@ -137,14 +137,17 @@ function addRecipe(drink, recipe){
|
||||
return drink;
|
||||
}
|
||||
|
||||
function addSyrup(drink, syrup, qunatity){
|
||||
function addSyrup(recipe, syrup, size, qunatity){
|
||||
|
||||
let pumps = 0;
|
||||
if(qunatity){
|
||||
pumps = qunatity
|
||||
}
|
||||
else if(size){
|
||||
pumps = standardPumps(size);
|
||||
}
|
||||
else{
|
||||
pumps = standardPumps(drink.size);
|
||||
pumps = 1;
|
||||
}
|
||||
|
||||
s = {
|
||||
@ -152,14 +155,14 @@ function addSyrup(drink, syrup, qunatity){
|
||||
count: pumps
|
||||
}
|
||||
|
||||
let otherSyrups = _.without(drink.recipe.addedSyrups, _.findWhere(drink.recipe.addedSyrups, {
|
||||
let otherSyrups = _.without(recipe.addedSyrups, _.findWhere(recipe.addedSyrups, {
|
||||
name: syrup
|
||||
}));
|
||||
|
||||
otherSyrups.push(s);
|
||||
drink.recipe.addedSyrups = otherSyrups;
|
||||
recipe.addedSyrups = otherSyrups;
|
||||
|
||||
return drink;
|
||||
return recipe;
|
||||
}
|
||||
|
||||
function standardPumps(size, mod){
|
||||
|
@ -1,3 +1,62 @@
|
||||
function americano (drink) {
|
||||
let recipe = {
|
||||
name: "Americano",
|
||||
assigned: true,
|
||||
shots: standardShots(drink.size, 1),
|
||||
milk: milkTypes.TWOPERCENT
|
||||
}
|
||||
return recipe;
|
||||
}
|
||||
|
||||
function espresso (drink) {
|
||||
let recipe = {
|
||||
name: "Espresso",
|
||||
assigned: true
|
||||
}
|
||||
return recipe;
|
||||
}
|
||||
|
||||
function espressoMacchiato (drink) {
|
||||
let recipe = {
|
||||
name: "Espresso Macchiato",
|
||||
assigned: true,
|
||||
shots: standardShots(drink.size),
|
||||
milk: milkTypes.TWOPERCENT
|
||||
}
|
||||
return recipe;
|
||||
}
|
||||
|
||||
function espressoConPanna (drink) {
|
||||
let recipe = {
|
||||
name: "Espresso Macchiato",
|
||||
assigned: true,
|
||||
milk: milkTypes.TWOPERCENT
|
||||
}
|
||||
return recipe;
|
||||
}
|
||||
|
||||
function starbucksDoubleShotOnIce (drink) {
|
||||
let recipe = {
|
||||
name: "Starbucks Double Shot On Ice",
|
||||
assigned: true,
|
||||
shots: shotsSBDS(),
|
||||
milk: milkTypes.TWOPERCENT
|
||||
}
|
||||
function shotsSBDS(){
|
||||
switch (drink.size){
|
||||
case drinkSizes.TALL:
|
||||
return 2;
|
||||
case drinkSizes.GRANDE:
|
||||
return 3;
|
||||
case drinkSizes.VENTI:
|
||||
return 5;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
return recipe;
|
||||
}
|
||||
|
||||
function latte (drink) {
|
||||
let recipe = {
|
||||
name: "Latte",
|
||||
@ -8,6 +67,17 @@ function latte (drink) {
|
||||
return recipe;
|
||||
}
|
||||
|
||||
function cinnamonDolceLatte (drink) {
|
||||
let recipe = {
|
||||
name: "Cinnamon Dolce Latte",
|
||||
assigned: true,
|
||||
shots: standardShots(drink.size),
|
||||
milk: milkTypes.TWOPERCENT
|
||||
}
|
||||
addSyrup(drink, "Cinnamon Dolce")
|
||||
return recipe;
|
||||
}
|
||||
|
||||
function skinnyLatte (drink) {
|
||||
let recipe = {
|
||||
name: "Skinny Syrup Latte",
|
||||
|
Loading…
x
Reference in New Issue
Block a user