瀏覽代碼

Remove all front and backend from long merchant creation process

Lee Morgan 6 年之前
父節點
當前提交
93f68e3fef

+ 0 - 15
controllers/ingredientData.js

@@ -15,21 +15,6 @@ module.exports = {
             });
     },
 
-    //POST - creates new ingredients from a list
-    //Inputs:
-    //  req.body: list of ingredients (name, category, unit)
-    //Returns:
-    //  ingredients: list containing the newly created ingredients
-    createNewIngredients: function(req, res){
-        Ingredient.create(req.body)
-            .then((ingredients)=>{
-                return res.json(ingredients);
-            })
-            .catch((err)=>{
-                return res.json("Error: new ingredients could not be created");
-            });
-    },
-
     //TODO - Redirect to merchantData.js rather than adding here
     //POST - create a single ingredient and then add to the merchant
     //Inputs: 

+ 0 - 148
controllers/merchantData.js

@@ -87,154 +87,6 @@ module.exports = {
             });
     },
 
-    //POST - Creates a Clover merchant from all entered data
-    //Inputs:
-    //  req.body.data: All data from frontend in form of merchant model
-    //Redirect to "/inventory"
-    createMerchantClover: async function(req, res){
-        let data = JSON.parse(req.body.data);
-        data.email = data.email.toLowerCase();
-
-        let merchant = await Merchant.findOne({email: data.email});
-        if(merchant){
-            req.session.error = "Email already in use";
-            return res.redirect("/merchant/new/clover");
-        }
-
-        if(data.password.length < 15 || data.password !== data.confirmPassword){
-            req.session.error = "Passwords must match and contain at least 15 characters";
-            return res.redirect("/");
-        }
-
-        axios.get(`https://apisandbox.dev.clover.com/v3/merchants/${req.session.merchantId}?access_token=${req.session.accessToken}`)
-            .then((cloverMerchant)=>{
-                req.session.posId = undefined;
-
-                let salt = bcrypt.genSaltSync(10);
-                let hash = bcrypt.hashSync(data.password, salt);
-
-                let merchant = new Merchant({
-                    name: cloverMerchant.data.name,
-                    email: data.email,
-                    password: hash,
-                    pos: "clover",
-                    posId: cloverMerchant.data.id,
-                    posAccessToken: req.session.accessToken
-                });
-
-                req.session.merchantId = undefined;
-                req.session.accessToken = undefined;
-
-                for(let item of data.inventory){
-                    merchant.inventory.push({
-                        ingredient: item.ingredient.id,
-                        quantity: item.quantity
-                    });
-                }
-
-                for(let recipe of data.recipes){
-                    recipe.merchant = merchant._id;
-                }
-
-                Recipe.create(data.recipes)
-                    .then((recipes)=>{
-                        for(let recipe of recipes){
-                            merchant.recipes.push(recipe._id);
-                        }
-
-                        merchant.save()
-                            .then((merchant)=>{
-                                req.session.user = merchant._id;
-                                return res.redirect("/inventory");
-                            })
-                            .catch((err)=>{
-                                req.session.error = "Error: your data could not be saved";
-
-                                return res.redirect("/");
-                            });
-                    })
-                    .catch((err)=>{
-                        req.session.error = "Error: your recipes could not be created";
-                        
-                        return res.redirect("/");
-                    });
-            })
-            .catch((err)=>{
-                req.session.error = "Error: Unable to retrieve your data from Clover";
-
-                return res.redirect("/");
-            });
-    },
-
-    //POST - Creates a non-pos merchant from all entered data
-    //Inputs:
-    //  req.body.data: All data from frontend in form of merchant model
-    //Redirects to "/inventory"
-    createMerchantNone: async function(req, res){
-        let data = JSON.parse(req.body.data);
-        data.email = data.email.toLowerCase();
-
-        let merchantExists = await Merchant.findOne({email: data.email});
-        if(merchantExists){
-            req.session.error = "Email already in use";
-            return res.redirect("/merchant/new/none");
-        }
-
-        if(data.password.length < 15 || data.password !== data.confirmPassword){
-            req.session.error = "Passwords must match and contain at least 15 characters";
-            return res.redirect("/");
-        }
-
-        let salt = bcrypt.genSaltSync(10);
-        let hash = bcrypt.hashSync(data.password, salt);
-        
-        let merchant = new Merchant({
-            name: data.name,
-            email: data.email,
-            password: hash,
-            pos: "none",
-            accountStatus: {
-                status: "valid",
-                //working here
-            }
-
-        });
-
-        for(let item of data.inventory){
-            merchant.inventory.push({
-                ingredient: item.ingredient.id,
-                quantity: item.quantity
-            });
-        }
-
-        for(let recipe of data.recipes){
-            recipe.merchant = merchant._id;
-        }
-
-        Recipe.create(data.recipes)
-            .then((recipes)=>{
-                for(let recipe of recipes){
-                    merchant.recipes.push(recipe._id);
-                }
-
-                merchant.save()
-                    .then((merchant)=>{
-                        req.session.user = merchant._id;
-                        return res.redirect("/inventory");
-                    })
-                    .catch((err)=>{
-                        req.session.error = "Error: unable to save user data";
-
-                        return res.redirect("/");
-                    });
-            })
-            .catch((err)=>{
-                req.session.error = "Error: unable to create recipes";
-
-                return res.redirect("/");
-            });
-    },
-
     //POST - Adds an ingredient to merchant's inventory
     //Inputs:
     //  req.body.ingredient: ingredient id

+ 0 - 19
controllers/otherData.js

@@ -135,25 +135,6 @@ module.exports = {
         return res.redirect("/");
     },
 
-    //POST - check an email for uniqueness
-    //Inputs:
-    //  req.body.email: email to check
-    //Returns:
-    //  Boolean
-    checkUniqueEmail: function(req, res){
-        Merchant.findOne({email: req.body.email})
-            .then((merchant)=>{
-                if(merchant){
-                    return res.json(false);
-                }
-
-                return res.json(true);
-            })
-            .catch((err)=>{
-                return res.json("Error: unable to validate email address");
-            });
-    },
-
     clover: async function(req, res){
         if(req.url.includes("?")){
             let urlArgs = req.url.slice(req.url.indexOf("?") + 1).split("&");

+ 0 - 4
routes.js

@@ -16,8 +16,6 @@ module.exports = function(app){
 
     //Merchant
     app.get("/merchant/recipes/update", merchantData.updateRecipes);
-    app.post("/merchant/clover/create", merchantData.createMerchantClover);
-    app.post("/merchant/none/create", merchantData.createMerchantNone);
     app.post("/merchant/ingredients/create", merchantData.addMerchantIngredient);
     app.post("/merchant/ingredients/remove", merchantData.removeMerchantIngredient);
     app.post("/merchant/ingredients/update", merchantData.updateMerchantIngredient);
@@ -29,7 +27,6 @@ module.exports = function(app){
 
     //Ingredients
     app.get("/ingredients", ingredientData.getIngredients);
-    app.post("/ingredients/create", ingredientData.createNewIngredients);
     app.post("/ingredients/createone", ingredientData.createIngredient);  //also adds to merchant
 
     //Other
@@ -37,7 +34,6 @@ module.exports = function(app){
     app.post("/purchases/create", otherData.createPurchase);
     app.post("/login", otherData.login);
     app.get("/logout", otherData.logout);
-    app.post("/email", otherData.checkUniqueEmail);
     app.get("/clover", otherData.clover);
     app.get("/cloverlogin", otherData.cloverRedirect);
     app.get("/cloverauth*", otherData.cloverAuth);

+ 2 - 0
views/landingPage/controller.js

@@ -2,6 +2,7 @@ let controller = {
     publicStrand: document.querySelector("#publicStrand"),
     loginStrand: document.querySelector("#loginStrand"),
     posChoiceStrand: document.querySelector("#posChoiceStrand"),
+    registerStrand: document.querySelector("#registerStrand"),
 
     onStart: function(){
         if(error){
@@ -15,6 +16,7 @@ let controller = {
         this.publicStrand.style.display = "none";
         this.loginStrand.style.display = "none";
         this.posChoiceStrand.style.display = "none";
+        this.registerStrand.style.display = "none";
     }
 }
 

+ 25 - 2
views/landingPage/landing.ejs

@@ -17,7 +17,7 @@
                 <div class="public-buttons">
                     <button class="button" onclick="loginObj.display()">Log In</button>
 
-                    <button class="button" onclick="posChoiceObj.display()">Join</button>
+                    <button class="button" onclick="registerObj.display()">Join</button>
                 </div>
 
                 <div class="logo-text">
@@ -69,6 +69,29 @@
             </form>
         </div>
 
+        <div id="registerStrand" onsubmit="registerObj.submit()">
+            <form>
+                <label>Restaurant Name:
+                    <input id="regName" type="text">
+                </label>
+
+                <label>Email:
+                    <input id="regEmail" type="email">
+                </label>
+
+                <label>Password:
+                    <input id="regPass" type="password">
+                </label>
+
+                <label>Confirm Password:
+                    <input id="regConfirmPass" type="password">
+                </label>
+
+                <input type="submit" value="Register">
+            </form>
+        </div>
+        
+
         <div id="posChoiceStrand">
             <h1>Choose your POS System</h1>
 
@@ -94,7 +117,7 @@
         <script src="../shared/validation.js"></script>
         <script src="/landingPage/public.js"></script>
         <script src="/landingPage/login.js"></script>
-        <script src="/landingPage/posChoice.js"></script>
+        <script src="/landingPage/register.js"></script>
         <script src="/landingPage/controller.js"></script>
     </body>
 </html>

+ 12 - 0
views/landingPage/register.js

@@ -0,0 +1,12 @@
+let registerObj = {
+    display: function(){
+        controller.clearScreen();
+        controller.registerStrand.style.display = "flex";
+    },
+
+    submit: function(){
+        event.preventDefault();
+
+        
+    }
+}

+ 0 - 131
views/merchantSetupPage/addIngredients.js

@@ -1,131 +0,0 @@
-addIngredientsObj = {
-    isPopulated: false,
-    rows: [],
-    displayedRows: [],
-    currentSort: "",
-
-    display: function(){
-        controller.clearScreen();
-        controller.addIngredientsStrand.style.display = "flex";
-
-        if(!this.isPopulated){
-            this.createRows();
-            this.filter();
-            this.isPopulated = true;
-        }
-    },
-
-    createRows: function(){
-        for(let ingredient of ingredients){
-            let row = document.createElement("tr");
-            row.id = ingredient._id;
-            row.sortOptions = {
-                name: ingredient.name.toLowerCase(),
-                category: ingredient.category.toLowerCase(),
-                unit: ingredient.unit.toLowerCase()
-            };
-        
-            let add = document.createElement("td");
-            row.appendChild(add);
-
-            let checkbox = document.createElement("input");
-            checkbox.type = "checkbox";
-            add.appendChild(checkbox);
-            
-            let name = document.createElement("td");
-            name.innerText = ingredient.name;
-            name.classList = "truncateLong";
-            row.appendChild(name);
-        
-            let category = document.createElement("td");
-            category.innerText = ingredient.category;
-            row.appendChild(category);
-        
-            let quantity = document.createElement("td");
-            row.appendChild(quantity);
-
-            let quantityInput = document.createElement("input");
-            quantityInput.type = "number";
-            quantityInput.step = "0.01";
-            quantityInput.min = "0";
-            quantityInput.classList = "inputField";
-            quantity.appendChild(quantityInput);
-            
-            let unit = document.createElement("td");
-            unit.innerText = ingredient.unit;
-            row.appendChild(unit);
-
-            this.rows.push(row);
-        }
-    },
-
-    filter: function(){
-        let searchString = document.querySelector("#filter").value.toLowerCase();
-
-        this.displayedRows = [];
-
-        for(let row of this.rows){
-            if(row.sortOptions.name.includes(searchString)){
-                this.displayedRows.push(row);
-            }
-        }
-
-        this.currentSort = "";
-        this.sortIngredients("name");
-    },
-
-    sortIngredients: function(property){
-        if(this.currentSort === property){
-            this.displayedRows.sort((a, b)=>(a.sortOptions[property] > b.sortOptions[property]) ? -1 : 1);
-            this.currentSort = "";
-        }else{
-            this.displayedRows.sort((a, b)=>(a.sortOptions[property] > b.sortOptions[property]) ? 1 : -1);
-            this.currentSort = property;
-        }
-
-        this.populate();
-    },
-
-    populate: function(){
-        let tbody = document.querySelector("#addIngredientsStrand tbody");
-
-        while(tbody.children.length > 0){
-            tbody.removeChild(tbody.firstChild);
-        }
-
-        for(let row of this.displayedRows){
-            tbody.appendChild(row);
-        }
-    },
-
-    submit: function(){
-        controller.data.inventory = [];
-
-        let tbody = document.querySelector("#ingredient-display tbody");
-        let isValid = true;
-        for(let row of tbody.children){
-            if(row.children[0].children[0].checked){
-                let quantity = row.children[3].children[0].value;
-
-                if(validator.ingredient.quantity(quantity)){
-                    controller.data.inventory.push({
-                        ingredient: {
-                            id: row.id,
-                            name: row.children[1].innerText,
-                            category: row.children[2].innerText,
-                            unit: row.children[4].innerText
-                        },
-                        quantity: quantity
-                    });
-                }else{
-                    isValid = false;
-                    break;
-                }
-            }
-        }
-
-        if(isValid){
-            createIngredientsObj.display();
-        }
-    }
-}

+ 0 - 53
views/merchantSetupPage/basicInfo.js

@@ -1,53 +0,0 @@
-basicInfoObj = {
-    display: function(){
-        controller.clearScreen();
-        controller.basicInfoStrand.style.display = "flex";
-
-        if(!recipes){
-            document.querySelector("#nameLabel").style.display = "block";
-        }
-    },
-
-    agree: function(){
-        let checkbox = document.querySelector("#agree");
-        let button = document.querySelector("#subButton");
-
-        if(checkbox.checked){
-            button.disabled = false;
-            button.classList = "button";
-        }else{
-            button.disabled = true;
-            button.classList = "buttonDisabled";
-        }
-    },
-
-    submit: function(){
-        event.preventDefault();
-
-        let name = document.querySelector("#regName").value;
-        let email = document.querySelector("#regEmail").value;
-        let password = document.querySelector("#regPass").value;
-        let confirmPassword = document.querySelector("#regConfirmPass").value;
-
-        axios.post("/email", {email: email})
-            .then((response)=>{
-                if(typeof(response.data) === "string"){
-                    banner.createError(response.data);
-                }else if(response.data){
-                    if(validator.merchant.password(password, confirmPassword)){
-                        controller.data.name = name;
-                        controller.data.email = email;
-                        controller.data.password = password;
-                        controller.data.confirmPassword = confirmPassword;
-            
-                        addIngredientsObj.display();
-                    }
-                }else{
-                    banner.createError("Email address already in use");
-                }
-            })
-            .catch((err)=>{
-                banner.createError("Error: unable to validate email address");
-            });
-    }
-}

+ 0 - 36
views/merchantSetupPage/controller.js

@@ -1,36 +0,0 @@
-let controller = {
-    data: {},  //For storing all data from user to pass to backend
-
-    basicInfoStrand: document.querySelector("#basicInfoStrand"),
-    addIngredientsStrand: document.querySelector("#addIngredientsStrand"),
-    createIngredientsStrand: document.querySelector("#createIngredientsStrand"),
-    nameRecipesStrand: document.querySelector("#nameRecipesStrand"),
-    createRecipesStrand: document.querySelector("#createRecipesStrand"),
-
-    onStart: function(){
-        if(error){
-            banner.createError(error);
-        }
-        
-        basicInfoObj.display();
-    },
-
-    //General purpose data validator
-    checkValid: function(valueToCheck, inputField){
-        if(!validator.ingredient[valueToCheck](inputField.value, createBanner = false)){
-            inputField.classList += " input-error"
-        }else{
-            inputField.classList.remove("input-error");
-        }
-    },
-
-    clearScreen: function(){
-        this.basicInfoStrand.style.display = "none";
-        this.addIngredientsStrand.style.display = "none";
-        this.createIngredientsStrand.style.display = "none";
-        this.nameRecipesStrand.style.display = "none";
-        this.createRecipesStrand.style.display = "none";
-    }
-}
-
-controller.onStart();

+ 0 - 147
views/merchantSetupPage/createIngredients.js

@@ -1,147 +0,0 @@
-let createIngredientsObj = {
-    display: function(){
-        controller.clearScreen();
-        controller.createIngredientsStrand.style.display = "flex";
-
-        let tbody = document.querySelector("#createIngredientsStrand tbody");
-        if(tbody.children.length === 0){
-            document.querySelector("#createIngredientsStrand thead").style.display = "none";
-            document.querySelector("#finishButton").innerText = "No new ingredients";
-        }
-    },
-
-    //Creates a new, empty row in table to input data
-    newIngredientField: function(){
-        let tbody = document.querySelector("#inputField tbody");
-
-        document.querySelector("#inputField thead").style.display = "table-header-group"
-        document.querySelector("#finishButton").innerText = "Finish";
-
-        let row = document.createElement("tr");
-        tbody.appendChild(row);
-    
-        let name = document.createElement("td");
-        row.appendChild(name);
-
-        let nameInput = document.createElement("input");
-        nameInput.type = "text";
-        nameInput.classList = "inputField";
-        nameInput.onblur = ()=>{controller.checkValid("name", nameInput)};
-        name.appendChild(nameInput);
-        
-        let category = document.createElement("td");
-        row.appendChild(category);
-
-        let categoryInput = document.createElement("input");
-        categoryInput.type = "text"
-        categoryInput.classList = "inputField";
-        categoryInput.onblur = ()=>{controller.checkValid("category", categoryInput)};
-        category.appendChild(categoryInput);
-        
-        let quantity = document.createElement("td");
-        row.appendChild(quantity);
-
-        let quantityInput = document.createElement("input");
-        quantityInput.type = "number";
-        quantityInput.step = "0.01";
-        quantityInput.classList = "inputField";
-        quantityInput.onblur = ()=>{controller.checkValid("quantity", quantityInput)};
-        quantity.appendChild(quantityInput);
-    
-        let unit = document.createElement("td");
-        row.appendChild(unit);
-
-        let unitInput = document.createElement("input");
-        unitInput.type = "text";
-        unitInput.classList = "inputField";
-        unitInput.onblur = ()=>{controller.checkValid("unit", unitInput)};
-        unit.appendChild(unitInput);
-    
-        let removeTd = document.createElement("td");
-        row.appendChild(removeTd);
-
-        let removeButton = document.createElement("button");
-        removeButton.innerText = "Remove";
-        removeButton.classList = "button-small";
-        removeButton.onclick = ()=>{this.removeIngredient(row)};
-        removeTd.appendChild(removeButton);
-    },
-
-    removeIngredient: function(row){
-        if(row.parentNode.children.length <= 1){
-            document.querySelector("#createIngredientsStrand thead").style.display = "none";
-            document.querySelector("#finishButton").innerText = "No new ingredients";
-        }
-
-        row.parentNode.removeChild(row);
-    },
-
-    submit: function(){
-        let tbody = document.querySelector("#inputField tbody");
-        let isValid = true;
-
-        let newIngredients = [];
-        let axiosIngredients = [];
-        
-        for(let row of tbody.children){
-            let quantity = row.children[2].children[0].value;
-
-            let newIngredient = {
-                name: row.children[0].children[0].value,
-                category: row.children[1].children[0].value,
-                unit: row.children[3].children[0].value
-            }
-
-            if(validator.ingredient.all(newIngredient, quantity)){
-                axiosIngredients.push(newIngredient);
-
-                newIngredients.push({
-                    ingredient: newIngredient,
-                    quantity: quantity
-                });
-            }else{
-                isValid = false;
-                break;
-            }
-        }
-
-        if(controller.data.inventory.length <= 0 && axiosIngredients.length <= 0){
-            banner.createError("You must add at least one ingredient to your inventory");
-            isValid = false;
-        }
-
-        if(isValid){
-            if(axiosIngredients.length > 0){
-                axios.post("/ingredients/create", axiosIngredients)
-                    .then((response)=>{
-                        if(typeof(response.data) === "string"){
-                            banner.createError(response.data);
-                            return;
-                        }else{
-                            for(let ingredient of newIngredients){
-                                for(let createdIngredient of response.data){
-                                    if(createdIngredient.name === ingredient.ingredient.name){
-                                        ingredient.ingredient.id = createdIngredient._id; //changed id a bit here
-                                        break;
-                                    }
-                                }
-                    
-                                controller.data.inventory.push(ingredient);
-                            }
-                        }
-                    })
-                    .catch((err)=>{
-                        banner.createError("There has been an error and your ingredients have not been saved");
-                    });
-            }
-
-            if(recipes){
-                createRecipesObj.display();
-            }else{
-                nameRecipesObj.display();
-            }
-        }
-
-        
-    }
-}

+ 0 - 207
views/merchantSetupPage/createRecipes.js

@@ -1,207 +0,0 @@
-let createRecipesObj = {
-    recipeIndex: 0,
-    
-    display: function(){
-        controller.clearScreen();
-        controller.createRecipesStrand.style.display = "flex";
-
-        if(recipes){
-            controller.data.recipes = [];
-
-            for(let recipe of recipes.elements){
-                controller.data.recipes.push({
-                    name: recipe.name,
-                    posId: recipe.id,
-                    price: recipe.price,
-                    ingredients: [],
-                });
-            }
-        }
-
-        this.showRecipe();
-    },
-
-    //Loops through recipeData to create td's
-    //Displays each ingredient for current recipe
-    //Create and display correct buttons for navigation
-    showRecipe: function(){
-        let title = document.querySelector("#recipeName");
-        title.innerText = controller.data.recipes[this.recipeIndex].name;
-
-        if(!recipes){
-            document.querySelector("#price").value = controller.data.recipes[this.recipeIndex].price || 0;
-        }
-
-        let tbody = document.querySelector("#createRecipesStrand tbody");
-
-        if(controller.data.recipes[this.recipeIndex].ingredients.length <= 0){
-            document.querySelector("#createRecipesStrand table").style.display = "none";
-        }else{
-            document.querySelector("#createRecipesStrand table").style.display = "table";
-        }
-
-        for(let recipeIngredient of controller.data.recipes[this.recipeIndex].ingredients){
-            let row = document.createElement("tr");
-            tbody.appendChild(row);
-    
-            let ingredientTd = document.createElement("td");
-            row.appendChild(ingredientTd);
-
-            let ingredientName = document.createElement("select");
-            for(let inventoryIngredient of controller.data.inventory){
-                let newOption = document.createElement("option");
-                newOption.innerText = inventoryIngredient.ingredient.name;
-                newOption.value = inventoryIngredient.ingredient.id;
-                if(inventoryIngredient.ingredient.id === recipeIngredient.ingredient){
-                    newOption.selected = "selected";
-                }
-                ingredientName.appendChild(newOption);
-            }
-            ingredientTd.appendChild(ingredientName);
-    
-            let quantityTd = document.createElement("td");
-            row.appendChild(quantityTd);
-
-            let ingQuant = document.createElement("input");
-            ingQuant.type = "number";
-            ingQuant.step = "0.01";
-            ingQuant.value = recipeIngredient.quantity;
-            ingQuant.onblur = ()=>{controller.checkValid("quantity", ingQuant)};
-            quantityTd.appendChild(ingQuant);
-
-            let actionTd = document.createElement("td");
-            row.appendChild(actionTd);
-
-            let removeButton = document.createElement("button");
-            removeButton.innerText = "Remove";
-            removeButton.classList = "button-small";
-            removeButton.onclick = ()=>{this.removeRow(row)};
-            actionTd.appendChild(removeButton);
-        }
-    
-        let nextButton = document.querySelector("#next");
-        nextButton.onclick = ()=>{this.changeRecipe(1)};
-        if(this.recipeIndex === controller.data.recipes.length - 1){
-            nextButton.innerText = "Finish";
-        }else{
-            nextButton.innerText = "Next Recipe";
-        }
-    
-        let previousButton = document.querySelector("#previous");
-        if(this.recipeIndex === 0){
-            previousButton.style.display = "none";
-        }else{
-            previousButton.style.display = "inline-block";
-        }
-    },
-
-    //Adds ingredient data to recipeData
-    //Empties all data in the table
-    //Changes recipeDataIndex
-    //Hands off to showRecipe function
-    changeRecipe: function(num){
-        let tbody = document.querySelector("#createRecipesStrand tbody");
-        controller.data.recipes[this.recipeIndex].ingredients = [];
-        if(!recipes){
-            controller.data.recipes[this.recipeIndex].price = Math.floor(document.querySelector("#price").value * 100);
-        }
-        let isValid = true;
-        
-    
-        for(let row of tbody.children){
-            let quantity = row.children[1].children[0].value;
-
-            if(validator.ingredient.quantity(quantity)){
-                controller.data.recipes[this.recipeIndex].ingredients.push({
-                    ingredient: row.children[0].children[0].value,
-                    quantity: quantity
-                });
-            }else{
-                isValid = false;
-                break;
-            }
-        }
-
-        this.recipeIndex += num
-
-        if(isValid){
-            if(this.recipeIndex > controller.data.recipes.length - 1){
-                this.submit();
-            }else{
-                while(tbody.children.length > 0){
-                    tbody.removeChild(tbody.firstChild);
-                }
-
-                this.showRecipe();
-            }
-        }
-    },
-
-    //Creates a new, empty row in table to input data
-    addRecipeIngredientField: function(){
-        let tbody = document.querySelector("#createRecipesStrand tbody");
-        document.querySelector("#createRecipesStrand table").style.display = "table";
-    
-        let row = document.createElement("tr");
-        tbody.appendChild(row);
-    
-        let ingTd = document.createElement("td");
-        row.appendChild(ingTd);
-
-        let ingName = document.createElement("select");
-        for(let ingredient of controller.data.inventory){
-            let newOption = document.createElement("option");
-            newOption.innerText = ingredient.ingredient.name;
-            newOption.value = ingredient.ingredient.id;
-            ingName.appendChild(newOption);
-        }
-        ingTd.appendChild(ingName);
-    
-        let quantTd = document.createElement("td");
-        row.appendChild(quantTd);
-
-        let ingQuant = document.createElement("input");
-        ingQuant.type = "number";
-        ingQuant.step = "0.01";
-        ingQuant.min = "0";
-        ingQuant.onblur = ()=>{controller.checkValid("quantity", ingQuant)};
-        quantTd.appendChild(ingQuant);
-    
-        let removeTd = document.createElement("td");
-        row.appendChild(removeTd);
-        
-        let removeButton = document.createElement("button");
-        removeButton.innerText = "Remove";
-        removeButton.classList = "button-small";
-        removeButton.onclick = ()=>{this.removeRow(row)};
-        removeTd.appendChild(removeButton);
-    },
-
-    removeRow: function(row){
-        let tbody = document.querySelector("#createRecipesStrand tbody");
-
-        row.parentNode.removeChild(row);
-
-        if(tbody.children.length <= 0){
-            document.querySelector("#createRecipesStrand table").style.display = "none";
-        }
-    },
-
-    //Add all recipes to data variable
-    //Creates a form and submits data
-    submit: function(){        
-        let form = document.createElement("form");
-        form.method = "post";
-        form.action = recipes ? "/merchant/clover/create" : "/merchant/none/create";
-        form.style.display = "none";
-        
-        let dataInput = document.createElement("input");
-        dataInput.type = "hidden";
-        dataInput.name = "data";
-        dataInput.value = JSON.stringify(controller.data);
-    
-        form.appendChild(dataInput);
-        document.body.appendChild(form);
-        form.submit();
-    }
-}

+ 0 - 134
views/merchantSetupPage/merchantSetup.css

@@ -1,134 +0,0 @@
-/* General purpose */
-.buttonDiv{
-    display: flex;
-    justify-content: space-between;
-}
-
-    .buttonDiv > *{
-        margin: 5px;
-    }
-
-.container{
-    flex-direction: column;
-    align-items: center;
-}
-
-/* Agreement Strand */
-#agreementStrand{
-    display: flex;
-    flex-direction: column;
-    align-items: center;
-}
-
-    #agreementStrand > *{
-        margin: 10px;
-    }
-
-/* Basic Info Strand */
-#basicInfoStrand{
-    display: none;
-}
-
-    #basicInfoStrand > *{
-        margin: 10px;
-    }
-
-    #nameLabel{
-        display: none;
-    }
-
-/* Add Ingredients Strand */
-#addIngredientsStrand{
-    display: none;
-}
-
-    #addIngredientsStrand > *{
-        margin: 10px;
-    }
-
-    #addIngredientsStrand h5{
-        margin-top: 0;
-    }
-
-    .clickable{
-        cursor: pointer;
-    }
-
-/* Create Ingredients Strand */
-#createIngredientsStrand{
-    display: none;
-}
-
-    #createIngredientsStrand > *{
-        margin: 10px;
-    }
-
-/* Name Recipes Strand */
-#nameRecipesStrand{
-    display: none;
-}
-
-    #nameRecipesStrand > *{
-        margin: 10px;
-    }
-
-/* Create Recipes Strand */
-#createRecipesStrand{
-    display: none;
-}
-
-    #createRecipesStrand > *{
-        margin: 10px;
-    }
-
-    #recipeName{
-        color: #ff626b;
-    }
-
-@media screen and (max-width: 1000px){
-    /* createIngredientsStrand */
-    #createIngredientsStrand td, #createIngredientsStrand th{
-        font-size: 15px;
-        padding: 5px;
-    }
-
-    #createIngredientsStrand .button{
-        font-size: 16px;
-    }
-
-    .inputField{
-        max-width: 100px;
-    }
-}
-
-@media screen and (max-width: 600px){
-    .inputField{
-        max-width: 50px;
-    }
-
-    /* addIngredientsStrand */
-    #addIngredientsStrand h1, #addIngredientsStrand h5{
-        text-align: center;
-    }
-
-    #addIngredientsStrand td, #addIngredientsStrand th{
-        font-size: 12px;
-        padding: 2px;
-    }
-
-    /* createIngredientsStrand */
-    #createIngredientsStrand td, #createIngredientsStrand th{
-        font-size: 12px;
-        padding: 2px;
-    }
-
-    #createIngredientsStrand .button{
-        font-size: 13px;
-    }
-
-    /* createRecipesStrand */
-    #createRecipesStrand td, #createRecipesStrand th{
-        font-size: 12px;
-        padding: 2px;
-    }
-}

+ 0 - 151
views/merchantSetupPage/merchantSetup.ejs

@@ -1,151 +0,0 @@
-<!DOCTYPE html>
-<html lang="en">
-    <head>
-        <meta charset="UTF-8">
-        <title>The Subline</title>
-        <link rel="icon" type="img/png" href="/shared/images/logo.png">
-        <link rel="stylesheet" href="/merchantSetupPage/merchantSetup.css">
-        <link rel="stylesheet" href="/shared/shared.css">
-    </head>
-    <body>
-        <% include ../shared/header %>
-
-        <% include ../shared/banner %>
-
-        <div id="basicInfoStrand" class="container">
-            <h1>Basic Information</h1>
-
-            <form onsubmit="basicInfoObj.submit()">
-                <label id="nameLabel">Name
-                    <input id="regName" type="text">
-                </label>
-
-                <label>Email
-                    <input id="regEmail" type="email" required>
-                </label>
-
-                <label>Password
-                    <input id="regPass" type="password" required>
-                </label>
-
-                <label>Confirm Password
-                    <input id="regConfirmPass" type="password" required>
-                </label>
-
-                <label>
-                    <input id="agree" onclick="basicInfoObj.agree()" type="checkbox">
-                    I agree to the <a href="/legal" target="_blank">Privacy Policy & Terms and Conditions</a>
-                </label>
-
-                <input id="subButton" class="buttonDisabled" type="Submit" value="Continue" disabled>
-            </form>
-        </div>
-
-        <div id="addIngredientsStrand" class="container">
-            <h1>Choose the ingredients in your inventory</h1>
-
-            <h5>(Can't find something?  You can create it in the next step)</h5>
-
-            <input id="filter" type="text" onkeyup="addIngredientsObj.filter()" placeholder="FILTER INGREDIENTS">
-            
-            <table id="ingredient-display">
-                <thead>
-                    <tr>
-                        <th>Add</th>
-                        <th class="clickable" onclick="addIngredientsObj.sortIngredients('name')">Ingredient</th>
-                        <th class="clickable" onclick="addIngredientsObj.sortIngredients('category')">Category</th>
-                        <th>Quantity</th>
-                        <th class="clickable" onclick="addIngredientsObj.sortIngredients('unit')">Unit</th>
-                    </tr>
-                </thead>
-                <tbody></tbody>
-            </table>
-
-            <button class="button" onclick="addIngredientsObj.submit()">Continue</button>
-        </div>
-
-        <div id="createIngredientsStrand" class="container">
-            <h1>Create ingredients for your inventory</h1>
-
-            <div class="buttonDiv">
-                <button class="button" onclick="addIngredientsObj.display()">Back</button>
-
-                <button class="button" onclick="createIngredientsObj.newIngredientField()">Create Ingredient</button>
-
-                <button class="button" id="finishButton" onclick="createIngredientsObj.submit()">No new ingredients</button>
-            </div>
-
-            <table id="inputField">
-                <thead>
-                    <tr>
-                        <th>Ingredient Name</th>
-                        <th>Category</th>
-                        <th>Quantity</th>
-                        <th>Measurement Unit</th>
-                        <th>Actions</th>
-                    </tr>
-                </thead>
-                <tbody></tbody>
-            </table>
-            
-        </div>
-
-        <div id="nameRecipesStrand" class="container">
-            <h1>Name your recipes</h1>
-
-            <button class="button" onclick="nameRecipesObj.addNameField()">Add Recipe</button>
-
-            <div id="nameList"></div>
-
-            <button class="button" onclick="nameRecipesObj.submit()">Submit</button>
-        </div>
-
-        <div id="createRecipesStrand" class="container">
-            <h1>Add ingredients to your recipes</h1>
-
-            <h2 id="recipeName"></h2>
-
-            <div class="buttonDiv">
-                <button class="button" onclick="createRecipesObj.addRecipeIngredientField()">Add Ingredient</button>
-
-                <button class="button" id="next">Next Recipe</button>
-
-                <button class="button" id="previous" onclick="createRecipesObj.changeRecipe(-1)">Previous Recipe</button>
-            </div>
-
-            <% if(!locals.recipes){ %>
-                <label>Price:
-                    <input id="price" type="number" step="0.01" min="0" placeholder="enter price" required> 
-                </label>
-            <% } %>
-
-            <table>
-                <thead>
-                    <tr>
-                        <th>Ingredient</th>
-                        <th>Quantity</th>
-                        <th>Actions</th>
-                    </tr>
-                </thead>
-                <tbody></tbody>
-            </table>
-        </div>
-
-        <%- include ../shared/footer %>
-
-        <script>
-            let ingredients = <%- JSON.stringify(ingredients) %>;
-            let recipes = <%- JSON.stringify(recipes) %>;
-            let error = <%- JSON.stringify(error) %>;
-        </script>
-        <script src="https://unpkg.com/axios/dist/axios.min.js"></script>
-        <script src="/shared/validation.js"></script>
-        <script src="/merchantSetupPage/basicInfo.js"></script>
-        <script src="/merchantSetupPage/addIngredients.js"></script>
-        <script src="/merchantSetupPage/createIngredients.js"></script>
-        <script src="/merchantSetupPage/nameRecipes.js"></script>
-        <script src="/merchantSetupPage/createRecipes.js"></script>
-        <script src="/merchantSetupPage/controller.js"></script>
-    </body>
-</html>
-

+ 0 - 39
views/merchantSetupPage/nameRecipes.js

@@ -1,39 +0,0 @@
-let nameRecipesObj = {
-    display: function(){
-        controller.clearScreen();
-        controller.nameRecipesStrand.style.display = "flex";
-
-        this.addNameField();
-    },
-
-    //Add another input box to input another recipe name
-    addNameField: function(){
-        let nameList = document.querySelector("#nameList");
-
-        let nameDiv = document.createElement("div");
-        nameList.appendChild(nameDiv);
-
-        let nameInput = document.createElement("input");
-        nameInput.type = "text";
-        nameDiv.appendChild(nameInput);
-
-        let nameRemove = document.createElement("button");
-        nameRemove.innerText = "Remove";
-        nameRemove.classList = "button-small";
-        nameRemove.onclick = ()=>{nameDiv.parentNode.removeChild(nameDiv)};
-        nameDiv.appendChild(nameRemove);
-    },
-
-    submit: function(){
-        controller.data.recipes = [];
-
-        for(let nameDiv of document.querySelector("#nameList").children){
-            controller.data.recipes.push({
-                name: nameDiv.children[0].value,
-                ingredients: []
-            });
-        }
-
-        createRecipesObj.display();
-    }
-}