From 59002c08cb2d5a0fe2022db48a74357f77821b7c Mon Sep 17 00:00:00 2001 From: asm Date: Thu, 5 Oct 2023 19:03:32 +0200 Subject: [PATCH 1/3] DV-000281: Fix sign in and sign up forms. --- cypress/support/pages/NavSubPage.cy.js | 6 +- frontend/src/components/Modal.module.css | 125 +++++++++++++++--- frontend/src/components/SignIn.js | 55 +++++++- .../user/SimpleIntegrationUsersTest.java | 41 +++++- 4 files changed, 198 insertions(+), 29 deletions(-) diff --git a/cypress/support/pages/NavSubPage.cy.js b/cypress/support/pages/NavSubPage.cy.js index 0e2427bf..31e02a0d 100644 --- a/cypress/support/pages/NavSubPage.cy.js +++ b/cypress/support/pages/NavSubPage.cy.js @@ -10,7 +10,7 @@ export class NavSubPage { registerButton: ()=> cy.get('[data-cy="registerButton"]').should('be.visible'), cancelButton: ()=> cy.get('[data-cy="cancelButton"]').should('be.visible'), - emailInput: ()=> cy.get('[data-cy="emailInput"]').should('be.visible'), + loginInput: ()=> cy.get('[data-cy="loginInput"]').should('be.visible'), passwordInput: ()=> cy.get('[data-cy="passwordInput"]').should('be.visible'), firstNameInput: ()=> cy.get('[data-cy="firstNameInput"]').should('be.visible'), @@ -25,7 +25,7 @@ export class NavSubPage { this.elements.signInButton().should('have.text', text); this.elements.signInButton().click(); this.elements.loginButton(); - this.elements.emailInput(); + this.elements.loginInput(); this.elements.passwordInput(); this.elements.cancelButton().click(); } @@ -36,7 +36,7 @@ export class NavSubPage { this.elements.registerButton(); this.elements.firstNameInput(); this.elements.lastnameNameInput(); - this.elements.emailInput(); + this.elements.loginInput(); this.elements.passwordInput(); this.elements.cancelButton().click(); } diff --git a/frontend/src/components/Modal.module.css b/frontend/src/components/Modal.module.css index e50ffe60..d83c0410 100644 --- a/frontend/src/components/Modal.module.css +++ b/frontend/src/components/Modal.module.css @@ -160,31 +160,120 @@ margin-bottom: 5px; } - .form { + form { + background-color: #15172b; + border-radius: 20px; + box-sizing: border-box; + height: 500px; + padding: 20px; + width: 320px; + } + + title { + color: #eee; + font-family: sans-serif; + font-size: 36px; + font-weight: 600; + margin-top: 30px; + } + + .subtitle { + color: #eee; + font-family: sans-serif; + font-size: 16px; + font-weight: 600; + margin-top: 10px; + } + + .input-container { + height: 50px; position: relative; - z-index: 1; - background: #FFFFFF; - border-radius: 10px; - max-width: 360px; - margin: 0 auto 100px; - padding: 45px; - text-align: center; + width: 100%; } - - .form input { + + .ic1 { + margin-top: 40px; + } + + .ic2 { + margin-top: 30px; + } + + .input { + background-color: #303245; + border-radius: 12px; + border: 0; + box-sizing: border-box; + color: #eee; + font-size: 18px; + height: 100%; outline: 0; - background: #f2f2f2; + padding: 4px 20px 0; width: 100%; + } + + .cut { + background-color: #15172b; + border-radius: 10px; + height: 20px; + left: 20px; + position: absolute; + top: -20px; + transform: translateY(0); + transition: transform 200ms; + width: 76px; + } + + .cut-short { + width: 50px; + } + + .input:focus ~ .cut, + .input:not(:placeholder-shown) ~ .cut { + transform: translateY(8px); + } + + .placeholder { + color: #65657b; + font-family: sans-serif; + left: 20px; + line-height: 14px; + pointer-events: none; + position: absolute; + transform-origin: 0 50%; + transition: transform 200ms, color 200ms; + top: 20px; + } + + .input:focus ~ .placeholder, + .input:not(:placeholder-shown) ~ .placeholder { + transform: translateY(-30px) translateX(10px) scale(0.75); + } + + .input:not(:placeholder-shown) ~ .placeholder { + color: #808097; + } + + .input:focus ~ .placeholder { + color: #dc2f55; + } + + .submit { + background-color: #08d; + border-radius: 12px; border: 0; - border-radius: 5px; - margin: 0 0 15px; - padding: 15px; box-sizing: border-box; - font-size: 14px; - font-family: 'Comfortaa', cursive; + color: #eee; + cursor: pointer; + font-size: 18px; + height: 50px; + margin-top: 38px; + text-align: center; + width: 100%; } - .form input:focus { - background: #dbdbdb; + .submit:active { + background-color: #06b; } + \ No newline at end of file diff --git a/frontend/src/components/SignIn.js b/frontend/src/components/SignIn.js index 4c02a9f4..67ffb12f 100644 --- a/frontend/src/components/SignIn.js +++ b/frontend/src/components/SignIn.js @@ -1,8 +1,48 @@ -import React from "react"; +import React, { useState } from "react"; import styles from "./Modal.module.css"; import { RiCloseLine } from "react-icons/ri"; const SignIn = ({ setIsOpen1 }) => { + + const [loginError, setLoginError] = useState(''); + const [passwordError, setPasswordError] = useState(''); + + + const onSubmit = (e) => { + e.preventDefault(); + + const formData = new FormData(e.target); + + fetch("http://localhost:8080/login", { + method: "POST", + headers: { + Accept: "application/json", + "Content-Type": "application/json", + }, + body: JSON.stringify({ + email: formData.get('login'), + password: formData.get('password'), + }), + }) + .then((response) => response.json()) + .then((data) => { + if(data.fieldErrors) { + data.fieldErrors.forEach(fieldError => { + if(fieldError.field === 'login'){ + setLoginError(fieldError.message); + } + + if(fieldError.field === 'password'){ + setPasswordError(fieldError.message); + } + }); + } else { + alert("Success !!"); + } + }) + .catch((err) => err); + } + return ( <>
setIsOpen1(false)} /> @@ -11,20 +51,23 @@ const SignIn = ({ setIsOpen1 }) => {
Dialog
+ +
Are you sure you want to Sign In ?
+
- Email: + Login: + />{loginError ? {loginError} : ''} Password: { maxlength="4" data-cy="passwordInput" className="form-control input-modal" - /> + />{ passwordError ? {passwordError} : ''}