diff --git a/.gitignore b/.gitignore index 9d67d47..8ab70e2 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ /static/bundle.js /static/bundle.js.map .DS_Store +.env diff --git a/SQL rebuild.sql b/SQL rebuild.sql new file mode 100644 index 0000000..c1c5d9f --- /dev/null +++ b/SQL rebuild.sql @@ -0,0 +1,83 @@ +DROP TABLE anorder, menu, order_basket + +CREATE TABLE menu ( +id SERIAL, +name TEXT NOT NULL, +price numeric (4,2) default 0 NOT NULL, +quantity numeric (5) default 0 NOT NULL, +type TEXT NOT NULL, +image TEXT, +header TEXT, +description TEXT, +more_info TEXT, +PRIMARY KEY (id) +); + +CREATE TABLE order_basket ( +id serial, +time TIMESTAMP default current_timestamp NOT NULL, +cust_name TEXT, +email TEXT NOT NULL, +cust_address TEXT NOT NULL, +postcode TEXT, +phone TEXT, +PRIMARY KEY (id) +); + +CREATE TABLE anorder ( +id serial, +menu_id INT NOT NULL, +quantity NUMERIC(5,0) NOT NULL, +order_basket_id INT NOT NULL, +PRIMARY KEY (id), +FOREIGN KEY (order_basket_id) REFERENCES order_basket (id), +FOREIGN KEY (menu_id) REFERENCES menu (id) +); + +-- INSERT INTO menu VALUES (1, 'Steak Hache', 11, 100, 'main', 'https://media.blueapron.com/recipes/2121/square_newsletter_images/1490637106-4-0003-6001/403_2PRE07-steak-frites-18311_WEB_SQ_hi_res.jpg'); +-- INSERT INTO menu VALUES (2, 'Raclette', 9, 100, 'main', 'https://www.lavenderandlovage.com/wp/wp-content/uploads/2015/02/Tartiflette-15-1024x711.jpg'); +-- INSERT INTO menu VALUES (3, 'Iles flottantes', 4, 100, 'dessert', 'https://www.cookomix.com/wp-content/uploads/2017/11/iles-flottantes-thermomix-800x600.jpg'); +-- INSERT INTO menu VALUES (4, 'Foie Gras', 10, 100, 'starter', 'https://s23991.pcdn.co/wp-content/uploads/2010/12/seared-foie-gras-recipe.jpg'); +-- ALTER SEQUENCE menu_id_seq RESTART WITH 5 INCREMENT BY 1; + + + + +INSERT INTO menu VALUES (0, 'SMASHED AVO, OUR WAY', 7, 100, 'brunch', 'https://media.blueapron.com/recipes/2121/square_newsletter_images/1490637106-4-0003-6001/403_2PRE07-steak-frites-18311_WEB_SQ_hi_res.jpg', 'Smashed avo on Dusty Knuckle seeded rye', 'Smashed avo on Dusty Knuckle seeded rye w/ walnutand sumac crumble, chilli oil and orange zest.', 'Add a poached egg or two £1.25 / £2.50 add hot smoked salmon £4.5'); +INSERT INTO menu VALUES (1, 'VEGAN DREAMING', 8.5, 100, 'brunch', 'https://www.lavenderandlovage.com/wp/wp-content/uploads/2015/02/Tartiflette-15-1024x711.jpg', 'Dusty Knuckle potato sour dough served w/ homemade beetroot relish', 'Dusty Knuckle potato sour dough served w/ homemade beetroot relish, avocado, confit mushrooms, watercress and mixed seed salad with homemade coriander and cashew cream.', 'Un vegan it…add 2 poached eggs £2.5 Seriously un vegan it! add bacon £2.5'); +INSERT INTO menu VALUES (2, 'OKONOMI-YUMMI!', 10.5, 100, 'brunch', 'https://media.blueapron.com/recipes/2121/square_newsletter_images/1490637106-4-0003-6001/403_2PRE07-steak-frites-18311_WEB_SQ_hi_res.jpg', 'Our take on the Japanese classic', 'Our take on the Japanese classic. Thick savoury Japanese pancake (gf) w/ avocado, a poached egg & all the trimmings...think tonkatsu sauce, homemade miso kewpie, bonito fish flakes, fried shallots.', 'Add crispy bacon or halloumi £2.5 Add hot smoked salmon £4.5 Make it veggie just ask ; )'); +INSERT INTO menu VALUES (3, 'CAULIFLOWER TOAST', 9.5, 100, 'brunch', 'https://media.blueapron.com/recipes/2121/square_newsletter_images/1490637106-4-0003-6001/403_2PRE07-steak-frites-18311_WEB_SQ_hi_res.jpg', 'Homemade roasted cauliflower bread (gf)', 'Homemade roasted cauliflower bread (gf) served w/ our fennel jam, avocado, a poached egg drizzled with toasted sunflower tahini.', 'Add halloumi or crispy bacon £2.5'); +INSERT INTO menu VALUES (4, 'AUTUMN HASH', 11.5, 100, 'brunch', 'https://media.blueapron.com/recipes/2121/square_newsletter_images/1490637106-4-0003-6001/403_2PRE07-steak-frites-18311_WEB_SQ_hi_res.jpg', 'Potato and smoked mozzarella pikelet (gf)', 'Potato and smoked mozzarella pikelet (gf) (think hash brown!) served w/ warm celeriac remoulade, bacon crumb, a fried egg and homemade red pepper ketchup', 'Add bacon or halloumi £2.5 Make it veggie...just ask:)'); +INSERT INTO menu VALUES (5, 'UP STREAM DREAM', 9.5, 100, 'brunch', 'https://media.blueapron.com/recipes/2121/square_newsletter_images/1490637106-4-0003-6001/403_2PRE07-steak-frites-18311_WEB_SQ_hi_res.jpg', 'Home hot smoked salmon w/ warm pearled spelt', 'Home hot smoked salmon w/ warm pearled spelt & honeyroasted pumpkin salad, salsa verde and a poached egg.', 'Add avocado £2.5'); +INSERT INTO menu VALUES (6, 'BACON BENEDICT', 9.5, 100, 'brunch', 'https://media.blueapron.com/recipes/2121/square_newsletter_images/1490637106-4-0003-6001/403_2PRE07-steak-frites-18311_WEB_SQ_hi_res.jpg', 'Maple glazed crispy bacon served on a brick lane bagel', 'Maple glazed crispy bacon served on a brick lane bagel w/ spinach, poached eggs and hollandaise sauce', 'Swap bacon for house hot smoked salmon £3 Add Avocado £2.5'); +INSERT INTO menu VALUES (7, 'CHILLI POACHED EGGS', 9.5, 100, 'brunch', 'https://media.blueapron.com/recipes/2121/square_newsletter_images/1490637106-4-0003-6001/403_2PRE07-steak-frites-18311_WEB_SQ_hi_res.jpg', 'Dusty Knuckle potato sour dough served w/ wilted spinach', 'Dusty Knuckle potato sour dough served w/ wilted spinach, whipped garlic yoghurt, poached eggs and chilli & dill butter.', 'Add bacon, halloumi or avocado £2.5'); +INSERT INTO menu VALUES (8, 'CLEMENTINE & CASHEW SMOOTHIE', 5.5, 100, 'drinks', 'https://media.blueapron.com/recipes/2121/square_newsletter_images/1490637106-4-0003-6001/403_2PRE07-steak-frites-18311_WEB_SQ_hi_res.jpg'); +INSERT INTO menu VALUES (9, 'SUPER GREEN SMOOTHIE', 5.5, 100, 'drinks', 'https://media.blueapron.com/recipes/2121/square_newsletter_images/1490637106-4-0003-6001/403_2PRE07-steak-frites-18311_WEB_SQ_hi_res.jpg', 'w/ avocado, spinach, banana, matcha, honey'); +INSERT INTO menu VALUES (10, 'MACADAMIA & BANANA SMOOTHIE', 5.5, 100, 'drinks', 'https://media.blueapron.com/recipes/2121/square_newsletter_images/1490637106-4-0003-6001/403_2PRE07-steak-frites-18311_WEB_SQ_hi_res.jpg'); +INSERT INTO menu VALUES (11, 'ESPRESSO SMOOTHIE', 4.5, 100, 'drinks', 'https://media.blueapron.com/recipes/2121/square_newsletter_images/1490637106-4-0003-6001/403_2PRE07-steak-frites-18311_WEB_SQ_hi_res.jpg', 'w/ espresso, banana, dates, milk'); +INSERT INTO menu VALUES (12, 'ORANGE JUICE', 3, 100, 'drinks', 'https://media.blueapron.com/recipes/2121/square_newsletter_images/1490637106-4-0003-6001/403_2PRE07-steak-frites-18311_WEB_SQ_hi_res.jpg'); +INSERT INTO menu VALUES (13, 'APPLE JUICE', 3, 100, 'drinks', 'https://media.blueapron.com/recipes/2121/square_newsletter_images/1490637106-4-0003-6001/403_2PRE07-steak-frites-18311_WEB_SQ_hi_res.jpg'); +INSERT INTO menu VALUES (14, 'CLEANSE', 3, 100, 'drinks', 'https://media.blueapron.com/recipes/2121/square_newsletter_images/1490637106-4-0003-6001/403_2PRE07-steak-frites-18311_WEB_SQ_hi_res.jpg', 'carrot, lemon and ginger'); +INSERT INTO menu VALUES (15, 'FUEL', 3, 100, 'drinks', 'https://media.blueapron.com/recipes/2121/square_newsletter_images/1490637106-4-0003-6001/403_2PRE07-steak-frites-18311_WEB_SQ_hi_res.jpg', 'beetroot, apple and celery'); +INSERT INTO menu VALUES (17, 'BLONDIE', 3.5, 100, 'dessert', 'https://media.blueapron.com/recipes/2121/square_newsletter_images/1490637106-4-0003-6001/403_2PRE07-steak-frites-18311_WEB_SQ_hi_res.jpg', 'Matcha and White Chocolate' ); +INSERT INTO menu VALUES (18, 'BROWNIE', 3.5, 100, 'dessert', 'https://media.blueapron.com/recipes/2121/square_newsletter_images/1490637106-4-0003-6001/403_2PRE07-steak-frites-18311_WEB_SQ_hi_res.jpg'); + +ALTER SEQUENCE menu_id_seq RESTART WITH 19 INCREMENT BY 1; + +INSERT INTO order_basket VALUES (1, '2011-05-16 15:36:38', 'Chris P','15 Dekker','E8 3FS', '07714205581'); +INSERT INTO order_basket VALUES (2, '2011-05-16 15:36:38','Chris P','15 Dekker','E8 3FS', '07714205581'); +INSERT INTO order_basket VALUES (3, '2011-05-16 15:36:38','Chris P','15 Dekker','E8 3FS', '07714205581'); +ALTER SEQUENCE order_basket_id_seq RESTART WITH 4 INCREMENT BY 1; + +INSERT INTO anorder VALUES (1, 2, 1, 1); +INSERT INTO anorder VALUES (2, 4, 3, 1); +INSERT INTO anorder VALUES (3, 3, 2, 2); +INSERT INTO anorder VALUES (4, 1, 2, 3); +ALTER SEQUENCE anorder_id_seq RESTART WITH 5 INCREMENT BY 1; + + + + + + + diff --git a/delivereat-db.code-workspace b/delivereat-db.code-workspace new file mode 100644 index 0000000..ee986b8 --- /dev/null +++ b/delivereat-db.code-workspace @@ -0,0 +1,16 @@ +{ + "folders": [ + { + "path": "." + }, + { + "path": "B:\\MacDocs\\delivereat" + }, + { + "path": "B:\\MacDocs\\react-cinema" + } + ], + "settings": { + "liveServer.settings.multiRootWorkspaceName": "delivereat-with-db" + } +} diff --git a/package-lock.json b/package-lock.json index 167f7e9..1023bdb 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,5 +1,5 @@ { - "name": "react-testing", + "name": "deliveat-with-db", "version": "1.0.0", "lockfileVersion": 1, "requires": true, @@ -1016,7 +1016,6 @@ "version": "6.24.1", "resolved": "https://registry.npmjs.org/babel-helper-bindify-decorators/-/babel-helper-bindify-decorators-6.24.1.tgz", "integrity": "sha1-FMGeXxQte0fxmlJDHlKxzLxAozA=", - "dev": true, "requires": { "babel-runtime": "^6.22.0", "babel-traverse": "^6.24.1", @@ -1027,7 +1026,6 @@ "version": "6.24.1", "resolved": "https://registry.npmjs.org/babel-helper-builder-binary-assignment-operator-visitor/-/babel-helper-builder-binary-assignment-operator-visitor-6.24.1.tgz", "integrity": "sha1-zORReto1b0IgvK6KAsKzRvmlZmQ=", - "dev": true, "requires": { "babel-helper-explode-assignable-expression": "^6.24.1", "babel-runtime": "^6.22.0", @@ -1073,7 +1071,6 @@ "version": "6.24.1", "resolved": "https://registry.npmjs.org/babel-helper-explode-assignable-expression/-/babel-helper-explode-assignable-expression-6.24.1.tgz", "integrity": "sha1-8luCz33BBDPFX3BZLVdGQArCLKo=", - "dev": true, "requires": { "babel-runtime": "^6.22.0", "babel-traverse": "^6.24.1", @@ -1084,7 +1081,6 @@ "version": "6.24.1", "resolved": "https://registry.npmjs.org/babel-helper-explode-class/-/babel-helper-explode-class-6.24.1.tgz", "integrity": "sha1-fcKjkQ3uAHBW4eMdZAztPVTqqes=", - "dev": true, "requires": { "babel-helper-bindify-decorators": "^6.24.1", "babel-runtime": "^6.22.0", @@ -1096,7 +1092,6 @@ "version": "6.24.1", "resolved": "https://registry.npmjs.org/babel-helper-function-name/-/babel-helper-function-name-6.24.1.tgz", "integrity": "sha1-00dbjAPtmCQqJbSDUasYOZ01gKk=", - "dev": true, "requires": { "babel-helper-get-function-arity": "^6.24.1", "babel-runtime": "^6.22.0", @@ -1109,7 +1104,6 @@ "version": "6.24.1", "resolved": "https://registry.npmjs.org/babel-helper-get-function-arity/-/babel-helper-get-function-arity-6.24.1.tgz", "integrity": "sha1-j3eCqpNAfEHTqlCQj4mwMbG2hT0=", - "dev": true, "requires": { "babel-runtime": "^6.22.0", "babel-types": "^6.24.1" @@ -1150,7 +1144,6 @@ "version": "6.24.1", "resolved": "https://registry.npmjs.org/babel-helper-remap-async-to-generator/-/babel-helper-remap-async-to-generator-6.24.1.tgz", "integrity": "sha1-XsWBgnrXI/7N04HxySg5BnbkVRs=", - "dev": true, "requires": { "babel-helper-function-name": "^6.24.1", "babel-runtime": "^6.22.0", @@ -1238,14 +1231,12 @@ "babel-plugin-syntax-async-functions": { "version": "6.13.0", "resolved": "https://registry.npmjs.org/babel-plugin-syntax-async-functions/-/babel-plugin-syntax-async-functions-6.13.0.tgz", - "integrity": "sha1-ytnK0RkbWtY0vzCuCHI5HgZHvpU=", - "dev": true + "integrity": "sha1-ytnK0RkbWtY0vzCuCHI5HgZHvpU=" }, "babel-plugin-syntax-async-generators": { "version": "6.13.0", "resolved": "https://registry.npmjs.org/babel-plugin-syntax-async-generators/-/babel-plugin-syntax-async-generators-6.13.0.tgz", - "integrity": "sha1-a8lj67FuzLrmuStZbrfzXDQqi5o=", - "dev": true + "integrity": "sha1-a8lj67FuzLrmuStZbrfzXDQqi5o=" }, "babel-plugin-syntax-class-constructor-call": { "version": "6.18.0", @@ -1256,26 +1247,22 @@ "babel-plugin-syntax-class-properties": { "version": "6.13.0", "resolved": "https://registry.npmjs.org/babel-plugin-syntax-class-properties/-/babel-plugin-syntax-class-properties-6.13.0.tgz", - "integrity": "sha1-1+sjt5oxf4VDlixQW4J8fWysJ94=", - "dev": true + "integrity": "sha1-1+sjt5oxf4VDlixQW4J8fWysJ94=" }, "babel-plugin-syntax-decorators": { "version": "6.13.0", "resolved": "https://registry.npmjs.org/babel-plugin-syntax-decorators/-/babel-plugin-syntax-decorators-6.13.0.tgz", - "integrity": "sha1-MSVjtNvePMgGzuPkFszurd0RrAs=", - "dev": true + "integrity": "sha1-MSVjtNvePMgGzuPkFszurd0RrAs=" }, "babel-plugin-syntax-dynamic-import": { "version": "6.18.0", "resolved": "https://registry.npmjs.org/babel-plugin-syntax-dynamic-import/-/babel-plugin-syntax-dynamic-import-6.18.0.tgz", - "integrity": "sha1-jWomIpyDdFqZgqRBBRVyyqF5sdo=", - "dev": true + "integrity": "sha1-jWomIpyDdFqZgqRBBRVyyqF5sdo=" }, "babel-plugin-syntax-exponentiation-operator": { "version": "6.13.0", "resolved": "https://registry.npmjs.org/babel-plugin-syntax-exponentiation-operator/-/babel-plugin-syntax-exponentiation-operator-6.13.0.tgz", - "integrity": "sha1-nufoM3KQ2pUoggGmpX9BcDF4MN4=", - "dev": true + "integrity": "sha1-nufoM3KQ2pUoggGmpX9BcDF4MN4=" }, "babel-plugin-syntax-export-extensions": { "version": "6.13.0", @@ -1303,14 +1290,12 @@ "babel-plugin-syntax-trailing-function-commas": { "version": "6.22.0", "resolved": "https://registry.npmjs.org/babel-plugin-syntax-trailing-function-commas/-/babel-plugin-syntax-trailing-function-commas-6.22.0.tgz", - "integrity": "sha1-ugNgk3+NBuQBgKQ/4NVhb/9TLPM=", - "dev": true + "integrity": "sha1-ugNgk3+NBuQBgKQ/4NVhb/9TLPM=" }, "babel-plugin-transform-async-generator-functions": { "version": "6.24.1", "resolved": "https://registry.npmjs.org/babel-plugin-transform-async-generator-functions/-/babel-plugin-transform-async-generator-functions-6.24.1.tgz", "integrity": "sha1-8FiQAUX9PpkHpt3yjaWfIVJYpds=", - "dev": true, "requires": { "babel-helper-remap-async-to-generator": "^6.24.1", "babel-plugin-syntax-async-generators": "^6.5.0", @@ -1321,7 +1306,6 @@ "version": "6.24.1", "resolved": "https://registry.npmjs.org/babel-plugin-transform-async-to-generator/-/babel-plugin-transform-async-to-generator-6.24.1.tgz", "integrity": "sha1-ZTbjeK/2yx1VF6wOQOs+n8jQh2E=", - "dev": true, "requires": { "babel-helper-remap-async-to-generator": "^6.24.1", "babel-plugin-syntax-async-functions": "^6.8.0", @@ -1343,7 +1327,6 @@ "version": "6.24.1", "resolved": "https://registry.npmjs.org/babel-plugin-transform-class-properties/-/babel-plugin-transform-class-properties-6.24.1.tgz", "integrity": "sha1-anl2PqYdM9NvN7YRqp3vgagbRqw=", - "dev": true, "requires": { "babel-helper-function-name": "^6.24.1", "babel-plugin-syntax-class-properties": "^6.8.0", @@ -1355,7 +1338,6 @@ "version": "6.24.1", "resolved": "https://registry.npmjs.org/babel-plugin-transform-decorators/-/babel-plugin-transform-decorators-6.24.1.tgz", "integrity": "sha1-eIAT2PjGtSIr33s0Q5Df13Vp4k0=", - "dev": true, "requires": { "babel-helper-explode-class": "^6.24.1", "babel-plugin-syntax-decorators": "^6.13.0", @@ -1602,7 +1584,6 @@ "version": "6.24.1", "resolved": "https://registry.npmjs.org/babel-plugin-transform-exponentiation-operator/-/babel-plugin-transform-exponentiation-operator-6.24.1.tgz", "integrity": "sha1-KrDJx/MJj6SJB3cruBP+QejeOg4=", - "dev": true, "requires": { "babel-helper-builder-binary-assignment-operator-visitor": "^6.24.1", "babel-plugin-syntax-exponentiation-operator": "^6.8.0", @@ -1633,7 +1614,6 @@ "version": "6.26.0", "resolved": "https://registry.npmjs.org/babel-plugin-transform-object-rest-spread/-/babel-plugin-transform-object-rest-spread-6.26.0.tgz", "integrity": "sha1-DzZpLVD+9rfi1LOsFHgTepY7ewY=", - "dev": true, "requires": { "babel-plugin-syntax-object-rest-spread": "^6.8.0", "babel-runtime": "^6.26.0" @@ -1815,7 +1795,6 @@ "version": "6.24.1", "resolved": "https://registry.npmjs.org/babel-preset-stage-2/-/babel-preset-stage-2-6.24.1.tgz", "integrity": "sha1-2eKWD7PXEYfw5k7sYrwHdnIZvcE=", - "dev": true, "requires": { "babel-plugin-syntax-dynamic-import": "^6.18.0", "babel-plugin-transform-class-properties": "^6.24.1", @@ -1827,7 +1806,6 @@ "version": "6.24.1", "resolved": "https://registry.npmjs.org/babel-preset-stage-3/-/babel-preset-stage-3-6.24.1.tgz", "integrity": "sha1-g2raCp56f6N8sTj7kyb4eTSkg5U=", - "dev": true, "requires": { "babel-plugin-syntax-trailing-function-commas": "^6.22.0", "babel-plugin-transform-async-generator-functions": "^6.24.1", @@ -2683,6 +2661,11 @@ } } }, + "classnames": { + "version": "2.2.6", + "resolved": "https://registry.npmjs.org/classnames/-/classnames-2.2.6.tgz", + "integrity": "sha512-JR/iSQOSt+LQIWwrwEzJ9uk0xfN3mTVYMwt1Ir5mUcSN6pU+V4zQFFaJsclJbPuAUQH+yfWef6tm7l1quW3C8Q==" + }, "cli-boxes": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/cli-boxes/-/cli-boxes-1.0.0.tgz", @@ -4803,11 +4786,13 @@ }, "balanced-match": { "version": "1.0.0", - "bundled": true + "bundled": true, + "optional": true }, "brace-expansion": { "version": "1.1.11", "bundled": true, + "optional": true, "requires": { "balanced-match": "^1.0.0", "concat-map": "0.0.1" @@ -4820,15 +4805,18 @@ }, "code-point-at": { "version": "1.1.0", - "bundled": true + "bundled": true, + "optional": true }, "concat-map": { "version": "0.0.1", - "bundled": true + "bundled": true, + "optional": true }, "console-control-strings": { "version": "1.1.0", - "bundled": true + "bundled": true, + "optional": true }, "core-util-is": { "version": "1.0.2", @@ -4931,7 +4919,8 @@ }, "inherits": { "version": "2.0.3", - "bundled": true + "bundled": true, + "optional": true }, "ini": { "version": "1.3.5", @@ -4941,6 +4930,7 @@ "is-fullwidth-code-point": { "version": "1.0.0", "bundled": true, + "optional": true, "requires": { "number-is-nan": "^1.0.0" } @@ -4953,17 +4943,20 @@ "minimatch": { "version": "3.0.4", "bundled": true, + "optional": true, "requires": { "brace-expansion": "^1.1.7" } }, "minimist": { "version": "0.0.8", - "bundled": true + "bundled": true, + "optional": true }, "minipass": { "version": "2.2.4", "bundled": true, + "optional": true, "requires": { "safe-buffer": "^5.1.1", "yallist": "^3.0.0" @@ -4980,6 +4973,7 @@ "mkdirp": { "version": "0.5.1", "bundled": true, + "optional": true, "requires": { "minimist": "0.0.8" } @@ -5052,7 +5046,8 @@ }, "number-is-nan": { "version": "1.0.1", - "bundled": true + "bundled": true, + "optional": true }, "object-assign": { "version": "4.1.1", @@ -5062,6 +5057,7 @@ "once": { "version": "1.4.0", "bundled": true, + "optional": true, "requires": { "wrappy": "1" } @@ -5167,6 +5163,7 @@ "string-width": { "version": "1.0.2", "bundled": true, + "optional": true, "requires": { "code-point-at": "^1.0.0", "is-fullwidth-code-point": "^1.0.0", diff --git a/package.json b/package.json index a03a776..dc25bfd 100644 --- a/package.json +++ b/package.json @@ -6,18 +6,27 @@ "scripts": { "test": "jest", "dev": "webpack --mode development", - "build": "webpack --mode production" + "build": "webpack --mode production", + "start": "node server.js", + "heroku-postbuild": "npm run build" }, + "engines":{ + "node":"10.10.0", + "npm":"6.4.1" + }, "author": "", "license": "ISC", "babel": { "presets": [ "babel-preset-react", - "babel-preset-env" + "babel-preset-env", + "babel-preset-stage-2" ] }, "dependencies": { + "babel-preset-stage-2": "^6.24.1", "body-parser": "^1.18.3", + "classnames": "^2.2.6", "dotenv": "^6.1.0", "express": "^4.16.3", "hbs": "^4.0.1", @@ -27,6 +36,10 @@ "react-dom": "^16.2.0" }, "devDependencies": { + "babel": "6.23.0", + "babel-cli": "6.26.0", + "babel-preset-env": "1.6.0", + "nodemon": "1.11.0", "babel-jest": "^22.4.1", "babel-loader": "^7.1.3", "babel-preset-env": "^1.6.1", @@ -44,5 +57,16 @@ "react-test-renderer": "^16.2.0", "webpack": "^4.0.1", "webpack-cli": "^2.0.9" - } + }, + "directories": { + "test": "tests" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/chrisphillers/delivereat-with-db.git" + }, + "bugs": { + "url": "https://github.com/chrisphillers/delivereat-with-db/issues" + }, + "homepage": "https://github.com/chrisphillers/delivereat-with-db#readme" } diff --git a/procfile b/procfile new file mode 100644 index 0000000..489b270 --- /dev/null +++ b/procfile @@ -0,0 +1 @@ +web: node server.js diff --git a/server.js b/server.js index 89ca1de..bdf149c 100644 --- a/server.js +++ b/server.js @@ -1,23 +1,75 @@ -const express = require('express'); +require('dotenv').config(); + const bodyParser = require('body-parser'); +const pgp = require('pg-promise')(); +const express = require('express'); const app = express(); +const db = pgp({ + host: process.env.DB_HOST || "localhost", + port: 5432, + database: process.env.DB_NAME, + user: process.env.DB_USERNAME, + password: process.env.DB_PASSWORD +}); app.use(bodyParser.json()); app.use('/static', express.static('static')); app.set('view engine', 'hbs'); -const menu = { - 1: { - id: 1, - name: "Strawberry cheesecake", - price: 6 - } -}; app.get('/', function(req, res){ res.render('index'); }); -app.listen(8080, function(){ - console.log('Listening on port 8080'); +app.get('/api/menu', function(req, res){ + db.any('SELECT * FROM menu') + .then(function(data){ + res.json(data) + }) + .catch(function(error){ + res.json({error:error.message}) + }) +}) + + +app.post("/api/order",(req,res) => { + const {items, name, email, address, postcode, phone} = req.body; + db.one("INSERT INTO order_basket(cust_name, cust_address, email, postcode, phone) VALUES ($1, $2, $3, $4, $5) RETURNING id", [name, address, email, postcode, phone]).then( + result => { + const orderId = result.id; + Promise.all(items.map(item => { + return db.none( + "INSERT INTO anorder (menu_id, order_basket_id, quantity) VALUES ($1, $2, $3)", + [item.menuItemId, orderId, item.quantity] + + ) + }) + ) + .then(() => orderId) + } + + ) + .then(orderId => { + console.log('catch 3'); + res.json({orderId: orderId, success: true, message: 'Brace yourself for the Kale'}) + }) + .catch(error => { + console.log(error); + res.json({error: error.message}) + }); +}); + +app.use(function(req, res, next) { + return res.status(404).send({ message: `Route ${req.url} not found.` }); +}); + // Handle 404 +// app.use(function(req, res) { +// res.status(400); +// res.render('404.jade', {title: '404: File Not Found'}); +// }); + + + +app.listen(process.env.PORT||8080, function() { + console.log("Listening on port 8080"); }); diff --git a/src/components/App.js b/src/components/App.js index 2ba4c77..b4a1264 100644 --- a/src/components/App.js +++ b/src/components/App.js @@ -1,18 +1,114 @@ -import React from 'react'; +import React from "react"; +import Menu from "./Menu"; +import Nav from "./Nav"; +import Oops from "./Oops"; -import '../styles/App.scss'; +import "../styles/App.scss"; +// import { Route, Switch, BrowserRouter } from 'react-router-dom'; class App extends React.Component { - constructor(){ + constructor() { super(); + + this.state = { + menuItems: [], + customerDetails: { + name: "Chris", + address: "Dekker House", + postcode: "E8 3FS", + email: "chrisphillers@gmail.com", + phone: "07714205581" + }, + showBasket: false, + basketStatus: false + }; + this.fetchMenuItems = this.fetchMenuItems.bind(this); + this.receiveOrder = this.receiveOrder.bind(this); + this.closeBasket = this.closeBasket.bind(this); + this.openBasket = this.openBasket.bind(this); + this.basketStatus = this.basketStatus.bind(this); + } + + + + + + componentDidMount() { + this.fetchMenuItems(); + + } + + basketStatus(){ + this.setState({basketStatus: true}); + } + + openBasket(){ + this.setState({showBasket: true}); + } + + closeBasket() { + this.setState({ showBasket: false }); } - render(){ + receiveOrder(orderBasket) { + const finalOrder = { + items: orderBasket, + ...this.state.customerDetails + }; + console.log({ finalOrder }); + this.postOrder(finalOrder); + } + + + + + fetchMenuItems() { + fetch("/api/menu") + .then(res => res.json()) + .then(body => { + this.setState({ menuItems: body }); + console.log(this.state.menuItems); + }); + } + + postOrder(currentOrder) { + fetch("/api/order", { + method: "post", + body: JSON.stringify(currentOrder), + headers: { + "Content-Type": "application/json" + } + }) + .then(function(response) { + return response.json(); + }) + .then(data => { + console.log(data); + alert("15 mins to Kale o'clock!") + // handle response + }); + } + + render() { + + + return (
{this.props.state.menuItem.Title}
+{this.props.state.moreFilmInfo.Genre}
+{this.props.state.moreFilmInfo.Plot}
+
+
+ );
+ }
+}
+
+export default Oops;
diff --git a/src/styles/App.scss b/src/styles/App.scss
index 0bdf5c0..ef0548f 100644
--- a/src/styles/App.scss
+++ b/src/styles/App.scss
@@ -1,3 +1,18 @@
+@import "defaults";
+
body {
- background-color: Cornsilk;
+ margin: 0;
+}
+
+#root {
+ width: 100%;
+}
+
+.header {
+ height: 30vh;
+ background-image: url("/static/img/header.jpg");
+ background-position: center;
+ background-repeat: no-repeat;
+ background-size: cover;
+ // position: relative;
}
diff --git a/src/styles/Basket.scss b/src/styles/Basket.scss
new file mode 100644
index 0000000..1405413
--- /dev/null
+++ b/src/styles/Basket.scss
@@ -0,0 +1,31 @@
+@import "defaults";
+
+.basket {
+
+ top:0;
+ animation: bounce 1s;
+
+ &__order {
+ display: flex;
+ flex-direction: row;
+ // justify-content: space-around;
+ align-items: baseline;
+ // display: inline;
+ }
+}
+
+.hidden {
+ position: fixed;
+
+
+ bottom: -100%;
+ left: 0px;
+ width: 100vw;
+ height: 100vh;
+ background-color: aquamarine;
+ transition: bottom 0.5s;
+ margin-right: 0px;
+ opacity: 0.9;
+ z-index: 1;
+ animation: bounce 1s;
+}
diff --git a/src/styles/Menu.scss b/src/styles/Menu.scss
new file mode 100644
index 0000000..469f6a9
--- /dev/null
+++ b/src/styles/Menu.scss
@@ -0,0 +1,39 @@
+@import "defaults";
+
+.menu {
+ padding: 0;
+}
+
+.menuitems {
+ display: flex;
+ flex-direction: column;
+ background-color: white;
+
+ &__row {
+ display: flex;
+ justify-content: space-between;
+ }
+
+ &__order {
+ display: flex;
+ flex-direction: row;
+ justify-content: space-around;
+ align-items: baseline;
+ // display: inline;
+ }
+
+ &__info {
+ width: 70%;
+ }
+}
+
+hr {
+ margin: 0;
+ padding: 0;
+}
+
+// .menuitems__details {
+// display: flex;
+// // flex-direction: column;
+// align-items: flex-start;
+// }
diff --git a/src/styles/MoreInfo.scss b/src/styles/MoreInfo.scss
new file mode 100644
index 0000000..0592049
--- /dev/null
+++ b/src/styles/MoreInfo.scss
@@ -0,0 +1,9 @@
+@import "defaults";
+
+.moreinfo{
+ // width: 100vh;
+ // height: 100vw;
+ // background-color:red;
+ // // position: absolute;
+ // // top:0;
+}
\ No newline at end of file
diff --git a/src/styles/Nav.scss b/src/styles/Nav.scss
new file mode 100644
index 0000000..6953cc1
--- /dev/null
+++ b/src/styles/Nav.scss
@@ -0,0 +1,18 @@
+@import "defaults";
+
+.nav {
+ position: sticky;
+ top: 0;
+ display: flex;
+ justify-content: space-between;
+ background-color: white;
+
+ &__logo {
+ height: 150px;
+ }
+ &__basket {
+ height: 70px;
+ margin: 30px;
+ z-index: 6;
+ }
+}
diff --git a/src/styles/Oops.scss b/src/styles/Oops.scss
new file mode 100644
index 0000000..7114d5a
--- /dev/null
+++ b/src/styles/Oops.scss
@@ -0,0 +1 @@
+@import "defaults";
diff --git a/src/styles/_defaults.scss b/src/styles/_defaults.scss
new file mode 100644
index 0000000..3ee48f6
--- /dev/null
+++ b/src/styles/_defaults.scss
@@ -0,0 +1,108 @@
+$primary-color: #252525;
+$background-color: #ffd5d1;
+$font-family: "courier new", courier, monospace;
+
+* {
+ -moz-box-sizing: border-box;
+ -webkit-box-sizing: border-box;
+ box-sizing: border-box;
+ scroll-behavior: smooth;
+}
+
+body {
+ background-color: $background-color;
+ font-family: $font-family;
+ color: $primary-color;
+ display: flex;
+ justify-content: center;
+}
+
+ul {
+ list-style: none;
+}
+
+h1 {
+ font-size: 3em;
+}
+
+h2 {
+ font-size: 2.5em;
+ margin: 10px;
+ padding: 0;
+}
+
+h3 {
+ font-size: 2em;
+ margin: 8px;
+ padding: 0;
+}
+
+.orderbutton {
+ display: inline;
+
+ &__plus {
+ -webkit-border-radius: 20px;
+ -moz-border-radius: 20px;
+ border-radius: 20px;
+ height: 25px;
+ line-height: 4px;
+ color: #ffffff;
+ // font-family: Open Sans;
+ width: 25px;
+ padding: 7px;
+ background-color: #000000;
+ text-decoration: none;
+ // display: inline-block;
+ // cursor: pointer;
+ // text-align: center;
+ // display: table-cell;
+ // vertical-align: middle;
+ border: none;
+ }
+
+ &__plus:hover {
+ background: #19c4d0;
+ text-decoration: none;
+ }
+ &__minus {
+ -webkit-border-radius: 20px;
+ -moz-border-radius: 20px;
+ border-radius: 20px;
+ height: 25px;
+ line-height: 4px;
+ color: #ffffff;
+ // font-family: Open Sans;
+ width: 25px;
+ padding: 7px;
+ background-color: #000000;
+ text-decoration: none;
+ border: none;
+ // display: inline-block;
+ // cursor: pointer;
+ // text-align: center;
+ // display: table-cell;
+ // vertical-align: middle;
+ }
+
+ &__minus:hover {
+ background: #19c4d0;
+ text-decoration: none;
+ }
+}
+
+@keyframes bounce {
+ 0%, 20%, 60%, 100% {
+ -webkit-transform: translateY(0);
+ transform: translateY(0);
+ }
+
+ 40% {
+ -webkit-transform: translateY(-20px);
+ transform: translateY(-20px);
+ }
+
+ 80% {
+ -webkit-transform: translateY(-10px);
+ transform: translateY(-10px);
+ }
+}
\ No newline at end of file
diff --git a/static/img/basket.png b/static/img/basket.png
new file mode 100644
index 0000000..252025f
Binary files /dev/null and b/static/img/basket.png differ
diff --git a/static/img/basket_full.png b/static/img/basket_full.png
new file mode 100644
index 0000000..00116f0
Binary files /dev/null and b/static/img/basket_full.png differ
diff --git a/static/img/header.jpg b/static/img/header.jpg
new file mode 100644
index 0000000..7a78de4
Binary files /dev/null and b/static/img/header.jpg differ
diff --git a/static/img/header2.jpg b/static/img/header2.jpg
new file mode 100644
index 0000000..81f5e20
Binary files /dev/null and b/static/img/header2.jpg differ
diff --git a/static/img/logo.png b/static/img/logo.png
new file mode 100644
index 0000000..a940d18
Binary files /dev/null and b/static/img/logo.png differ
diff --git a/static/img/oops.gif b/static/img/oops.gif
new file mode 100644
index 0000000..81fef9f
Binary files /dev/null and b/static/img/oops.gif differ
diff --git a/static/styles.css b/static/styles.css
index 293d3b1..cdb90c5 100644
--- a/static/styles.css
+++ b/static/styles.css
@@ -1,3 +1,9 @@
body {
margin: 0;
}
+
+/* img {
+ width: 400px;
+ height: 400px;
+ object-fit: cover;
+} */
diff --git a/views/404.jade b/views/404.jade
new file mode 100644
index 0000000..e9b8a5e
--- /dev/null
+++ b/views/404.jade
@@ -0,0 +1,5 @@
+extends layout
+block content
+ h1= title
+ p Dude, where is my page?
+ a(href='/') Take me to the homepage!
\ No newline at end of file
diff --git a/views/index.hbs b/views/index.hbs
index 8fdb420..69c73ab 100644
--- a/views/index.hbs
+++ b/views/index.hbs
@@ -1,13 +1,16 @@
-
-