diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..6f3a291 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "liveServer.settings.port": 5501 +} \ No newline at end of file diff --git a/package.json b/package.json index 39bd0c7..16c67af 100644 --- a/package.json +++ b/package.json @@ -48,16 +48,8 @@ "react-app/jest" ] }, - "browserslist": { - "production": [ - ">0.2%", - "not dead", - "not op_mini all" - ], - "development": [ - "last 1 chrome version", - "last 1 firefox version", - "last 1 safari version" - ] - } + "browserslist": [ + "defaults", + "not ie 11" + ] } diff --git a/src/client/config.ts b/src/client/config.ts index 7964b79..cf36c66 100644 --- a/src/client/config.ts +++ b/src/client/config.ts @@ -1 +1 @@ -export const origin = 'https://dev2.akarpov.ru/' \ No newline at end of file +export const origin = 'https://0e06-92-100-146-65.ngrok-free.app/' \ No newline at end of file diff --git a/src/consts.tsx b/src/consts.tsx index a6ca788..5fdea72 100644 --- a/src/consts.tsx +++ b/src/consts.tsx @@ -7,9 +7,18 @@ import axios from "axios"; // }); -export const backend = axios.create({ +export let backend = axios.create({ baseURL: 'https://0e06-92-100-146-65.ngrok-free.app/api/', timeout: 100000, headers: {'Authorization': 'Bearer ' + localStorage.getItem('token')} } -) \ No newline at end of file +) + +export const updateBackend = () =>{ + backend = axios.create({ + baseURL: 'https://0e06-92-100-146-65.ngrok-free.app/api/', + timeout: 100000, + headers: {'Authorization': 'Bearer ' + localStorage.getItem('token')} + } + ) +} \ No newline at end of file diff --git a/src/pages/Login/index.tsx b/src/pages/Login/index.tsx index e5d9a95..f125745 100644 --- a/src/pages/Login/index.tsx +++ b/src/pages/Login/index.tsx @@ -25,6 +25,7 @@ export const Login: react.FC = () => { - + + + } \ No newline at end of file diff --git a/src/pages/Login/style.css b/src/pages/Login/style.css index 2bf7a67..2cc26ad 100644 --- a/src/pages/Login/style.css +++ b/src/pages/Login/style.css @@ -20,8 +20,7 @@ width: 400px; } -.btn-y{ - width: 440px!important; +.login-btn-y{ background-color: #FFCF08; border-radius: 10px; padding: 15px 50px; diff --git a/src/pages/Main/index.tsx b/src/pages/Main/index.tsx index 17a2f01..2bd166a 100644 --- a/src/pages/Main/index.tsx +++ b/src/pages/Main/index.tsx @@ -1,7 +1,7 @@ import { AutoComplete, DatePicker, Input, Checkbox, Select, Radio, Space, Spin } from 'antd'; import react, { useEffect, useState } from 'react' import { useNavigate } from 'react-router-dom'; -import { backend } from '../../consts'; +import { backend, updateBackend } from '../../consts'; import { Button } from '../../elements/Button'; import { FavoriteCard, FavoriteCardIE } from '../../elements/FavoriteCard'; import { GenerateCard } from '../../elements/GenerateCard'; @@ -21,10 +21,10 @@ export const Main: react.FC = () => { let navigate = useNavigate() let token = localStorage.getItem('token') - let firstAuth = localStorage.getItem('firstAuth') - + console.log(token) useEffect(()=>{ + updateBackend() if (null == localStorage.getItem('token')){ navigate('/login') } diff --git a/src/pages/Register/index.tsx b/src/pages/Register/index.tsx index c91ac33..12835cc 100644 --- a/src/pages/Register/index.tsx +++ b/src/pages/Register/index.tsx @@ -38,9 +38,8 @@ export const Register: react.FC = () => { или
- {}}> - - + + } \ No newline at end of file diff --git a/src/pages/Register/style.css b/src/pages/Register/style.css index 2bf7a67..2cc26ad 100644 --- a/src/pages/Register/style.css +++ b/src/pages/Register/style.css @@ -20,8 +20,7 @@ width: 400px; } -.btn-y{ - width: 440px!important; +.login-btn-y{ background-color: #FFCF08; border-radius: 10px; padding: 15px 50px; diff --git a/src/pages/SearchPage/index.tsx b/src/pages/SearchPage/index.tsx index 4270216..78c449f 100644 --- a/src/pages/SearchPage/index.tsx +++ b/src/pages/SearchPage/index.tsx @@ -1,4 +1,4 @@ -import React, { useEffect, useState } from "react"; +import React, { useEffect, useRef, useState } from "react"; import { useParams } from "react-router-dom"; import { backend } from "../../consts"; import { RouteCard, RouteCardIE } from "../../elements/RouteCard"; @@ -15,14 +15,26 @@ export const SearchPage:React.FC = () =>{ const [data, setData] = useState([]) const [events, setEvents] = useState([]) + const queried = useRef(false); useEffect(()=>{ - if (cities.length == 0){ - backend.get('/data/cities').then((response)=>setCities(response.data)) - backend.post('/route/build',JSON.parse(prefs as string)).then((r)=>setData(r.data as any)) - backend.post('/recommendations/build_events/',JSON.parse(prefs as string)).then((r)=>setEvents(r.data as any)) - } - }) + const dataLoad = async (prefs: string) => { + const cities = await backend.get('/data/cities') + const routes = await backend.post('/route/build',JSON.parse(prefs as string)) + const events = await backend.post('/recommendations/build_events/',JSON.parse(prefs as string)) + return { + cities, routes, events + } + } + if (!queried.current) { + queried.current = true; + dataLoad(prefs as string).then((data) => { + setCities(data.cities.data as any); + setData(data.routes.data as any); + setEvents(data.events.data as any); + }) + } + }, [prefs]) console.log(events) let newData; diff --git a/src/router.tsx b/src/router.tsx index 950efbf..73a5ff3 100644 --- a/src/router.tsx +++ b/src/router.tsx @@ -1,5 +1,5 @@ import { - createBrowserRouter + createBrowserRouter, createHashRouter } from 'react-router-dom' import App from './App' import { Register } from './pages/Register'; @@ -7,8 +7,8 @@ import { Login } from './pages/Login'; import { Main } from './pages/Main'; import { EventMatch } from './pages/EventMatch'; import { GenerateTour } from './pages/GenerateTour'; -import { Prefernces } from './elements/Prefernces'; import { SearchPage } from './pages/SearchPage'; +import { Prefernces } from './elements/Prefernces'; const routes = [ @@ -47,4 +47,4 @@ const routes = [ ] -export const router = createBrowserRouter(routes); +export const router = createHashRouter(routes);