diff --git a/public/language.svg b/public/language.svg index 2518fb9..f9f9367 100644 --- a/public/language.svg +++ b/public/language.svg @@ -1,16 +1,6 @@ - - - - - - - - - - - - - - - + + + + + diff --git a/public/menu.svg b/public/menu.svg index d17ca80..8e583ca 100644 --- a/public/menu.svg +++ b/public/menu.svg @@ -1,8 +1,8 @@ - + - + diff --git a/src/elements/Header/index.tsx b/src/elements/Header/index.tsx index de0ae13..88e5692 100644 --- a/src/elements/Header/index.tsx +++ b/src/elements/Header/index.tsx @@ -14,7 +14,7 @@ export const RusPassHeader:React.FC = () =>{ navigate('/')}>
- + navigate('/buyed')} src='/language.svg'> navigate('/favorites')}> navigate('/login')} >
diff --git a/src/elements/RouteCard/index.tsx b/src/elements/RouteCard/index.tsx index bdb7804..5715f49 100644 --- a/src/elements/RouteCard/index.tsx +++ b/src/elements/RouteCard/index.tsx @@ -7,6 +7,7 @@ import Sidebar from "react-sidebar"; import { PlaceCard } from "../TourCard"; import { Collapse, Tabs, TabsProps } from "antd"; import { backend } from "../../consts"; +import { useNavigate } from "react-router-dom"; export interface RouteCardIE{ rawProps:any, @@ -36,7 +37,7 @@ export const RouteCard:React.FC = (props) =>{ const [showMap, setShowMap] = useState(false) const [selectedDay, setSelectedDay] = useState('0') const [liked, setLiked] = useState(false) - + let navigate = useNavigate() let cntPlaces = 0 props.options.forEach((route)=>{ cntPlaces += route.paths.length @@ -92,9 +93,17 @@ export const RouteCard:React.FC = (props) =>{ // backend.get('route/list').then((e)=>console.log(e.data)) backend.post('route/save', { points: props.rawProps.path - }) + }).then((e)=>console.log(e.data)) setLiked(!liked) } + + const onBuy = () =>{ + backend.post('route/save', { + points: props.rawProps.path + }).then((e)=>backend.get('buy/' + e.data.id + '/add_to_buy/')) + + navigate('/buyed') + } return(
= (props) =>{
setSelectedDay(e)} /> +
} diff --git a/src/elements/map/index.tsx b/src/elements/map/index.tsx index 5852437..00147ad 100644 --- a/src/elements/map/index.tsx +++ b/src/elements/map/index.tsx @@ -37,7 +37,7 @@ export const MyMap: React.FC = (props) =>{ useEffect(()=>{ setTimeout(()=> axios.get('https://api.mapbox.com/directions/v5/mapbox/walking/'+pathString+'?alternatives=true&continue_straight=true&geometries=geojson&language=en&overview=simplified&steps=true&access_token=pk.eyJ1IjoiZmlyZXNpZWh0IiwiYSI6ImNrdW9kemYzbTB4ZGkycHAxbXN2YnIzaGMifQ.G0fl-qVbecucfOvn8OtU4Q').then( (data:any) => setRoute(data.data.routes[0].geometry) - ), 1000) + ).catch((err)=>console.log('ERRRRRRRR')), 1000) }) diff --git a/src/pages/Buyed/index.tsx b/src/pages/Buyed/index.tsx new file mode 100644 index 0000000..3fbde18 --- /dev/null +++ b/src/pages/Buyed/index.tsx @@ -0,0 +1,88 @@ +import { Spin } from "antd"; +import React, { useEffect, useState } from "react"; +import { backend } from "../../consts"; +import { RusPassHeader } from "../../elements/Header"; +import { RouteCard } from "../../elements/RouteCard"; + +export const Buyed:React.FC = () =>{ + const [data, setData] = useState([]) + + useEffect(()=>{ + backend.get('/buy/').then((e)=>setData(e.data)) + }) + let newData; + + if (data.length != 0){ + newData = data.map((tour:any, index)=>{ + + let newPath = tour.points.map((path:any)=>{ + let newPaths = path.paths + for (let i = 0; i < newPaths.length; i++) { + if (newPaths[i].type == 'transition') { + newPaths.splice(i, 1); + i--; + } + } + + return { + date:path.date, + paths: newPaths + } + }) + + + return { + city: 'Тур №' + (index+1), + path: newPath + } + }) + } + + + + + + + + + + + return( +
+ + +

Ваши купленные туры

+ + { + data.length == 0 || newData == undefined? + + : +
+

Рекомендованные Туры

+ +
+ { + newData.map((tour:any, index:number)=> + + ) + } + +
+
+ } + + + Документация + +
+ + + + + +
+ +
© 2023 A project of the Government of Moscow
+
+ ); +} diff --git a/src/router.tsx b/src/router.tsx index 31d3d65..5b17026 100644 --- a/src/router.tsx +++ b/src/router.tsx @@ -11,6 +11,7 @@ import { SearchPage } from './pages/SearchPage'; import { Prefernces } from './elements/Prefernces'; import { Favorites } from './pages/Favorites'; import { Weather } from './pages/Weather'; +import { Buyed } from './pages/Buyed'; const routes = [ @@ -53,6 +54,10 @@ const routes = [ { path: '/route/:routeChangeId/change', element: + }, + { + path: '/buyed', + element: } ]