mirror of
https://github.com/originalmk/skrytka-app.git
synced 2025-01-18 16:29:17 +00:00
fix bug with end screen and btnCorrectAnswer
This commit is contained in:
parent
89ee81f11f
commit
1092ac659b
@ -136,7 +136,7 @@ export const QuizDataImageFromDb = [
|
||||
},
|
||||
}
|
||||
];
|
||||
|
||||
let MAX_POINT = 9;
|
||||
|
||||
|
||||
|
||||
@ -379,10 +379,10 @@ useEffect(() => {
|
||||
const buttonsElementArray = Array.from(buttonsElement)
|
||||
setIsClick(!isClick);
|
||||
|
||||
if(score === 9) {
|
||||
if(score === MAX_POINT) {
|
||||
navigate('/result');
|
||||
}
|
||||
if(isClick === true) {
|
||||
if(isClick) {
|
||||
buttonsElementArray.forEach(button => {
|
||||
|
||||
|
||||
|
@ -1,47 +1,45 @@
|
||||
import { TruckId } from "./Truck";
|
||||
import { AppContext } from './AppContext';
|
||||
import React, {useContext, useEffect, useState} from 'react';
|
||||
import React, {useContext, useEffect, useState, useReducer} from 'react';
|
||||
import { ButtonShowCorrectAnswer } from "./GetImageAndQuestion";
|
||||
export let EndCacheId = "";
|
||||
export let EndCorrectAnswer = "";
|
||||
|
||||
let clickcounter = 0;
|
||||
|
||||
const FetchData = ({isClick,score,setIsClick,setScore,navigate}) => {
|
||||
if(clickcounter < 3)
|
||||
clickcounter++;
|
||||
|
||||
|
||||
useEffect(() => {
|
||||
fetch(`/random-question?fire-truck=${TruckId}`)
|
||||
.then(res => res.json())
|
||||
.then(dataQuestion => {
|
||||
if(isClick === true) {
|
||||
const propertValuesObjectFromDb = Object.values(dataQuestion);
|
||||
EndCorrectAnswer = propertValuesObjectFromDb[1];
|
||||
|
||||
if(clickcounter === 1)
|
||||
EndCorrectAnswer = propertValuesObjectFromDb[1];
|
||||
EndCacheId = propertValuesObjectFromDb[0];
|
||||
|
||||
if(!isClick){
|
||||
EndCorrectAnswer = propertValuesObjectFromDb[1];
|
||||
EndCacheId = propertValuesObjectFromDb[0];
|
||||
}
|
||||
|
||||
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
},[isClick])
|
||||
return (
|
||||
<>
|
||||
|
||||
<div className="questionDiv">
|
||||
<h1 className='questionText1'>{EndCorrectAnswer}</h1>
|
||||
<button onClick={() => ButtonShowCorrectAnswer(isClick, setIsClick , score , setScore, navigate)} className='NextQuestionButton'>{isClick ? "Pokaż odpowiedź" : "Następne pytanie"}</button>
|
||||
<button onClick={() => ButtonShowCorrectAnswer(isClick, setIsClick , score , setScore, navigate)} className='NextQuestionButton'>{isClick ? "Pokaż odpowiedź" : "Następne pytanie"}</button>
|
||||
</div>
|
||||
</>
|
||||
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
export const QuizGetQuestion = ({score,isClick,setScore,setIsClick,navigate}) => {
|
||||
return (
|
||||
<FetchData score = {score} isClick = {isClick} setScore = {setScore} setIsClick = {setIsClick} navigate = {navigate}/>
|
||||
|
@ -11,12 +11,9 @@ import 'react-circular-progressbar/dist/styles.css';
|
||||
|
||||
const Result = () => {
|
||||
const navigate = useNavigate();
|
||||
console.log(endScore);
|
||||
useEffect(() => {
|
||||
if(!endScore) navigate('/');
|
||||
},[])
|
||||
|
||||
|
||||
useEffect(() => {
|
||||
if(!SecondSeconds) navigate('/');
|
||||
},[])
|
||||
if(endScore) {
|
||||
useEffect(() => {
|
||||
|
||||
|
@ -1,11 +1,11 @@
|
||||
export let SecondSeconds = 1;
|
||||
export let SecondSeconds = 0;
|
||||
export let SecondMinutes = 0;
|
||||
|
||||
import React, { useState, useEffect } from 'react';
|
||||
|
||||
const Timer = () => {
|
||||
const [time, setTime] = useState(0);
|
||||
let seconds = Math.floor(time % 60);
|
||||
let seconds = Math.floor(time % 60) + 1;
|
||||
let minutes = Math.floor(time / 60);
|
||||
|
||||
useEffect(() => {
|
||||
|
Loading…
x
Reference in New Issue
Block a user