auth for partners
This commit is contained in:
parent
937a78b04f
commit
9a55d65db1
10
src/App.js
10
src/App.js
@ -16,18 +16,18 @@ const App = () => {
|
|||||||
return (
|
return (
|
||||||
<Router>
|
<Router>
|
||||||
<Switch>
|
<Switch>
|
||||||
<Route path='/auth' exact>
|
<Route path='/authdev' exact>
|
||||||
{/* <AuthPageForPartners /> */}
|
|
||||||
<AuthPageForDevelopers />
|
<AuthPageForDevelopers />
|
||||||
</Route>
|
</Route>
|
||||||
|
<Route path='/auth' exact>
|
||||||
|
<AuthPageForPartners />
|
||||||
|
</Route>
|
||||||
<ProtectedRoute path='/' exact component={HomePage} />
|
<ProtectedRoute path='/' exact component={HomePage} />
|
||||||
<ProtectedRoute path='/candidate/:id' component={CandidatePage} />
|
<ProtectedRoute path='/candidate/:id' component={CandidatePage} />
|
||||||
<ProtectedRoute path='/calendar' component={CalendarPage} />
|
<ProtectedRoute path='/calendar' component={CalendarPage} />
|
||||||
<ProtectedRoute path='/form' component={FormPage} />
|
<ProtectedRoute path='/form' component={FormPage} />
|
||||||
<ProtectedRoute path='/report' component={ReportPage} />
|
<ProtectedRoute path='/report' component={ReportPage} />
|
||||||
<Route>
|
<ProtectedRoute component={()=><div>Page not found</div>} />
|
||||||
<div>Page not found</div>
|
|
||||||
</Route>
|
|
||||||
</Switch>
|
</Switch>
|
||||||
</Router>
|
</Router>
|
||||||
)
|
)
|
||||||
|
@ -25,8 +25,6 @@ const AuthForDevelopers = () => {
|
|||||||
const [username, setUsername] = useState('')
|
const [username, setUsername] = useState('')
|
||||||
const [password, setPassword] = useState('')
|
const [password, setPassword] = useState('')
|
||||||
|
|
||||||
console.log('i', isAuth)
|
|
||||||
|
|
||||||
if(isAuth) {
|
if(isAuth) {
|
||||||
return <Redirect to='/' />
|
return <Redirect to='/' />
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import React from 'react';
|
import React, { useState } from 'react';
|
||||||
import { useDispatch } from 'react-redux';
|
import { useDispatch } from 'react-redux';
|
||||||
import { auth } from '../../redux/outstaffingSlice';
|
import { auth } from '../../redux/outstaffingSlice';
|
||||||
import style from './AuthForPartners.module.css';
|
import style from './AuthForPartners.module.css';
|
||||||
@ -12,9 +12,22 @@ import phone from '../../images/phone.png';
|
|||||||
import telegram from '../../images/telegram.png';
|
import telegram from '../../images/telegram.png';
|
||||||
import vector from '../../images/Vector_Smart_Object.png';
|
import vector from '../../images/Vector_Smart_Object.png';
|
||||||
import vectorBlack from '../../images/Vector_Smart_Object_black.png';
|
import vectorBlack from '../../images/Vector_Smart_Object_black.png';
|
||||||
|
import { fetchAuth } from '../../server/server'
|
||||||
|
|
||||||
|
import { useSelector } from 'react-redux'
|
||||||
|
import { selectAuth } from '../../redux/outstaffingSlice';
|
||||||
|
import { Redirect } from 'react-router-dom';
|
||||||
|
|
||||||
const AuthForPartners = () => {
|
const AuthForPartners = () => {
|
||||||
const dispatch = useDispatch();
|
const dispatch = useDispatch()
|
||||||
|
const isAuth = useSelector(selectAuth)
|
||||||
|
|
||||||
|
const [username, setUsername] = useState('')
|
||||||
|
const [password, setPassword] = useState('')
|
||||||
|
|
||||||
|
if(isAuth) {
|
||||||
|
return <Redirect to='/' />
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<section className={style.partners}>
|
<section className={style.partners}>
|
||||||
@ -34,12 +47,27 @@ const AuthForPartners = () => {
|
|||||||
</div>
|
</div>
|
||||||
<form className={style.partners__form}>
|
<form className={style.partners__form}>
|
||||||
<label htmlFor="login">Ваш логин:</label>
|
<label htmlFor="login">Ваш логин:</label>
|
||||||
<input id="login" type="text" placeholder="Логин" />
|
<input id="login" type="text" placeholder="Логин"
|
||||||
|
value={username}
|
||||||
|
onChange={(e) => setUsername(e.target.value)}
|
||||||
|
/>
|
||||||
|
|
||||||
<label htmlFor="password">Пароль:</label>
|
<label htmlFor="password">Пароль:</label>
|
||||||
<input id="password" type="password" placeholder="Пароль" />
|
<input id="password" type="password" placeholder="Пароль"
|
||||||
|
value={password}
|
||||||
|
onChange={(e) => setPassword(e.target.value)}
|
||||||
|
/>
|
||||||
|
|
||||||
<button className={style.form__btn} type="submit" onClick={() => dispatch(auth(true))}>
|
<button className={style.form__btn}
|
||||||
|
onClick={(e) => {
|
||||||
|
e.preventDefault();
|
||||||
|
fetchAuth({
|
||||||
|
username,
|
||||||
|
password,
|
||||||
|
dispatch: ()=> dispatch(auth(true))
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}>
|
||||||
Войти
|
Войти
|
||||||
</button>
|
</button>
|
||||||
</form>
|
</form>
|
||||||
|
@ -3,7 +3,7 @@ export const fetchProfile = async (link, index) => {
|
|||||||
const response = await fetch(`${link}${index}`, {
|
const response = await fetch(`${link}${index}`, {
|
||||||
headers: {
|
headers: {
|
||||||
'Authorization': `Bearer ${localStorage.getItem('auth_token')}`,
|
'Authorization': `Bearer ${localStorage.getItem('auth_token')}`,
|
||||||
'Origin': `${baseURL}`,
|
'Origin': `${process.env.REACT_APP_BASE_URL}`,
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
let data = await response.json()
|
let data = await response.json()
|
||||||
@ -17,7 +17,7 @@ export const fetchSkills = async (link) => {
|
|||||||
const response = await fetch(link, {
|
const response = await fetch(link, {
|
||||||
headers: {
|
headers: {
|
||||||
'Authorization': `Bearer ${localStorage.getItem('auth_token')}`,
|
'Authorization': `Bearer ${localStorage.getItem('auth_token')}`,
|
||||||
'Origin': `${baseURL}`,
|
'Origin': `${process.env.REACT_APP_BASE_URL}`,
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
let data = await response.json()
|
let data = await response.json()
|
||||||
@ -31,7 +31,7 @@ export const fetchItemsForId = async (link, id) => {
|
|||||||
const response = await fetch(`${link}${id}`, {
|
const response = await fetch(`${link}${id}`, {
|
||||||
headers: {
|
headers: {
|
||||||
'Authorization': `Bearer ${localStorage.getItem('auth_token')}`,
|
'Authorization': `Bearer ${localStorage.getItem('auth_token')}`,
|
||||||
'Origin': `${baseURL}`,
|
'Origin': `${process.env.REACT_APP_BASE_URL}`,
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
let data = await response.json()
|
let data = await response.json()
|
||||||
@ -46,7 +46,7 @@ export const fetchForm = async (link, info) => {
|
|||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {
|
headers: {
|
||||||
'Authorization': `Bearer ${localStorage.getItem('auth_token')}`,
|
'Authorization': `Bearer ${localStorage.getItem('auth_token')}`,
|
||||||
'Origin': `${baseURL}`,
|
'Origin': `${process.env.REACT_APP_BASE_URL}`,
|
||||||
'Content-Type': 'multipart/form-data'
|
'Content-Type': 'multipart/form-data'
|
||||||
},
|
},
|
||||||
body: info
|
body: info
|
||||||
|
Loading…
Reference in New Issue
Block a user