mirror of
https://github.com/originalmk/skrytka-app.git
synced 2024-11-20 10:28:50 +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 React, {useRef, useEffect, useState} from 'react';
|
||||||
import { useNavigate } from 'react-router-dom';
|
import { useNavigate } from 'react-router-dom';
|
||||||
import { TruckId } from './Truck';
|
import { TruckId } from './Truck';
|
||||||
@ -296,7 +295,6 @@ useEffect(() => {
|
|||||||
|
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
console.log('Wykonało sie 3')
|
|
||||||
name0ArrayFromDB.push(caches[0].cacheName);
|
name0ArrayFromDB.push(caches[0].cacheName);
|
||||||
name1ArrayFromDB.push(caches[1].cacheName);
|
name1ArrayFromDB.push(caches[1].cacheName);
|
||||||
name2ArrayFromDB.push(caches[2].cacheName);
|
name2ArrayFromDB.push(caches[2].cacheName);
|
||||||
|
@ -1,34 +1,30 @@
|
|||||||
import { TruckId } from "./Truck";
|
import { TruckId } from "./Truck";
|
||||||
import { AppContext } from './AppContext';
|
import { AppContext } from './AppContext';
|
||||||
import React, {useContext, useEffect, useState, useReducer} from 'react';
|
import React, {useContext, useEffect, useState} from 'react';
|
||||||
import { ButtonShowCorrectAnswer } from "./GetImageAndQuestion";
|
import { ButtonShowCorrectAnswer } from "./GetImageAndQuestion";
|
||||||
export let EndCacheId = "";
|
export let EndCacheId = "";
|
||||||
export let EndCorrectAnswer = "";
|
export let EndCorrectAnswer = "";
|
||||||
let clickcounter = 0;
|
|
||||||
|
|
||||||
const FetchData = ({isClick,score,setIsClick,setScore,navigate}) => {
|
const FetchData = ({isClick,score,setIsClick,setScore,navigate}) => {
|
||||||
if(clickcounter < 3)
|
|
||||||
clickcounter++;
|
|
||||||
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
fetch(`/random-question?fire-truck=${TruckId}`)
|
fetch(`/random-question?fire-truck=${TruckId}`)
|
||||||
.then(res => res.json())
|
.then(res => res.json())
|
||||||
.then(dataQuestion => {
|
.then(dataQuestion => {
|
||||||
|
if(isClick) {
|
||||||
const propertValuesObjectFromDb = Object.values(dataQuestion);
|
const propertValuesObjectFromDb = Object.values(dataQuestion);
|
||||||
|
|
||||||
if(clickcounter === 1)
|
|
||||||
EndCorrectAnswer = propertValuesObjectFromDb[1];
|
EndCorrectAnswer = propertValuesObjectFromDb[1];
|
||||||
EndCacheId = propertValuesObjectFromDb[0];
|
|
||||||
|
|
||||||
if(!isClick){
|
|
||||||
EndCorrectAnswer = propertValuesObjectFromDb[1];
|
|
||||||
EndCacheId = propertValuesObjectFromDb[0];
|
EndCacheId = propertValuesObjectFromDb[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
})
|
})
|
||||||
},[isClick])
|
})
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
|
|
||||||
@ -40,10 +36,11 @@ const FetchData = ({isClick,score,setIsClick,setScore,navigate}) => {
|
|||||||
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
export const QuizGetQuestion = ({score,isClick,setScore,setIsClick,navigate}) => {
|
export const QuizGetQuestion = ({score,isClick,setScore,setIsClick,navigate}) => {
|
||||||
return (
|
return (
|
||||||
<FetchData score = {score} isClick = {isClick} setScore = {setScore} setIsClick = {setIsClick} navigate = {navigate}/>
|
<FetchData score = {score} isClick = {isClick} setScore = {setScore} setIsClick = {setIsClick} navigate = {navigate}/>
|
||||||
)
|
)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user