From 6e18d4fe47fdc2a1b2566d7dd8e8f9c959689a92 Mon Sep 17 00:00:00 2001 From: Antonella Morittu <33493978+AntonellaMorittu@users.noreply.github.com> Date: Wed, 22 May 2024 14:57:16 +0200 Subject: [PATCH 01/27] Delete netlify.toml --- netlify.toml | 6 ------ 1 file changed, 6 deletions(-) delete mode 100644 netlify.toml diff --git a/netlify.toml b/netlify.toml deleted file mode 100644 index ed9e83391..000000000 --- a/netlify.toml +++ /dev/null @@ -1,6 +0,0 @@ -# This file tells netlify where the code for this project is and -# how it should build the JavaScript assets to deploy from. -[build] - base = "frontend/" - publish = "dist" - command = "npm run build" From 2f01730153aef88c9e72b28d8c16d946fb9ed8a5 Mon Sep 17 00:00:00 2001 From: Teddy Date: Wed, 22 May 2024 16:06:41 +0200 Subject: [PATCH 02/27] create folder and form --- frontend/.eslintrc.cjs | 2 ++ frontend/src/App.jsx | 8 +++++++- frontend/src/components/Button.jsx | 5 +++++ frontend/src/components/Home.jsx | 12 ++++++++++++ frontend/src/components/LogIn.jsx | 20 ++++++++++++++++++++ frontend/src/components/Register.jsx | 24 ++++++++++++++++++++++++ frontend/src/components/Session.jsx | 3 +++ 7 files changed, 73 insertions(+), 1 deletion(-) create mode 100644 frontend/src/components/Button.jsx create mode 100644 frontend/src/components/Home.jsx create mode 100644 frontend/src/components/LogIn.jsx create mode 100644 frontend/src/components/Register.jsx create mode 100644 frontend/src/components/Session.jsx diff --git a/frontend/.eslintrc.cjs b/frontend/.eslintrc.cjs index 4dcb43901..94e01b901 100644 --- a/frontend/.eslintrc.cjs +++ b/frontend/.eslintrc.cjs @@ -17,4 +17,6 @@ module.exports = { { allowConstantExport: true }, ], }, + 'react/prop-types': "off" } + diff --git a/frontend/src/App.jsx b/frontend/src/App.jsx index 1091d4310..16eb81f50 100644 --- a/frontend/src/App.jsx +++ b/frontend/src/App.jsx @@ -1,3 +1,9 @@ +import { Home } from "./components/Home" + export const App = () => { - return
Find me in src/app.jsx!
; + return ( +<> + + + ) }; diff --git a/frontend/src/components/Button.jsx b/frontend/src/components/Button.jsx new file mode 100644 index 000000000..94a7b673c --- /dev/null +++ b/frontend/src/components/Button.jsx @@ -0,0 +1,5 @@ +export const Button = ({ btnText }) => { + return ( + + ) +} diff --git a/frontend/src/components/Home.jsx b/frontend/src/components/Home.jsx new file mode 100644 index 000000000..ee680bd06 --- /dev/null +++ b/frontend/src/components/Home.jsx @@ -0,0 +1,12 @@ +import { LogIn } from "./LogIn" +import { Register } from "./Register" + +export const Home = () => { + return ( +
+ + +
+ ); +}; + diff --git a/frontend/src/components/LogIn.jsx b/frontend/src/components/LogIn.jsx new file mode 100644 index 000000000..d8aa56251 --- /dev/null +++ b/frontend/src/components/LogIn.jsx @@ -0,0 +1,20 @@ +import { Button } from "./Button"; + +export const LogIn = () => { + return ( + <> +
LogIn
+
+ + +
- ) -} + return ; +}; diff --git a/frontend/src/components/Headline.jsx b/frontend/src/components/Headline.jsx new file mode 100644 index 000000000..917d7025c --- /dev/null +++ b/frontend/src/components/Headline.jsx @@ -0,0 +1,3 @@ +export const Headline = ({ titleText }) => { + return

{titleText}

; +}; diff --git a/frontend/src/components/Register.jsx b/frontend/src/components/Register.jsx index 59ccb61ea..733e30a74 100644 --- a/frontend/src/components/Register.jsx +++ b/frontend/src/components/Register.jsx @@ -1,10 +1,11 @@ import { Button } from "./Button"; +import { Headline } from "./Headline"; export const Register = () => { return (
-

Register

+

Love to read and want to meet fellow book enthusiasts?

@@ -15,26 +16,14 @@ export const Register = () => {

We can't wait to welcome you and embark on literary adventures together!

-
- - - -
- -
-
+
+
-
+
+ + + + +
diff --git a/frontend/src/index.css b/frontend/src/index.css index f7e0655ea..5fc991510 100644 --- a/frontend/src/index.css +++ b/frontend/src/index.css @@ -13,6 +13,12 @@ font-family: var(--text-font); } +body { + display: flex; + flex-direction: column; + align-items: center; +} + h2 { font-family: var(--title-font); font-size: 35px; @@ -23,7 +29,6 @@ h2 { display: flex; flex-direction: column; align-items: center; - margin: 25px 0; gap: 15px; } @@ -34,40 +39,41 @@ h2 { } form { + display: flex; + flex-direction: column; margin: 10px; + gap: 20px; } label { display: flex; flex-direction: column; - margin-bottom: 20px; + /* margin-bottom: 20px; */ font-weight: 400; } -fieldset label { - margin-bottom: 8px; -} - legend { font-size: 18px; } fieldset { + display: flex; + flex-direction: column; border: none; padding-top: 5px; + gap: 15px; } input[type="text"], input[type="password"], input[type="email"] { padding: 10px; - width: 100%; border-radius: 3px; border: 0.5px solid black; } .button-box { - margin: 20px 0; + margin: 10px 0; } button { @@ -76,11 +82,41 @@ button { font-family: var(--title-font); font-size: 16px; border-radius: 5px; - padding: 8px 0; + border: none; + padding: 8px; text-transform: uppercase; width: 100%; } +@media (min-width: 480px) { + form { + width: 440px; + } + + h2 { + font-size: 45px; + } +} + +@media (min-width: 768px) { + form { + width: 580px; + } + + .address-tablet-desktop { + display: flex; + justify-content: space-between; + } + + .postcode-box label { + width: 200px; + } + + .city-box label { + width: 350px; + } +} + /* 3D6E30 */ /* 725982 */ /* 683651 */ From f1616bcfd94dd96ce8409bdca0187727fa4d133a Mon Sep 17 00:00:00 2001 From: schouenkes Date: Thu, 23 May 2024 12:05:38 +0200 Subject: [PATCH 06/27] added a focus/blur function for the placeholder --- frontend/src/components/Home.jsx | 11 +++--- frontend/src/components/LogIn.jsx | 30 +++++++------- frontend/src/components/Register.jsx | 57 ++++++++------------------- frontend/src/components/TextInput.jsx | 20 ++++++++++ frontend/src/helpers/HandleFocus.jsx | 20 ++++++++++ frontend/src/index.css | 22 ++++++++--- 6 files changed, 95 insertions(+), 65 deletions(-) create mode 100644 frontend/src/components/TextInput.jsx create mode 100644 frontend/src/helpers/HandleFocus.jsx diff --git a/frontend/src/components/Home.jsx b/frontend/src/components/Home.jsx index ee680bd06..a18d67df1 100644 --- a/frontend/src/components/Home.jsx +++ b/frontend/src/components/Home.jsx @@ -1,12 +1,11 @@ -import { LogIn } from "./LogIn" -import { Register } from "./Register" +import { LogIn } from "./LogIn"; +import { Register } from "./Register"; export const Home = () => { return ( -
- - +
+ +
); }; - diff --git a/frontend/src/components/LogIn.jsx b/frontend/src/components/LogIn.jsx index d8aa56251..07b61d9ef 100644 --- a/frontend/src/components/LogIn.jsx +++ b/frontend/src/components/LogIn.jsx @@ -1,20 +1,22 @@ import { Button } from "./Button"; +import { Headline } from "./Headline"; +import { TextInput } from "./TextInput"; export const LogIn = () => { return ( - <> -
LogIn
- - - -
- - + - + + +
Address - - - -
+ +
- +
- +
- + - + -
-
+
- + - +
- + - +
Address +
- +
diff --git a/frontend/src/components/TextInput.jsx b/frontend/src/components/TextInput.jsx index c795b78b7..09205f1f7 100644 --- a/frontend/src/components/TextInput.jsx +++ b/frontend/src/components/TextInput.jsx @@ -1,7 +1,7 @@ import { HandleFocus } from "../helpers/HandleFocus"; export const TextInput = ({ inputType, inputName, placeholder, label }) => { - const { placeholder: ourPlaceholder, handleFocus, handleOnBlur } = HandleFocus(placeholder, inputName); + const { placeholder: initialPlaceholder, handleFocus, handleOnBlur } = HandleFocus(placeholder, inputName); return ( <> @@ -9,10 +9,11 @@ export const TextInput = ({ inputType, inputName, placeholder, label }) => { {label} handleOnBlur(e.target.value)} + required /> diff --git a/frontend/src/index.css b/frontend/src/index.css index 84577c286..01094f652 100644 --- a/frontend/src/index.css +++ b/frontend/src/index.css @@ -35,6 +35,7 @@ h2 { display: flex; flex-direction: column; align-items: center; + margin-bottom: 10px; gap: 15px; } @@ -76,7 +77,7 @@ input[type="password"], input[type="email"] { padding: 10px; border-radius: 3px; - border: 0.5px solid black; + border: 1px solid black; } button { From cdd227f041f1f9d573c3e154122099209afeb141 Mon Sep 17 00:00:00 2001 From: Teddy Date: Thu, 23 May 2024 15:11:42 +0200 Subject: [PATCH 08/27] Co-authored-by: viktoria-olo Co-authored-by: Maja Schouenke --- backend/server.js | 11 +- frontend/src/components/Button.jsx | 2 +- frontend/src/components/Register.jsx | 164 ++++++++++++++++++++++++-- frontend/src/components/TextInput.jsx | 4 +- 4 files changed, 165 insertions(+), 16 deletions(-) diff --git a/backend/server.js b/backend/server.js index c6dfbef2d..0a0f14e16 100644 --- a/backend/server.js +++ b/backend/server.js @@ -3,7 +3,6 @@ import express from "express"; import mongoose from "mongoose"; import bcrypt from "bcrypt"; import crypto from "crypto"; -import { accessSync } from "fs"; const mongoUrl = process.env.MONGO_URL || "mongodb://localhost/project-auth"; mongoose.connect(mongoUrl); @@ -65,6 +64,16 @@ app.get("/", (req, res) => { res.send("Hello Technigo!"); }); + +app.get("/users", async (req, res) => { + const allUsers = await User.find().exec(); + if (allUsers.length > 0) { + res.json(allUsers); + } else { + res.status(404).send("No users found"); + } +}); + app.post("/users", async (req, res) => { try { const { name, username, email, password, address } = req.body; diff --git a/frontend/src/components/Button.jsx b/frontend/src/components/Button.jsx index 24713c646..9099dadc9 100644 --- a/frontend/src/components/Button.jsx +++ b/frontend/src/components/Button.jsx @@ -1,3 +1,3 @@ export const Button = ({ btnText }) => { - return ; + return ; }; diff --git a/frontend/src/components/Register.jsx b/frontend/src/components/Register.jsx index b33bec1fc..a494355f7 100644 --- a/frontend/src/components/Register.jsx +++ b/frontend/src/components/Register.jsx @@ -1,47 +1,185 @@ import { Button } from "./Button"; import { Headline } from "./Headline"; import { TextInput } from "./TextInput"; +import { useState } from "react"; export const Register = () => { + const [name, setName] = useState(""); + const [email, setEmail] = useState(""); + const [street, setStreet] = useState(""); + const [postCode, setPostCode] = useState(""); + const [city, setCity] = useState(""); + const [username, setUsername] = useState(""); + const [password, setPassword] = useState(""); + const [verifyPassword, setVerifyPassword] = useState(""); + const [address, setAddress] = useState(""); + const [accessToken, setAccessToken] = useState(""); + + const handleChange = (event) => {}; + + const handleSubmit = async (event) => { + event.preventDefault(); + setAddress(street + postCode + city); + try { + const response = await fetch("http://localhost:8080/users", { + method: "POST", + body: JSON.stringify({ + name: name, + username: username, + email: email, + password: password, + address: address, + }), + headers: { "Content-Type": "application/json" }, + }); + if (!response.ok) { + throw new Error("Network response was not ok"); + } + const result = await response.json(); + console.log(result); + } catch (error) { + console.error("Error adding new user:", error); + } + }; + return ( -
+

Love to read and want to meet fellow book enthusiasts?

- Register now for our OMC Book Club and dive into lively discussions, discover new genres, and share your - favorite reads! + Register now for our OMC Book Club and dive into lively discussions, + discover new genres, and share your favorite reads!

- - - - - + setName(event.target.value)} + /> + setEmail(event.target.value)} + />
Address - + setStreet(event.target.value)} + />
- + setPostCode(event.target.value)} + />
- + setCity(event.target.value)} + />
- + setUsername(event.target.value)} + /> + + setPassword(event.target.value)} + /> - + setVerifyPassword(event.target.value)} + />
+ ; +export const Button = ({ btnText, type, onClick }) => { + return ( + + ); }; diff --git a/frontend/src/components/LogIn.jsx b/frontend/src/components/LogIn.jsx index 22afd8090..67dce60ab 100644 --- a/frontend/src/components/LogIn.jsx +++ b/frontend/src/components/LogIn.jsx @@ -32,6 +32,11 @@ export const LogIn = () => { } }; + const logOut = () => { + setAccessToken(""); + window.location.reload(); + }; + return ( <>
@@ -60,9 +65,10 @@ export const LogIn = () => { onChange={(event) => setPassword(event.target.value)} />
-