main props
All checks were successful
Create and publish a Docker image / Publish image (push) Successful in 52s
Create and publish a Docker image / Deploy image (push) Successful in 4s

This commit is contained in:
VITALY-VORON 2023-08-26 07:31:19 +03:00
parent f492f2efb9
commit a26865508a
4 changed files with 11 additions and 16 deletions

View File

@ -13,9 +13,6 @@ function App() {
const [cardInfo, setCardInfo] = useState([]); const [cardInfo, setCardInfo] = useState([]);
const [userData, setUserData] = useState({}); const [userData, setUserData] = useState({});
const selectedCity = userData.selectedCity;
const identification = userData.unique;
const handleButtonValue = (value) => { const handleButtonValue = (value) => {
setIsHidden(true); setIsHidden(true);
setTimeout(() => { setTimeout(() => {
@ -29,7 +26,6 @@ function App() {
axios.get('https://easytravel.zetcraft.ru/v1/GetAllCards') axios.get('https://easytravel.zetcraft.ru/v1/GetAllCards')
.then(response => { .then(response => {
setCardInfo(response.data); setCardInfo(response.data);
console.log(cardInfo.length);
}) })
.catch(error => { .catch(error => {
console.error('Error fetching data:', error); console.error('Error fetching data:', error);
@ -39,7 +35,6 @@ function App() {
}, []); }, []);
useEffect(() => { useEffect(() => {
console.log(userData);
// Загрузка userData из localStorage при монтировании компонента // Загрузка userData из localStorage при монтировании компонента
const savedUserData = JSON.parse(localStorage.getItem('userData')); const savedUserData = JSON.parse(localStorage.getItem('userData'));
if (savedUserData) { if (savedUserData) {
@ -62,7 +57,7 @@ function App() {
content = <Tinder getValue={handleButtonValue} cardInfo={cardInfo} userData={userData} setUserData={setUserData} /> content = <Tinder getValue={handleButtonValue} cardInfo={cardInfo} userData={userData} setUserData={setUserData} />
break; break;
case '/main': case '/main':
content = <Main userData={userData} selectedCity={selectedCity} identification={identification} /> content = <Main />
break; break;
case '/city': case '/city':
content = <City getValue={handleButtonValue} setUserData={setUserData} /> content = <City getValue={handleButtonValue} setUserData={setUserData} />
@ -75,7 +70,7 @@ function App() {
return ( return (
<div className={`App ${isHidden ? 'hidden' : ''}`}> <div className={`App ${isHidden ? 'hidden' : ''}`}>
{arrayLength !== 0 ? <Main /> : content } {arrayLength !== 0 ? <Main userData={userData}/> : content}
</div> </div>
); );
} }

View File

@ -109,7 +109,8 @@ const City = (props) => {
<button <button
onClick={() => { onClick={() => {
route('/second') route('/second')
setUserData(prevUserData => ({ ...prevUserData, selectedCity: selectedCity})); setUserData({selectedCity: selectedCity});
console.log(selectedCity);
}} }}
className="animated-button" className="animated-button"
style={{ style={{

View File

@ -1,13 +1,10 @@
import React, {useState, useEffect} from "react"; import React, { useEffect } from "react";
const Main = ({userData}) => {
const Main = (props) => {
const city = props.selectedCity;
const id = props.identification;
useEffect(() => { useEffect(() => {
console.log(city && id); console.log(userData.selectedCity);
console.log(userData.unique);
}) })
return ( return (

View File

@ -44,7 +44,9 @@ const Tinder = (props) => {
var uniqueIds = [...new Set(allIds)]; var uniqueIds = [...new Set(allIds)];
if(uniqueIds.length === cardInfo.length) { if(uniqueIds.length === cardInfo.length) {
route('/main'); route('/main');
setUserData(prevUserData => ({ ...prevUserData, unique })); setUserData(prevUserData => ({ ...prevUserData, unique: unique }));
console.log(unique);
console.log(props.userData);
} }
}} }}
> >