Skip to content

Commit

Permalink
mm-107-startquizbuttonv2: correction made as per PR review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Anum1608 committed Aug 1, 2024
1 parent a189189 commit 371c2ec
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 29 deletions.
20 changes: 0 additions & 20 deletions src/Home/Home.test.tsx

This file was deleted.

9 changes: 2 additions & 7 deletions src/Home/Home.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,13 @@ import React, { useState } from "react";
import { useNavigate } from "react-router-dom";
import DisplayBackgroundImage from '../images/DisplayBackgroundImage';

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<HTMLFormElement>) => {
Expand All @@ -28,24 +27,20 @@ function Home(props:getUserProp) {
return (
<>
<main className="home-content" style={{ backgroundImage: `url(${homeBackgroundImage})` }}>

{/* Other components and content */}
<form onSubmit={handleSubmit}>
<label>Enter name:
<input type="text"
value={props.username}
//onChange={username => setUsername(username.target.value)}
onChange={(username) => {props.setUsername(username.target.value)}}
/>
</label>
<button type="submit">Submit</button>
{submitStatus ? <p>Welcome {props.username}!</p> : null}
</form>

<button className="startQuizButton" onClick={routeChange}>
Start quiz
</button>

</main>
</>
)
Expand Down
4 changes: 2 additions & 2 deletions src/Quiz/Quiz.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { QuestionDisplay } from "../QuestionDisplay/QuestionDisplay"

interface getUserProp{
interface QuizProps{
username:string;
}

export function Quiz (props:getUserProp) {
export function Quiz (props:QuizProps) {
return (
<div>
User : {props.username}
Expand Down

0 comments on commit 371c2ec

Please sign in to comment.