diff --git a/src/Home/Home.scss b/src/Home/Home.scss index 190044f..881be06 100644 --- a/src/Home/Home.scss +++ b/src/Home/Home.scss @@ -2,4 +2,23 @@ background-repeat: no-repeat; background-size: cover; background-position: center; +} + +.form { + display: flex; + flex-direction: column; + align-items: center; + justify-content: center; +} + +label { + margin: 10pix +} + +input { + margin: 10px; +} + +button { + margin: 10px; } \ No newline at end of file diff --git a/src/Home/Home.test.tsx b/src/Home/Home.test.tsx deleted file mode 100644 index 072609a..0000000 --- a/src/Home/Home.test.tsx +++ /dev/null @@ -1,20 +0,0 @@ -import { fireEvent, render, screen } from "@testing-library/react"; -import Home from "./Home"; -import "@testing-library/jest-dom"; -import React, { useState } from "react"; - -test.skip("user's name is displayed on form submission", () => { - const name = "Luigi"; - const [username, setUsername] = useState(name); - - render(); - - const textArea = screen.getByLabelText(/Enter name:/); - fireEvent.change(textArea, { target: { value: name }}); - - const submitButton = screen.getByRole("button"); - fireEvent.click(submitButton); - - const welcomeMessage = screen.getByText(/Welcome Luigi!/i); - expect(welcomeMessage).toBeInTheDocument(); -}) \ No newline at end of file diff --git a/src/Home/Home.tsx b/src/Home/Home.tsx index 418e34d..6cd6766 100644 --- a/src/Home/Home.tsx +++ b/src/Home/Home.tsx @@ -3,14 +3,13 @@ import { useNavigate } from "react-router-dom"; import DisplayBackgroundImage from '../images/DisplayBackgroundImage'; import './Home.scss' -interface getUserProp{ +interface HomeProps{ username:string; setUsername:(uname:string)=>void; } -function Home(props:getUserProp) { +function Home(props:HomeProps) { - //const [username, setUsername] = useState(""); const [submitStatus, setSubmitStatus] = useState(false); const handleSubmit = (event: React.FormEvent) => { @@ -29,24 +28,20 @@ function Home(props:getUserProp) { return ( <>
- {/* Other components and content */} -
+ {submitStatus ?

Welcome {props.username}!

: null}
- -
) diff --git a/src/Menu/MenuItems.tsx b/src/Menu/MenuItems.tsx index f929599..a766252 100644 --- a/src/Menu/MenuItems.tsx +++ b/src/Menu/MenuItems.tsx @@ -2,5 +2,5 @@ // list of the menu options that will be displayed when clicking on hamburger button export const menuItems = [ { label: 'Home', link: '/' }, - { label: 'Quiz', link: '' }, + { label: 'Quiz', link: '/quiz' }, ]; \ No newline at end of file diff --git a/src/Quiz/Quiz.tsx b/src/Quiz/Quiz.tsx index b5dac8f..0f7f0fb 100644 --- a/src/Quiz/Quiz.tsx +++ b/src/Quiz/Quiz.tsx @@ -2,7 +2,7 @@ import { QuestionDisplay } from "../QuestionDisplay/QuestionDisplay" import { getQuizQuestions } from "../getQuizQuestions/getQuizQuestions" import { useState, useEffect } from "react"; -interface getUserProp{ +interface QuizProps{ username:string; } @@ -25,7 +25,7 @@ export function Quiz (props:getUserProp) { setCurrentIndex(currentIndex + 1); } } - + return (
User : {props.username}