Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactored code #110

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

## Description
The Storventory app a inventory management system for small restaurants. It is setup to support multiple restaurant owners with multiple restaurants each. There is a separate inventory per restaurant. And you are able to create an account and search and purchase the necessary products your restaurant or restaurants need.

![Screenshot of Storventory (Shopping List Page on Mobile)](https://storventory.herokuapp.com/images/screenshot-1.png)
![Screenshot of Storventory (Inventory Page on Mobile)](https://storventory.herokuapp.com/images/screenshot-2.png)
![Screenshot of Storventory (Restaurants Page on Mobile)](https://storventory.herokuapp.com/images/screenshot-3.png)
![Screenshot of Storventory (Restaurants Page on Desktop)](https://storventory.herokuapp.com/images/screenshot-4.png)

## Table of Contents

* [Technologies](#Technologies)
Expand Down
19 changes: 19 additions & 0 deletions controllers/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
"use strict";

const fs = require("fs");
const path = require("path");
const basename = path.basename(module.filename);

module.exports = function(app) {
fs.readdirSync(__dirname)
.filter(file => {
return (
file.indexOf(".") !== 0 && file !== basename && file.slice(-3) === ".js"
);
})
.forEach(file => {
require("./" + file)(app);
});

module.exports = app;
};
23 changes: 23 additions & 0 deletions controllers/restaurantsController.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,4 +71,27 @@ module.exports = function(app) {
res.render("login");
}
});

app.get("/places", isAuthenticated, (req, res) => {
console.log(req);
let key = "";
if (fs.existsSync(__dirname + "/../config/config.json")) {
key = require(__dirname + "/../config/config.json").development.placeskey;
} else if (process.env.GOOGLEPLACES_KEY) {
key = process.env.GOOGLEPLACES_KEY;
} else {
return;
}

const result = request(
"https://maps.googleapis.com/maps/api/place/autocomplete/json?input=" +
req.body.text +
"&key=" +
key +
"&sessiontoken=" +
req.body.session
);

res.json(result);
});
};
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
"author": "",
"license": "ISC",
"dependencies": {
"chai": "^4.1.2",
"chai-http": "^4.0.0",
"bcryptjs": "2.4.3",
"express": "^4.17.1",
"express-handlebars": "^5.1.0",
Expand Down
Binary file added public/images/screenshot-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/images/screenshot-2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/images/screenshot-3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/images/screenshot-4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 6 additions & 4 deletions public/js/inventory.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,11 @@ $(document).ready(() => {
});
// Delete row on delete button click
$(document).on("click", ".delete", function() {
$(this)
.parents("tr")
.remove();
$(".add-new").removeAttr("disabled");
$.ajax({
method: "DELETE",
url: "/api/inventory/" + $(this).attr("data-id")
}).then(() => {
window.location.reload();
});
});
});
23 changes: 18 additions & 5 deletions public/js/restaurants.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,23 @@
$(document).ready(() => {
const uuid = require("uuid");
const session = uuid.v4();
let session = "";
$("#location").on("input", () => {
if (session === "") {
session = new Date().getTime();
}
const text = $("#location");

console.log("init");
console.log(uuid);
console.log(session);
$.ajax({
method: "GET",
url: "/places",
body: {
text: text.val().trim(),
session: session
}
}).then(data => {
console.log(data);
window.location.reload();
});
});

// const queryText = "";

Expand Down
5 changes: 1 addition & 4 deletions server.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,7 @@ app.engine("handlebars", exphbs({ defaultLayout: "template" }));
app.set("view engine", "handlebars");

// Requiring our routes
require("./controllers/loginController.js")(app);
require("./controllers/restaurantsController.js")(app);
require("./controllers/inventoryController.js")(app);
require("./controllers/shopController.js")(app);
require("./controllers")(app);

// Syncing our database and logging a message to the user upon success
db.sequelize.sync({ force: true }).then(() => {
Expand Down
8 changes: 4 additions & 4 deletions views/dashboard.handlebars
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!-- Item search bar -->
<nav class="navbar navbar-light bg-light">
{{!-- <nav class="navbar navbar-light bg-light">
<form class="form-inline">
<input class="form-control mr-sm-2" type="search" placeholder="Product Search" aria-label="Search">
<button class="btn btn-outline-success my-2 my-sm-0" type="submit">Search</button>
Expand All @@ -9,7 +9,7 @@
<div class="navbar" style="vertical-align: middle;">
<div class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="#" id="cart" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"><i class="fa fa-shopping-cart"></i>Cart <span class="badge">0</span></a>
{{!-- <!-- dropdown cart -->
<!-- dropdown cart -->
<div class="dropdown-menu" aria-labelledby="navbarDropdown">
<div class="container">
<div class="shopping-cart">
Expand Down Expand Up @@ -45,10 +45,10 @@
</div>
</div>
</div>
</div> --}}
</div>
</div>
</div>
</nav>
</nav> --}}

<!-- Show item, description, quantity, and desired stock amount -->
<div class="container-lg">
Expand Down