main props
This commit is contained in:
parent
f492f2efb9
commit
a26865508a
@ -13,9 +13,6 @@ function App() {
|
||||
const [cardInfo, setCardInfo] = useState([]);
|
||||
const [userData, setUserData] = useState({});
|
||||
|
||||
const selectedCity = userData.selectedCity;
|
||||
const identification = userData.unique;
|
||||
|
||||
const handleButtonValue = (value) => {
|
||||
setIsHidden(true);
|
||||
setTimeout(() => {
|
||||
@ -29,7 +26,6 @@ function App() {
|
||||
axios.get('https://easytravel.zetcraft.ru/v1/GetAllCards')
|
||||
.then(response => {
|
||||
setCardInfo(response.data);
|
||||
console.log(cardInfo.length);
|
||||
})
|
||||
.catch(error => {
|
||||
console.error('Error fetching data:', error);
|
||||
@ -39,7 +35,6 @@ function App() {
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
console.log(userData);
|
||||
// Загрузка userData из localStorage при монтировании компонента
|
||||
const savedUserData = JSON.parse(localStorage.getItem('userData'));
|
||||
if (savedUserData) {
|
||||
@ -62,7 +57,7 @@ function App() {
|
||||
content = <Tinder getValue={handleButtonValue} cardInfo={cardInfo} userData={userData} setUserData={setUserData} />
|
||||
break;
|
||||
case '/main':
|
||||
content = <Main userData={userData} selectedCity={selectedCity} identification={identification} />
|
||||
content = <Main />
|
||||
break;
|
||||
case '/city':
|
||||
content = <City getValue={handleButtonValue} setUserData={setUserData} />
|
||||
@ -75,7 +70,7 @@ function App() {
|
||||
|
||||
return (
|
||||
<div className={`App ${isHidden ? 'hidden' : ''}`}>
|
||||
{arrayLength !== 0 ? <Main /> : content }
|
||||
{arrayLength !== 0 ? <Main userData={userData}/> : content}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
@ -109,7 +109,8 @@ const City = (props) => {
|
||||
<button
|
||||
onClick={() => {
|
||||
route('/second')
|
||||
setUserData(prevUserData => ({ ...prevUserData, selectedCity: selectedCity}));
|
||||
setUserData({selectedCity: selectedCity});
|
||||
console.log(selectedCity);
|
||||
}}
|
||||
className="animated-button"
|
||||
style={{
|
||||
|
@ -1,13 +1,10 @@
|
||||
import React, {useState, useEffect} from "react";
|
||||
import React, { useEffect } from "react";
|
||||
|
||||
|
||||
const Main = (props) => {
|
||||
|
||||
const city = props.selectedCity;
|
||||
const id = props.identification;
|
||||
const Main = ({userData}) => {
|
||||
|
||||
useEffect(() => {
|
||||
console.log(city && id);
|
||||
console.log(userData.selectedCity);
|
||||
console.log(userData.unique);
|
||||
})
|
||||
|
||||
return (
|
||||
|
@ -44,7 +44,9 @@ const Tinder = (props) => {
|
||||
var uniqueIds = [...new Set(allIds)];
|
||||
if(uniqueIds.length === cardInfo.length) {
|
||||
route('/main');
|
||||
setUserData(prevUserData => ({ ...prevUserData, unique }));
|
||||
setUserData(prevUserData => ({ ...prevUserData, unique: unique }));
|
||||
console.log(unique);
|
||||
console.log(props.userData);
|
||||
}
|
||||
}}
|
||||
>
|
||||
|
Loading…
x
Reference in New Issue
Block a user