mirror of
				https://github.com/task-17-lct/frontend.git
				synced 2025-11-04 14:27:26 +03:00 
			
		
		
		
	fich
This commit is contained in:
		
							parent
							
								
									6b07040476
								
							
						
					
					
						commit
						f4aa746dc9
					
				
							
								
								
									
										3
									
								
								.vscode/settings.json
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										3
									
								
								.vscode/settings.json
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,3 @@
 | 
			
		|||
{
 | 
			
		||||
    "liveServer.settings.port": 5501
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										14
									
								
								package.json
									
									
									
									
									
								
							
							
						
						
									
										14
									
								
								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" 
 | 
			
		||||
  ]
 | 
			
		||||
}
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1 +1 @@
 | 
			
		|||
export const origin = 'https://dev2.akarpov.ru/'
 | 
			
		||||
export const origin = 'https://0e06-92-100-146-65.ngrok-free.app/'
 | 
			
		||||
| 
						 | 
				
			
			@ -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')}
 | 
			
		||||
  }
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
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')}
 | 
			
		||||
    }
 | 
			
		||||
  )
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -25,6 +25,7 @@ export const Login: react.FC = () => {
 | 
			
		|||
            <Input placeholder='Пароль' className='reg-input' onChange={setPassword}/>
 | 
			
		||||
            <Button className='' onClick={() => {
 | 
			
		||||
                    signin(username, password).then((e) => {
 | 
			
		||||
                        console.log(e)
 | 
			
		||||
                        localStorage.setItem('token', e.access);
 | 
			
		||||
                        localStorage.setItem('firstAuth', 'true');
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -36,9 +37,9 @@ export const Login: react.FC = () => {
 | 
			
		|||
                <span>или</span>
 | 
			
		||||
                <div className="sep-item"></div>
 | 
			
		||||
            </div>
 | 
			
		||||
            <YandexLogin clientID={clientID} onSuccess={() => {}}>
 | 
			
		||||
                <button className="btn-y">Yandex login</button>
 | 
			
		||||
            </YandexLogin>
 | 
			
		||||
            <Button className='login-btn-y' onClick={()=>navigate('/register')}>Зарегистрироваться</Button>
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        </Block>
 | 
			
		||||
    </div>
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -20,8 +20,7 @@
 | 
			
		|||
    width: 400px;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
.btn-y{
 | 
			
		||||
    width: 440px!important;
 | 
			
		||||
.login-btn-y{
 | 
			
		||||
    background-color: #FFCF08;
 | 
			
		||||
    border-radius: 10px;
 | 
			
		||||
    padding: 15px 50px;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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')
 | 
			
		||||
      }
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -38,9 +38,8 @@ export const Register: react.FC = () => {
 | 
			
		|||
                <span>или</span>
 | 
			
		||||
                <div className="sep-item"></div>
 | 
			
		||||
            </div>
 | 
			
		||||
            <YandexLogin clientID={clientID} onSuccess={() => {}}>
 | 
			
		||||
                <button className="btn-y">Yandex login</button>
 | 
			
		||||
            </YandexLogin>
 | 
			
		||||
            <Button className='login-btn-y' onClick={()=>navigate('/login')}>Войти</Button>
 | 
			
		||||
 | 
			
		||||
        </Block>
 | 
			
		||||
    </div>
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -20,8 +20,7 @@
 | 
			
		|||
    width: 400px;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
.btn-y{
 | 
			
		||||
    width: 440px!important;
 | 
			
		||||
.login-btn-y{
 | 
			
		||||
    background-color: #FFCF08;
 | 
			
		||||
    border-radius: 10px;
 | 
			
		||||
    padding: 15px 50px;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue
	
	Block a user