`;
@@ -76,12 +82,6 @@ class NavBar extends Component {
this.SetupHamburger();
this.OnLogin();
- if (localStorage.admin === true) {
- this.root.querySelector('.stock-mode').style.display = 'flex';
- } else {
- this.root.querySelector('.stock-mode').style.display = 'none';
- }
-
StorageListener.ListenOnKey('admin', (e) => {
const admin = e.value;
if (admin) {
@@ -91,8 +91,9 @@ class NavBar extends Component {
}
});
- this.root.querySelector('stock-slider').addEventListener('change', (e) => {
- console.log(e);
+ this.root.querySelector('.stock-slider').addEventListener('change', (e) => {
+ const stock = e.target.checked;
+ localStorage.setItem('stock-mode', stock);
});
// setup log in button
diff --git a/client/public/featured/index.html b/client/public/featured/index.html
index cf4c118..6bf8fb7 100644
--- a/client/public/featured/index.html
+++ b/client/public/featured/index.html
@@ -1,6 +1,6 @@
- LegoLog: Featured Sets
+ LegoLog Featured Sets
@@ -22,11 +22,9 @@
-
-
diff --git a/client/public/index.mjs b/client/public/index.mjs
index c1df717..0f4c110 100644
--- a/client/public/index.mjs
+++ b/client/public/index.mjs
@@ -1,7 +1,7 @@
// import { RendererPreInit, BrickRenderer } from './brick-renderer/index.mjs';
import { InitAuth0 } from './auth.mjs';
-import * as StorageListener from './localStorage-listener.mjs';
+import * as StorageListener from './localstorage-listener.mjs';
function main() {
InitAuth0();
diff --git a/client/public/localStorage-listener.mjs b/client/public/localStorage-listener.mjs
index b8f89cb..f92ec20 100644
--- a/client/public/localStorage-listener.mjs
+++ b/client/public/localStorage-listener.mjs
@@ -1,4 +1,8 @@
-
+// this was made for the purpose of being able to listen to changes in localStorage
+// because i needed that to see if the user was admin or not to display certain elements
+// in the navbar
+// HOWEVERRRRRRRRRRRRRRRRR it would have been like SUPER SUPER useful when making the
+// basket. hey whatever it's done now. TODO for a future refractor i guess...
const CallbackKeyArray = [];
const OldSetItem = localStorage.setItem;
@@ -19,6 +23,7 @@ function OnStorage(event) {
}
export function Init() {
+ // WHAAAAAAAAAAAAAAAAAAAAAT
localStorage.setItem = function (key, value) {
OldSetItem.apply(this, arguments);
OnStorage({
diff --git a/client/public/product/index.html b/client/public/product/index.html
index 4878c78..27a768f 100644
--- a/client/public/product/index.html
+++ b/client/public/product/index.html
@@ -1,6 +1,6 @@
- LegoLog!
+ LegoLog Product Page
@@ -18,7 +18,6 @@
-
diff --git a/client/public/search/index.html b/client/public/search/index.html
index 610696d..36e5cb5 100644
--- a/client/public/search/index.html
+++ b/client/public/search/index.html
@@ -1,6 +1,6 @@
- LegoLog: Featured Sets
+ LegoLog Search Results
diff --git a/db/dump.sql b/db/dump.sql
index 823cf10..928b6b7 100644
--- a/db/dump.sql
+++ b/db/dump.sql
@@ -16539,3 +16539,7 @@ INSERT INTO lego_set_inventory (set_id, stock, price, new_price, last_updated) V
-- admin user
INSERT INTO users (id, email, admin, nickname, date_created, date_updated) VALUES ('62686cdead060b0068fe7d38', 'systemadmin@legolog.com', true, 'systemadmin', NOW(), NOW());
+
+-- offer code
+
+INSERT INTO offer_code (code, discount, discount_type, min_order_value, type, expiry_date) VALUES ('LEGO10', 10, 1, 10.00, 'set', '2022-06-10');
diff --git a/db/schema.sql b/db/schema.sql
index e17b183..696a61a 100644
--- a/db/schema.sql
+++ b/db/schema.sql
@@ -90,22 +90,34 @@ CREATE TABLE IF NOT EXISTS users (
date_updated TIMESTAMP WITHOUT TIME ZONE NOT NULL
);
-CREATE TABLE IF NOT EXISTS orders (
+CREATE TABLE IF NOT EXISTS order_log (
id VARCHAR (50) NOT NULL PRIMARY KEY,
- user_id VARCHAR (50) NOT NULL,
+ user_id VARCHAR (50) NOT NULL, -- 0 if guest
+ subtotal DECIMAL NOT NULL,
date_placed TIMESTAMP WITHOUT TIME ZONE NOT NULL,
FOREIGN KEY ( user_id ) REFERENCES users( id )
);
-CREATE TABLE IF NOT EXISTS order_items (
+CREATE TABLE IF NOT EXISTS order_item (
order_id VARCHAR (50) NOT NULL,
brick_id VARCHAR (50),
-- colour is a modifier for the brick
brick_colour INT,
set_id VARCHAR (50),
amount INT NOT NULL,
- FOREIGN KEY ( order_id ) REFERENCES orders( id ),
+ price_paid DECIMAL NOT NULL,
+ FOREIGN KEY ( order_id ) REFERENCES order_log( id ),
FOREIGN KEY ( brick_id ) REFERENCES lego_brick( id ),
FOREIGN KEY ( brick_colour ) REFERENCES lego_brick_colour( id ),
FOREIGN KEY ( set_id ) REFERENCES lego_set( id )
);
+
+CREATE TABLE IF NOT EXISTS offer_code (
+ id SERIAL NOT NULL PRIMARY KEY,
+ code TEXT NOT NULL,
+ discount DECIMAL NOT NULL, -- percentage or fixed amount
+ discount_type INT NOT NULL, -- 0 = percentage, 1 = fixed amount
+ min_order_value DECIMAL NOT NULL,
+ type TEXT NOT NULL, -- set or brick
+ expiry_date TIMESTAMP WITHOUT TIME ZONE NOT NULL
+);
diff --git a/src/routes/helpers.js b/src/routes/helpers.js
index e117dfa..a2e65fd 100644
--- a/src/routes/helpers.js
+++ b/src/routes/helpers.js
@@ -2,8 +2,7 @@ const BrickController = require('../controllers/brick-controller.js');
const SetController = require('../controllers/set-controller.js');
const Logger = require('../logger.js');
-// AppEng Deadline
-const EndDate = new Date(1651269600 * 1000);
+const EndDate = new Date('2022-06-10T00:00:00.000Z');
function Special(req, res) {
res.send({
@@ -15,6 +14,8 @@ function Special(req, res) {
}
async function CalculateBasketPrice(req, res) {
+ // and here we remmeber the c days where you had to declare all
+ // of your variables at the top of the scope *ah*
const setList = [];
const setQuantities = [];
const brickList = [];