diff --git a/.gitignore b/.gitignore index 9394583..b81b10e 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ node_modules public/stylesheets .DS_Store config.js +.idea diff --git a/config.js.dist b/config.js.dist index 1f96101..a9d65b1 100644 --- a/config.js.dist +++ b/config.js.dist @@ -8,6 +8,6 @@ module.exports = { 'user': '', 'password': '', 'database': '', - 'debug': true + 'debug': true } } diff --git a/public/javascripts/templates/cart.html b/public/javascripts/templates/cart.html new file mode 100644 index 0000000..df8fec0 --- /dev/null +++ b/public/javascripts/templates/cart.html @@ -0,0 +1,23 @@ +
+

Koszyk

+
+ +
+ + + + + + + + + + + + + + + +
Id produktuNazwa produktuCena produktuOpiss
{{ product.id }}{{ product.name }}{{ product.price }}{{ product.description }}Usuń
+
+
Niestety, nie dodano jeszcze żadnych produktów do koszyka.
\ No newline at end of file diff --git a/public/javascripts/templates/product-detail.html b/public/javascripts/templates/product-detail.html index d35f19f..0250e43 100644 --- a/public/javascripts/templates/product-detail.html +++ b/public/javascripts/templates/product-detail.html @@ -14,4 +14,4 @@
-Dodaj do koszyka +Dodaj do koszyka diff --git a/src/controllers/cart.js b/src/controllers/cart.js new file mode 100644 index 0000000..1086cfe --- /dev/null +++ b/src/controllers/cart.js @@ -0,0 +1,22 @@ +module.exports.controller = function(app, mysql) { + app.post('/cart/add', function(req, res) { + if (!req.session.products) { + req.session.products = []; + } + + req.session.products.push(req.body); + res.send(200, null); + }); + + app.delete('/cart/:id/remove', function(req, res) { + req.session.products = (req.session.products || []).filter(function(product) { + return product.id != req.params.id; + }); + + res.send(200, null); + }); + + app.get('/cart', function(req, res) { + res.send(200, req.session.products || []); + }); +} \ No newline at end of file diff --git a/src/services/authManager.js b/src/services/authManager.js index abe1301..e5ba0f7 100644 --- a/src/services/authManager.js +++ b/src/services/authManager.js @@ -1,5 +1,5 @@ module.exports = { - administratorEmailAddress: ['mateusz.nowak@xsolve.pl'], + administratorEmailAddress: ['mateusz.nowak@xsolve.pl', 'paykitson@gmail.com'], isAdmin: function(profile) { var self = this, diff --git a/src/views/index.ejs b/src/views/index.ejs index bfa5a85..49e5f3f 100644 --- a/src/views/index.ejs +++ b/src/views/index.ejs @@ -19,6 +19,7 @@ Admin <% } %> Wyloguj + Koszyk <% } else { %> Zaloguj <% } %>