diff --git a/server.js b/server.js index 61563f8..d38c2bf 100644 --- a/server.js +++ b/server.js @@ -4,6 +4,8 @@ const express = require('express'); const app = express(); // create express app const http = require('http'); const mysql = require('mysql'); +const bcrypt = require('bcrypt'); +const saltRounds = 10; app.use(cors()); const bodyParser = require('body-parser'); @@ -26,34 +28,51 @@ const db = mysql.createConnection({ database: "account_information" }); -db.connect( (err) => { - if (err) { - throw err; - } +db.connect((err) => { + if (err) { + throw err; + } - console.log("Connected to MySQL server."); + console.log("Connected to MySQL server."); }); -app.post("/create", (req, res) => { - const username = req.body.username; - const password = req.body.password; - const email = req.body.email; - const address = req.body.address; - const firstname = req.body.firstname; - const lastname = req.body.lastname; - const phone = req.body.phone; - - const query = "INSERT INTO account (username, email, address, password, first_name, last_name, phone_num) VALUES (?, ?, ?, ?, ?, ?, ?);"; - db.query( - query, - [username, email, address, password, firstname, lastname, phone], - ); - return res.json(200); -}); +app.post("/register", (req, res) => { + + const username = req.body.username; + const password = req.body.password; + const email = req.body.email; + const address = req.body.address; + const firstname = req.body.firstname; + const lastname = req.body.lastname; + const phone = req.body.phone; + + bcrypt.hash(password, saltRounds, (err, hash) => { + if (err) { + console.log(err); + } -app + const data = [ + username, + email, + address, + hash, + firstname, + lastname, + phone + ]; + const query = "INSERT INTO account (username, email, address, password, first_name, last_name, phone_num) VALUES (?, ?, ?, ?, ?, ?, ?);"; + db.query( + query, data, + (err, result) => { + if (err) { + res.send({ err: err }); + } + } + ); + }); +}); // start express server on port 5000 server.listen(5000, () => { - console.log('NodeJS server running'); -}); + console.log('NodeJS server running'); +}); \ No newline at end of file diff --git a/src/App.css b/src/App.css new file mode 100644 index 0000000..e69de29 diff --git a/src/App.js b/src/App.js index c0dc8e3..7da904f 100644 --- a/src/App.js +++ b/src/App.js @@ -1,6 +1,8 @@ import React from "react"; -import Registration from "./Pages/LoginPage/LoginPage"; +import Registration from "./Pages/RegistrationPage/RegistrationPage"; import Home from "./Pages/HomePage/HomePage" +import Product from "./Pages/ProductPage/ProductPage" +import "./GeneralStyles.css"; import { BrowserRouter as Router, Switch, @@ -17,11 +19,17 @@ function App() { Home   Register - +   + Product + + + + + diff --git a/src/GeneralStyles.css b/src/GeneralStyles.css new file mode 100644 index 0000000..72aab57 --- /dev/null +++ b/src/GeneralStyles.css @@ -0,0 +1,12 @@ +button { + border: none; + margin-left: 1%; + background-color: rgb(102, 255, 0); + border-radius: 10px; +} + +button:hover { + background-color: rgb(0, 141, 141); + color: white; + cursor: pointer; +} \ No newline at end of file diff --git a/src/Pages/HomePage/HomePage.css b/src/Pages/HomePage/HomePage.css index 1d04a1c..1b53236 100644 --- a/src/Pages/HomePage/HomePage.css +++ b/src/Pages/HomePage/HomePage.css @@ -4,80 +4,80 @@ font-family: 'Times New Roman', Times, serif; margin: 0; padding: 0; - text-align: center; - } - - header { +} + +header { text-align: left; background-image: url(../../images/oceanimage.jpg); - background-blend-mode:lighten; + background-blend-mode: lighten; background-position: center; - background-size:cover; - opacity:1; + background-size: cover; + opacity: 1; color: black; - font-size:x-large; + font-size: x-large; margin: none; border-radius: none; padding: 10%; - } +} - h2 { - font-family:'Lucida Sans', 'Lucida Sans Regular', 'Lucida Grande', 'Lucida Sans Unicode', Geneva, Verdana, sans-serif; +h2 { + font-family: 'Lucida Sans', 'Lucida Sans Regular', 'Lucida Grande', 'Lucida Sans Unicode', Geneva, Verdana, sans-serif; text-align: center; background-color: rgb(184, 227, 240); color: black; - font-size:large; + font-size: large; margin: none; border-radius: none; padding: 1%; - } - h3 { - font-family:'Lucida Sans', 'Lucida Sans Regular', 'Lucida Grande', 'Lucida Sans Unicode', Geneva, Verdana, sans-serif; +} + +h3 { + font-family: 'Lucida Sans', 'Lucida Sans Regular', 'Lucida Grande', 'Lucida Sans Unicode', Geneva, Verdana, sans-serif; text-align: justify; color: black; - font-size:large; + font-size: large; margin: none; border-radius: none; padding: 1%; - } +} - - button { +.Frames{ + display: flex; + flex-direction: column; color: black; - padding: 20px 60px; - text-decoration: none; font-size: large; - border: none; margin: 5%; - background-color: rgb(102, 255, 0); - } + align-items: left; + text-align: center; +} + +.Frames button { + height: 30px; + width: 20%; +} - .hotbar-button { +.hotbar-button { color: black; padding: 5px 5px; text-decoration: none; font-size: large; border: none; margin: 1%; - } - .hotbar-button:hover { - cursor:pointer; - } - - button:hover { - background-color: rgb(0,141,141); - color: white; - } +} - .Topright { +.hotbar-button:hover { + cursor: pointer; +} + +.Topright { position: absolute; top: 30px; right: 16px; - font-size:18px - } - - .Middleright { + font-size: 18px +} + +.Middleright { position: absolute; - top:30px; - right:80px; - } \ No newline at end of file + top: 30px; + right: 80px; +} \ No newline at end of file diff --git a/src/Pages/HomePage/HomePage.js b/src/Pages/HomePage/HomePage.js index cdf06e9..ca64a87 100644 --- a/src/Pages/HomePage/HomePage.js +++ b/src/Pages/HomePage/HomePage.js @@ -1,37 +1,44 @@ import "./HomePage.css" -import image from "../../images/cartimage.png" +import image from "../../images/cartimage.png" import image2 from "../../images/searchbar.png" function Home() { - return ( -
-
-
WorldWide Frames - See A Better World
-

Items on Sale

-

Deals of the Day

- - - -

Sunglasses

- - + + return ( +
+
+
WorldWide Frames - See A Better World
+

Items on Sale

+
+
+

Deals of the Day

+ + + +
+
+

Sunglasses

+ + +
-
-
- -
+
+
+
+
-
-
- -
+
+
+
+
- - ); +
+ + ); } export default Home; \ No newline at end of file diff --git a/src/Pages/LoginPage/LoginPage.css b/src/Pages/LoginPage/LoginPage.css deleted file mode 100644 index 489d561..0000000 --- a/src/Pages/LoginPage/LoginPage.css +++ /dev/null @@ -1,48 +0,0 @@ -.information { - display: flex; - flex-direction: column; - width: 100%; - justify-content: center; - align-items: center; - background-color:aqua; - } - - input { - width: 250px; - height: 50px; - font-size: 20px; - padding-left: 10px; - margin: 5px; - - } - - button { - width: 320px; - height: 50px; - margin-top: 15px; - } - - button:hover { - cursor: pointer; - } - - .employees { - display: flex; - align-items: center; - flex-direction: column; - width: 100%; - } - - .employee { - width: 700px; - height: auto; - border: 1px solid black; - margin: 10px; - display: flex; - padding: 10px; - font-family: 'Courier New', Courier, monospace; - } - - .employee h3 { - margin: 20px; - } \ No newline at end of file diff --git a/src/Pages/LoginPage/LoginPage.js b/src/Pages/LoginPage/LoginPage.js deleted file mode 100644 index 40d45ef..0000000 --- a/src/Pages/LoginPage/LoginPage.js +++ /dev/null @@ -1,80 +0,0 @@ -import { useState } from "react"; -import "./LoginPage.css" -import Axios from "axios"; - -function Registration() { - const [username, setUsername] = useState(""); - const [email, setEmail] = useState(""); - const [address, setAddress] = useState(""); - const [password, setPassword] = useState(""); - const [firstname, setFirstname] = useState(""); - const [lastname, setLastname] = useState(0); - const [phone, setPhone] = useState(""); - - const addEmployee = () => { - Axios.post("/create", { - username: username, - email: email, - address: address, - password: password, - firstname: firstname, - lastname: lastname, - phone: phone, - }).then((response) =>{ - if (response.data.message) { - console.log(response.data.message) - } - }); - }; - - return ( -
- - { - setUsername(event.target.value); - }} - /> - - { - setPassword(event.target.value); - }} - /> - - { - setEmail(event.target.value); - }} - /> - - { - setAddress(event.target.value); - }} - /> - - { - setFirstname(event.target.value); - }} - /> - - { - setLastname(event.target.value); - }} - /> - - { - setPhone(event.target.value); - }} - /> - - -
- ); -} - -export default Registration; diff --git a/src/Pages/ProductPage/ProductPage.css b/src/Pages/ProductPage/ProductPage.css new file mode 100644 index 0000000..40599c3 --- /dev/null +++ b/src/Pages/ProductPage/ProductPage.css @@ -0,0 +1,46 @@ +.App1 { + min-height: 100vh; + background-color: rgb(211, 254, 255); + font-family: 'Times New Roman', Times, serif; + margin: 0; + padding: 0; + text-align: center; +} + +.panel1 { + height: 500px; + font-family: 'Times New Roman', Times, serif; + margin: 0; + padding: 0; +} + +.header1 { + min-height: 10vh; + background-color: aqua; + font-family: 'Times New Roman', Times, serif; + margin: 0; + padding: 0; + text-align: center; +} + +/* +* percentage's are used to scale items according to browser resizing +* can possibly use flex containers for buttons +*/ +.header2 { + position: relative; + left: 55%; + height: 500px; + width: 40%; + background-color: rgb(189, 207, 209); + font-family: 'Times New Roman', Times, serif; + margin: 0; + padding: 0; + text-align: left; +} + +.panel1 button { + position: relative; + left: 25%; + width: 15%; +} \ No newline at end of file diff --git a/src/Pages/ProductPage/ProductPage.js b/src/Pages/ProductPage/ProductPage.js new file mode 100644 index 0000000..55b28b6 --- /dev/null +++ b/src/Pages/ProductPage/ProductPage.js @@ -0,0 +1,24 @@ +import "./ProductPage.css" + +function Product() { + return ( +
+
+
+ WorldWide Frames - See A Better World +
+ {/* create an overall panel, with header 2, the image, and the button inside of it */} +
+
+

Name:

+

Manufacturer:

+

Cost:

+
+ +
+
+
+ ); +} + +export default Product; \ No newline at end of file diff --git a/src/Pages/RegistrationPage/RegistrationPage.css b/src/Pages/RegistrationPage/RegistrationPage.css new file mode 100644 index 0000000..d1a52e6 --- /dev/null +++ b/src/Pages/RegistrationPage/RegistrationPage.css @@ -0,0 +1,24 @@ +.information { + display: flex; + height: 100%; + width: 100%; + flex-direction: column; + justify-content: center; + align-items: center; + background-color: aqua; +} + +.information input { + width: 250px; + height: 50px; + font-size: 20px; + padding-left: 10px; + margin: 5px; +} + +.information button { + height: 30px; + width: 250px; + font-size: 20px; + margin: 10px; +} \ No newline at end of file diff --git a/src/Pages/RegistrationPage/RegistrationPage.js b/src/Pages/RegistrationPage/RegistrationPage.js new file mode 100644 index 0000000..d845f8e --- /dev/null +++ b/src/Pages/RegistrationPage/RegistrationPage.js @@ -0,0 +1,87 @@ +import { useState } from "react"; +import "./RegistrationPage.css" +import Axios from "axios"; +import { useHistory } from "react-router-dom"; + +function Registration() { + const [username, setUsername] = useState(""); + const [email, setEmail] = useState(""); + const [address, setAddress] = useState(""); + const [password, setPassword] = useState(""); + const [firstname, setFirstname] = useState(""); + const [lastname, setLastname] = useState(0); + const [phone, setPhone] = useState(""); + + let history = useHistory(); + + const registerUser = () => { + const data = { + username: username, + password: password, + email: email, + address: address, + firstname: firstname, + lastname: lastname, + phone: phone + }; + Axios.post("http://localhost:5000/register", data).then((response) => { + if (response.data.error) { + alert(response.data.error); + console.log("error!"); + } else { + console.log(response); + /*history.push("/");*/ + } + }); + }; + + return ( +
+ + { + setUsername(event.target.value); + }} + /> + + { + setPassword(event.target.value); + }} + /> + + { + setEmail(event.target.value); + }} + /> + + { + setAddress(event.target.value); + }} + /> + + { + setFirstname(event.target.value); + }} + /> + + { + setLastname(event.target.value); + }} + /> + + { + setPhone(event.target.value); + }} + /> + +
+ ); +} + +export default Registration;