refactoring
This commit is contained in:
29
src/App.js
29
src/App.js
@ -1,13 +1,12 @@
|
||||
import React, { Suspense, lazy, useEffect, useState } from 'react'
|
||||
import React from 'react'
|
||||
import { BrowserRouter as Router, Route, Switch } from 'react-router-dom'
|
||||
import { useSelector } from 'react-redux'
|
||||
import { selectAuth } from './redux/outstaffingSlice'
|
||||
// import { useSelector } from 'react-redux'
|
||||
// import { selectAuth } from './redux/outstaffingSlice'
|
||||
import 'bootstrap/dist/css/bootstrap.min.css'
|
||||
import './fonts/stylesheet.css'
|
||||
import { ProtectedRoute } from './components/ProtectedRoute/ProtectedRoute'
|
||||
|
||||
|
||||
import { YMInitializer } from 'react-yandex-metrika'
|
||||
// import { YMInitializer } from 'react-yandex-metrika'
|
||||
|
||||
import AuthPageForDevelopers from './pages/AuthPageForDevelopers'
|
||||
import AuthPageForPartners from './pages/AuthPageForPartners'
|
||||
@ -17,16 +16,16 @@ import CalendarPage from './pages/CalendarPage'
|
||||
import ReportPage from './pages/ReportFormPage.js'
|
||||
import FormPage from './pages/FormPage.js'
|
||||
import SingleReportPage from './pages/SingleReportPage'
|
||||
import { Highlighter } from './pages/CodeSnippetPage'
|
||||
// import { Highlighter } from './pages/CodeSnippetPage'
|
||||
import { QuizPage } from './pages/quiz/QuizPage'
|
||||
import { InterjacentPage } from './pages/quiz/InterjacentPage'
|
||||
import { QuizTestPage } from './pages/quiz/QuizTestPage'
|
||||
import { Instruction } from './components/features/quiz/Instructions'
|
||||
// import { Instruction } from './components/features/quiz/Instructions'
|
||||
import { InstructionPage } from './pages/quiz/InstructionPage'
|
||||
import {ResultPage} from "./pages/quiz/ResultPage";
|
||||
import { ResultPage } from './pages/quiz/ResultPage'
|
||||
|
||||
const App = (props) => {
|
||||
const isAuth = useSelector(selectAuth)
|
||||
// const isAuth = useSelector(selectAuth)
|
||||
return (
|
||||
<>
|
||||
<h1>IT Аутстаффинг в России</h1>
|
||||
@ -53,9 +52,15 @@ const App = (props) => {
|
||||
<ProtectedRoute exact path='/report' component={ReportPage} />
|
||||
<ProtectedRoute path='/report/:id' component={SingleReportPage} />
|
||||
<ProtectedRoute path='/quiz' component={QuizPage} />
|
||||
<ProtectedRoute path='/quiz-interjacent' component={InterjacentPage} />
|
||||
<ProtectedRoute
|
||||
path='/quiz-interjacent'
|
||||
component={InterjacentPage}
|
||||
/>
|
||||
<ProtectedRoute path='/quiz-test' component={QuizTestPage} />
|
||||
<ProtectedRoute path='/quiz-instruction' component={InstructionPage} />
|
||||
<ProtectedRoute
|
||||
path='/quiz-instruction'
|
||||
component={InstructionPage}
|
||||
/>
|
||||
<ProtectedRoute path='/quiz-result' component={ResultPage} />
|
||||
<ProtectedRoute component={() => <div>Page not found</div>} />
|
||||
</Switch>
|
||||
@ -76,5 +81,3 @@ const App = (props) => {
|
||||
}
|
||||
|
||||
export default App
|
||||
|
||||
|
||||
|
16
src/index.js
16
src/index.js
@ -1,16 +1,14 @@
|
||||
import React from 'react';
|
||||
import ReactDOM from 'react-dom';
|
||||
import { store } from './store/store';
|
||||
import { Provider } from 'react-redux';
|
||||
import App from './App';
|
||||
import React from 'react'
|
||||
import ReactDOM from 'react-dom'
|
||||
import { store } from './store/store'
|
||||
import { Provider } from 'react-redux'
|
||||
import App from './App'
|
||||
|
||||
import './index.css';
|
||||
import './index.css'
|
||||
|
||||
ReactDOM.render(
|
||||
<Provider store={store}>
|
||||
<>
|
||||
<App />
|
||||
</>
|
||||
</Provider>,
|
||||
document.getElementById('root')
|
||||
);
|
||||
)
|
||||
|
@ -6,7 +6,7 @@ export const withAuthRedirect =
|
||||
: link
|
||||
return actionCall(linkWithParams, body)
|
||||
.then((res) => {
|
||||
if (res.status && res.status == 401) {
|
||||
if (res.status && res.status === 401) {
|
||||
localStorage.clear()
|
||||
logout && logout()
|
||||
history.push(role === 'ROLE_DEV' ? '/authdev' : '/auth')
|
||||
|
@ -25,7 +25,6 @@ export const fetchAuth = async ({
|
||||
dispatch,
|
||||
catchError
|
||||
}) => {
|
||||
const baseURL = process.env.REACT_APP_BASE_URL
|
||||
const apiURL = process.env.REACT_APP_API_URL
|
||||
try {
|
||||
const response = await fetch(`${apiURL}/api/user/login`, {
|
||||
@ -33,7 +32,7 @@ export const fetchAuth = async ({
|
||||
mode: 'cors',
|
||||
headers: {
|
||||
'Access-Control-Request-Headers': 'authorization',
|
||||
'Content-Type': 'application/json',
|
||||
'Content-Type': 'application/json'
|
||||
// Origin: `http://localhost`
|
||||
},
|
||||
body: JSON.stringify({
|
||||
@ -98,7 +97,7 @@ export const fetchGet = withAuthRedirect(async (link) => {
|
||||
})
|
||||
|
||||
export const fetchPost = withAuthRedirect(async (link, body) => {
|
||||
console.log('i',body)
|
||||
console.log('i', body)
|
||||
try {
|
||||
const response = await fetch(link, {
|
||||
method: 'POST',
|
||||
@ -106,7 +105,7 @@ export const fetchPost = withAuthRedirect(async (link, body) => {
|
||||
Authorization: `Bearer ${localStorage.getItem('auth_token')}`,
|
||||
'Content-Type': 'application/json',
|
||||
//Origin: `http://localhost:3000`
|
||||
Origin: `${process.env.REACT_APP_BASE_URL}`,
|
||||
Origin: `${process.env.REACT_APP_BASE_URL}`
|
||||
},
|
||||
body: JSON.stringify(body)
|
||||
})
|
||||
|
Reference in New Issue
Block a user