generated from scaffold-eth/scaffold-eth-2
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
259 additions
and
78 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
"use client"; | ||
|
||
import React, { useState } from "react"; | ||
|
||
const questions = [ | ||
{ | ||
id: 0, | ||
question: "Do you enjoy this voting application?", | ||
answers: [ | ||
{ title: "Yes", score: 0 }, | ||
{ title: "No", score: 1 }, | ||
], | ||
}, | ||
]; | ||
|
||
function VotingRadio() { | ||
const [checkBox, setCheckBox] = useState(); | ||
|
||
const handleInputChange = (score: any) => { | ||
setCheckBox(score); | ||
}; | ||
|
||
return ( | ||
// <-- Here you need to return something from component | ||
<> | ||
<h1>{questions[0].question}</h1> | ||
{questions[0].answers.map(({ title, score }: any) => ( | ||
<label key={score}> | ||
<div> | ||
<input | ||
type="radio" | ||
value={score} | ||
name={score} | ||
onChange={() => handleInputChange(score)} | ||
checked={score === checkBox} | ||
/> | ||
{title} | ||
</div> | ||
</label> | ||
))} | ||
<button | ||
onClick={() => { | ||
console.log(checkBox); | ||
}} | ||
> | ||
Vote! | ||
</button> | ||
</> | ||
); | ||
} | ||
|
||
export default VotingRadio; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
import Voting from "./_components/Voting"; | ||
import VotingRadio from "./_components/VotingRadio"; | ||
|
||
export default function Page() { | ||
return ( | ||
<> | ||
<Voting /> | ||
<VotingRadio /> | ||
</> | ||
); | ||
} |
Oops, something went wrong.