Skip to content

Commit

Permalink
Merge pull request #23 from techswitch-learners/mm-107-startquizbuttonv2
Browse files Browse the repository at this point in the history
mm-107-startquizbuttonv2: correction made as per PR review comments
  • Loading branch information
Purbai authored Aug 1, 2024
2 parents 6b13f3b + d13ccf6 commit 07f9e43
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 @@ -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<HTMLFormElement>) => {
Expand All @@ -29,24 +28,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 07f9e43

Please sign in to comment.