mirror of
https://github.com/originalmk/skrytka-app.git
synced 2025-01-18 08:19:17 +00:00
return to the previous state with btnCorrectAnswer
This commit is contained in:
parent
c3d013d6b8
commit
7bf9684946
@ -1,4 +1,3 @@
|
||||
|
||||
import React, {useRef, useEffect, useState} from 'react';
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
import { TruckId } from './Truck';
|
||||
@ -296,7 +295,6 @@ useEffect(() => {
|
||||
|
||||
break;
|
||||
case 3:
|
||||
console.log('Wykonało sie 3')
|
||||
name0ArrayFromDB.push(caches[0].cacheName);
|
||||
name1ArrayFromDB.push(caches[1].cacheName);
|
||||
name2ArrayFromDB.push(caches[2].cacheName);
|
||||
|
@ -1,34 +1,30 @@
|
||||
import { TruckId } from "./Truck";
|
||||
import { AppContext } from './AppContext';
|
||||
import React, {useContext, useEffect, useState, useReducer} from 'react';
|
||||
import React, {useContext, useEffect, useState} 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) {
|
||||
const propertValuesObjectFromDb = Object.values(dataQuestion);
|
||||
|
||||
if(clickcounter === 1)
|
||||
EndCorrectAnswer = propertValuesObjectFromDb[1];
|
||||
EndCacheId = propertValuesObjectFromDb[0];
|
||||
|
||||
if(!isClick){
|
||||
EndCorrectAnswer = propertValuesObjectFromDb[1];
|
||||
EndCacheId = propertValuesObjectFromDb[0];
|
||||
}
|
||||
|
||||
|
||||
})
|
||||
},[isClick])
|
||||
})
|
||||
|
||||
|
||||
|
||||
return (
|
||||
<>
|
||||
|
||||
@ -40,10 +36,11 @@ const FetchData = ({isClick,score,setIsClick,setScore,navigate}) => {
|
||||
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
export const QuizGetQuestion = ({score,isClick,setScore,setIsClick,navigate}) => {
|
||||
return (
|
||||
<FetchData score = {score} isClick = {isClick} setScore = {setScore} setIsClick = {setIsClick} navigate = {navigate}/>
|
||||
)
|
||||
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user