Skip to content

Commit f2526fe

Browse files
committed
add: reset game
1 parent 93bf4a7 commit f2526fe

File tree

4 files changed

+24
-20
lines changed

4 files changed

+24
-20
lines changed

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,5 @@
2121
npm-debug.log*
2222
yarn-debug.log*
2323
yarn-error.log*
24+
25+
.firebase/

firebase.json

+2-18
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,9 @@
22
"hosting": {
33
"public": "build",
44
"ignore": [
5-
"**/.*",
65
"firebase.json",
7-
"**/node_modules/**",
8-
"/build/asset-manifest.json",
9-
"/build/static/js/*.js.map"
10-
],
11-
"rewrites": [
12-
{
13-
"source": "**",
14-
"destination": "/index.html"
15-
}
16-
],
17-
"headers": [{
18-
"source": "index.html",
19-
"headers" : [{
20-
"key" : "Access-Control-Allow-Origin",
21-
"value" : "*"
22-
}]
23-
}
6+
"**/.*",
7+
"**/node_modules/**"
248
]
259
}
2610
}

src/components/QuizForm.js

+11-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import {
44
differenceInMilliseconds
55
} from "date-fns"
66

7-
const QuizForm = ({ player, type }) => {
7+
const QuizForm = ({ player, type, reset }) => {
88

99
const [form, setForm] = useState({
1010
questions: require(`../questions/${type}`)[type],
@@ -114,6 +114,16 @@ const QuizForm = ({ player, type }) => {
114114
<span className="badge badge-primary">{ form.finishTimeSeconds }</span>
115115
</li>
116116
</ul>
117+
118+
<div className="mt-3">
119+
<button
120+
className="btn btn-block btn-success btn-lg"
121+
onClick={ () => { reset() } }
122+
type="button"
123+
>
124+
Novo Jogo
125+
</button>
126+
</div>
117127
</div>
118128
)}
119129
</div>

src/pages/App.js

+9-1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,14 @@ const App = () => {
1414
console.log('< APP : STATE > ', state)
1515
})
1616

17+
const resetForm = () => {
18+
setState({
19+
name: '',
20+
type: false,
21+
startQuiz: false
22+
})
23+
}
24+
1725
return (
1826
<div className="App animated fadeIn">
1927
<div className="container">
@@ -28,7 +36,7 @@ const App = () => {
2836
{state.startQuiz && (
2937
<div className={`row animated ${state.startQuiz ? 'fadeInDown' : 'fadeOutDown'}`}>
3038
<div className="col-xs-12 ml-auto mr-auto">
31-
<QuizForm player={state.name} type={state.type} />
39+
<QuizForm player={state.name} type={state.type} reset={ resetForm } />
3240
</div>
3341
</div>
3442
)}

0 commit comments

Comments
 (0)