-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11 from MunschThomas/pauffine
Pauffine
- Loading branch information
Showing
12 changed files
with
375 additions
and
289 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
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 |
---|---|---|
@@ -1,103 +1,117 @@ | ||
import { useEffect, useState, useRef } from "react"; | ||
import "./ModalQ.css"; | ||
import { useEffect, useState, useRef } from 'react' | ||
import './ModalQ.css' | ||
|
||
const ModalQ = ({ pause, dataQuestion, setDataQuestion, launchNewGame , rightAnswer, setRightAnswer}) => { | ||
const ModalQ = ({ | ||
pause, | ||
dataQuestion, | ||
setDataQuestion, | ||
launchNewGame, | ||
rightAnswer, | ||
setRightAnswer, | ||
}) => { | ||
const focus1 = useRef(null) | ||
const [isAsked, setIsAsked] = useState([]); | ||
const [clk, setClk] = useState(false); | ||
|
||
const [isAsked, setIsAsked] = useState([]) | ||
const [clk, setClk] = useState(false) | ||
|
||
// const onFoc = () => { | ||
// focus.current.focus() | ||
|
||
// } | ||
|
||
const [answerCorrect, setAnswerCorrect] = useState(null); | ||
const [selectedAnswer, setSelectedAnswer] = useState(null); | ||
|
||
const [answerCorrect, setAnswerCorrect] = useState(null) | ||
const [selectedAnswer, setSelectedAnswer] = useState(null) | ||
|
||
const checkKey = (choice) => { | ||
focus1.current.focus() | ||
setSelectedAnswer(choice); | ||
setSelectedAnswer(choice) | ||
if (choice === isAsked.reponse) { | ||
const showTrue = document.getElementById("correctAnswerReavel"); | ||
showTrue.style.visibility = "visible"; | ||
const showTrue = document.getElementById('correctAnswerReavel') | ||
showTrue.style.visibility = 'visible' | ||
setRightAnswer((rightAnswer) => rightAnswer + 1) | ||
} else { | ||
const showTrue = document.getElementById("wrongAnswerReavel"); | ||
showTrue.style.visibility = "visible"; | ||
const showTrue = document.getElementById('wrongAnswerReavel') | ||
showTrue.style.visibility = 'visible' | ||
} | ||
}; | ||
} | ||
const launch = (e) => { | ||
console.log("keyboardEvent", e); | ||
console.log('keyboardEvent', e) | ||
// let wrapper = document.getElementById("wrapper"); | ||
|
||
if (e.key === " ") { | ||
launchNewGame(); | ||
if (e.key === ' ') { | ||
launchNewGame() | ||
} | ||
if (e.key === "ArrowLeft") { | ||
checkKey("Vrai"); | ||
console.log('efefef'); | ||
if (e.key === 'ArrowLeft') { | ||
checkKey('Vrai') | ||
console.log('efefef') | ||
} | ||
if (e.key === "ArrowRight") { | ||
checkKey("Faux"); | ||
if (e.key === 'ArrowRight') { | ||
checkKey('Faux') | ||
} | ||
}; | ||
} | ||
|
||
useEffect(() => {console.log(rightAnswer); },[rightAnswer]) | ||
useEffect(() => { | ||
console.log(rightAnswer) | ||
}, [rightAnswer]) | ||
|
||
const handleListItemClick = (event) => { | ||
console.log("CONTENT", event.target.textContent); | ||
setSelectedAnswer(event.target.textContent); | ||
console.log('CONTENT', event.target.textContent) | ||
setSelectedAnswer(event.target.textContent) | ||
if (event.target.textContent === isAsked.reponse) { | ||
const showTrue = document.getElementById("correctAnswerReavel"); | ||
showTrue.style.visibility = "visible"; | ||
setRightAnswer(rightAnswer => rightAnswer + 1) | ||
const showTrue = document.getElementById('correctAnswerReavel') | ||
showTrue.style.visibility = 'visible' | ||
setRightAnswer((rightAnswer) => rightAnswer + 1) | ||
} else { | ||
const showTrue = document.getElementById("wrongAnswerReavel"); | ||
showTrue.style.visibility = "visible"; | ||
const showTrue = document.getElementById('wrongAnswerReavel') | ||
showTrue.style.visibility = 'visible' | ||
} | ||
}; | ||
} | ||
useEffect(() => { | ||
const quest = Math.floor(Math.random() * dataQuestion.length); | ||
|
||
console.log("dataQuestion", dataQuestion, "quest", quest); | ||
const quest = Math.floor(Math.random() * dataQuestion.length) | ||
|
||
const chosenQuest = dataQuestion.filter( | ||
(dataQuestion, i) => i !== quest | ||
); | ||
const newTab = dataQuestion.filter((el) => el.id !== chosenQuest[0].id); | ||
console.log("newTab", newTab); | ||
setDataQuestion(newTab); | ||
setIsAsked(...chosenQuest); | ||
console.log('dataQuestion', dataQuestion, 'quest', quest) | ||
const chosenQuest = dataQuestion.filter((dataQuestion, i) => i === quest) | ||
|
||
|
||
}, [clk]); | ||
const newTab = dataQuestion.filter((el) => el.id !== chosenQuest[0].id) | ||
console.log('newTab', newTab) | ||
setDataQuestion(newTab) | ||
setIsAsked(...chosenQuest) | ||
}, [clk]) | ||
|
||
useEffect(() => { | ||
console.log("in use effext", dataQuestion); | ||
}, [dataQuestion]); | ||
console.log('in use effext', dataQuestion) | ||
}, [dataQuestion]) | ||
|
||
return ( | ||
<div ref={focus1} className="wrapper" id="wrapper" tabIndex="0" onKeyDown={(e) => launch(e)}> | ||
<div className="wrapQuest"> | ||
<div | ||
ref={focus1} | ||
className='wrapper' | ||
id='wrapper' | ||
tabIndex='0' | ||
onKeyDown={(e) => launch(e)} | ||
> | ||
<div className='wrapQuest'> | ||
<h1>{isAsked.question}</h1> | ||
<div className="AnswerButton"> | ||
<div className='AnswerButton'> | ||
<button onClick={(e) => handleListItemClick(e)}>Vrai</button> | ||
<button onClick={(e) => handleListItemClick(e)}>Faux</button> | ||
</div> | ||
<div className="ReavelCorrect"> | ||
<div id="correctAnswerReavel" className="AnswerReavel"> | ||
<div className='ReavelCorrect'> | ||
<div id='correctAnswerReavel' className='AnswerReavel'> | ||
<h2>Bravo</h2> | ||
</div> | ||
<div id="wrongAnswerReavel" className="AnswerReavel"> | ||
<div id='wrongAnswerReavel' className='AnswerReavel'> | ||
<h2>Oh oh, {isAsked.correction}</h2> | ||
</div> | ||
<button className={selectedAnswer ? `visible` : `hidden`} onClick={() => launchNewGame()}>Continuer</button> | ||
<button | ||
className={selectedAnswer ? `visible` : `hidden`} | ||
onClick={() => launchNewGame()} | ||
> | ||
Continuer | ||
</button> | ||
</div> | ||
</div> | ||
</div> | ||
); | ||
}; | ||
) | ||
} | ||
|
||
export default ModalQ; | ||
export default ModalQ |
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 |
---|---|---|
@@ -1,28 +1,30 @@ | ||
import React from "react"; | ||
import ReactDOM from "react-dom"; | ||
import { BrowserRouter } from "react-router-dom"; | ||
import "./index.css"; | ||
import App from "./App"; | ||
import reportWebVitals from "./reportWebVitals"; | ||
import { Auth0Provider } from "@auth0/auth0-react"; | ||
import React from 'react' | ||
import ReactDOM from 'react-dom' | ||
import '../src/assets/fonts/Enedis-Bold.woff' | ||
|
||
import { BrowserRouter } from 'react-router-dom' | ||
import './index.css' | ||
import App from './App' | ||
import reportWebVitals from './reportWebVitals' | ||
import { Auth0Provider } from '@auth0/auth0-react' | ||
|
||
ReactDOM.render( | ||
<React.StrictMode> | ||
<BrowserRouter> | ||
<Auth0Provider | ||
domain="dev-qtkc-hsd.eu.auth0.com" | ||
clientId="hSKzbkTq6SqfvPJe56f8thzRagYLwU5J" | ||
domain='dev-qtkc-hsd.eu.auth0.com' | ||
clientId='hSKzbkTq6SqfvPJe56f8thzRagYLwU5J' | ||
redirectUri={window.location.origin} | ||
> | ||
<App /> | ||
</Auth0Provider> | ||
</BrowserRouter> | ||
</React.StrictMode>, | ||
|
||
document.getElementById("root") | ||
); | ||
document.getElementById('root') | ||
) | ||
|
||
// If you want to start measuring performance in your app, pass a function | ||
// to log results (for example: reportWebVitals(console.log)) | ||
// or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals | ||
reportWebVitals(); | ||
reportWebVitals() |
Oops, something went wrong.