import react, { useRef, useState } from 'react' import TinderCard from 'react-tinder-card' import './style.css' import { Block } from '../../elements/Block' import { Card, TinderCardContent } from '../../elements/Card' import { Button } from '../../elements/Button' import { dailySelectionBuild, dailySelectionGenerate, saveTinderPath, startTinder, swipe, } from '../../client' import {useNavigate} from 'react-router-dom'; import { MyMap } from '../../elements/map' interface IEventData{ title: string; description: string; id: string; } export const EventMatch: react.FC = () => { const ref = useRef(null); const navigate = useNavigate(); const started = useRef(false); const [dailyData, setDailyData] = useState([]); const [resData, setResData] = useState([]); const queried = useRef(false); const [answerData, setAnswerData] = useState([]); if (!started.current) { started.current = true; dailySelectionGenerate().then((e) => { console.log(e) setDailyData(e.events); }) } return
{ dailyData.map((e) => { return { console.log(dailyData.indexOf(e)) if (dailyData.indexOf(e) == 0) { if (!resData.length) return; if (!queried.current) { dailySelectionBuild(resData).then((e) => { setAnswerData(e.path); }); queried.current = true; } } if (type == 'right') { setResData(resData.concat([ { 'action': 'right', 'oid': (e as any).oid } as any ])) } }} > }) }
{ dailyData.length && !answerData.length ? (!queried.current ?
Вы не выбрали ни одного события, Мы не можем сгенерировать вам маршрут. Возвращяйтесь к нам завтра. { navigate('/'); }} >Вернуться на главную
: Подождите немного, мы генерируем для вас ежедневный маршрут) : answerData.length ? e.type == 'point').map((e: any) => {return { cords: [e.point.lat, e.point.lon], title: e.point.title, description: "" }}) }> : <> } { answerData.length ?
: <> }
}