diff --git a/package-lock.json b/package-lock.json index 3b4d2ac1..26b95c25 100644 --- a/package-lock.json +++ b/package-lock.json @@ -3216,6 +3216,14 @@ "resolved": "https://registry.npmjs.org/axe-core/-/axe-core-4.2.1.tgz", "integrity": "sha512-evY7DN8qSIbsW2H/TWQ1bX3sXN1d4MNb5Vb4n7BzPuCwRHdkZ1H2eNLuSh73EoQqkGKUtju2G2HCcjCfhvZIAA==" }, + "axios": { + "version": "0.21.1", + "resolved": "https://registry.npmjs.org/axios/-/axios-0.21.1.tgz", + "integrity": "sha512-dKQiRHxGD9PPRIUNIWvZhPTPpl1rf/OxTYKsqKUDjBwYylTvV7SjSHJb9ratfyzM6wCdLCOYLzs73qpg5c4iGA==", + "requires": { + "follow-redirects": "^1.10.0" + } + }, "axobject-query": { "version": "2.2.0", "resolved": "https://registry.npmjs.org/axobject-query/-/axobject-query-2.2.0.tgz", diff --git a/package.json b/package.json index 8abc5d7a..8ead7592 100644 --- a/package.json +++ b/package.json @@ -7,6 +7,7 @@ "@testing-library/jest-dom": "^5.12.0", "@testing-library/react": "^11.2.7", "@testing-library/user-event": "^12.8.3", + "axios": "^0.21.1", "bootstrap": "^4.6.0", "dotenv": "^10.0.0", "eslint": "^7.27.0", diff --git a/src/App.js b/src/App.js index 0c071871..b01e7b69 100644 --- a/src/App.js +++ b/src/App.js @@ -16,18 +16,18 @@ const App = () => { return ( - - {/* */} + + + + - -
Page not found
-
+
Page not found
} />
) diff --git a/src/api/index.js b/src/api/index.js new file mode 100644 index 00000000..9f6886d7 --- /dev/null +++ b/src/api/index.js @@ -0,0 +1,5 @@ +import axios from 'axios'; + +export default axios.create({ + baseURL: process.env.REACT_APP_API_URL +}); \ No newline at end of file diff --git a/src/components/Auth/AuthForDevelopers.js b/src/components/Auth/AuthForDevelopers.js index 908ca6be..a578dfd7 100644 --- a/src/components/Auth/AuthForDevelopers.js +++ b/src/components/Auth/AuthForDevelopers.js @@ -16,7 +16,7 @@ import { fetchAuth } from '../../server/server' import { useSelector } from 'react-redux' import { selectAuth } from '../../redux/outstaffingSlice'; -import { Redirect } from 'react-router-dom'; +import { Redirect, Link } from 'react-router-dom'; const AuthForDevelopers = () => { const dispatch = useDispatch() @@ -25,8 +25,6 @@ const AuthForDevelopers = () => { const [username, setUsername] = useState('') const [password, setPassword] = useState('') - console.log('i', isAuth) - if(isAuth) { return } @@ -79,6 +77,10 @@ const AuthForDevelopers = () => { > Войти + + diff --git a/src/components/Auth/AuthForDevelopers.module.css b/src/components/Auth/AuthForDevelopers.module.css index 63d34e32..f55c227c 100644 --- a/src/components/Auth/AuthForDevelopers.module.css +++ b/src/components/Auth/AuthForDevelopers.module.css @@ -399,3 +399,16 @@ line-height: normal; margin-left: 24px; } + +.auth__link { + display: block; + margin-top: 1.3rem; +} + + +.auth__link a { + display: block; + width: 100%; + height: 100%; + color: #fff; +} \ No newline at end of file diff --git a/src/components/Auth/AuthForPartners.js b/src/components/Auth/AuthForPartners.js index 4b79d1dc..dfab8a54 100644 --- a/src/components/Auth/AuthForPartners.js +++ b/src/components/Auth/AuthForPartners.js @@ -1,4 +1,4 @@ -import React from 'react'; +import React, { useState } from 'react'; import { useDispatch } from 'react-redux'; import { auth } from '../../redux/outstaffingSlice'; import style from './AuthForPartners.module.css'; @@ -12,9 +12,22 @@ import phone from '../../images/phone.png'; import telegram from '../../images/telegram.png'; import vector from '../../images/Vector_Smart_Object.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, Link } from 'react-router-dom'; const AuthForPartners = () => { - const dispatch = useDispatch(); + const dispatch = useDispatch() + const isAuth = useSelector(selectAuth) + + const [username, setUsername] = useState('') + const [password, setPassword] = useState('') + + if(isAuth) { + return + } return (
@@ -34,14 +47,33 @@ const AuthForPartners = () => {
- + setUsername(e.target.value)} + /> - + setPassword(e.target.value)} + /> - + +
diff --git a/src/components/Auth/AuthForPartners.module.css b/src/components/Auth/AuthForPartners.module.css index f7cb98fb..db43afbe 100644 --- a/src/components/Auth/AuthForPartners.module.css +++ b/src/components/Auth/AuthForPartners.module.css @@ -400,3 +400,15 @@ line-height: normal; margin-left: 24px; } + +.auth__link { + display: block; + margin-top: 1.3rem; +} + +.auth__link a { + display: block; + width: 100%; + height: 100%; + color: #fff; +} \ No newline at end of file diff --git a/src/components/Candidate/Candidate.js b/src/components/Candidate/Candidate.js index 8e8eee7c..9a9f4586 100644 --- a/src/components/Candidate/Candidate.js +++ b/src/components/Candidate/Candidate.js @@ -18,7 +18,7 @@ const Candidate = () => { const dispatch = useDispatch(); useEffect(() => { - fetchItemsForId('https://guild.craft-group.xyz/api/profile/', Number(candidateId)).then((el) => + fetchItemsForId(`${process.env.REACT_APP_API_URL}/api/profile/`, Number(candidateId)).then((el) => dispatch(currentCandidate(el)) ); }, [dispatch, candidateId]); diff --git a/src/components/Description/Description.js b/src/components/Description/Description.js index c956db78..2c77c38b 100644 --- a/src/components/Description/Description.js +++ b/src/components/Description/Description.js @@ -14,7 +14,7 @@ const Description = ({ onLoadMore }) => { const [allCandidates, getAllCandidates] = useState([]); useEffect(() => { - fetchProfile('https://guild.craft-group.xyz/api/profile?limit=', 1000).then((p) => getAllCandidates(p)); + fetchProfile(`${process.env.REACT_APP_API_URL}/api/profile?limit=`, 1000).then((p) => getAllCandidates(p)); }, []); return ( diff --git a/src/components/Form/Form.js b/src/components/Form/Form.js index e3cd7787..10765bc0 100644 --- a/src/components/Form/Form.js +++ b/src/components/Form/Form.js @@ -30,7 +30,7 @@ const Form = () => { formData.append('phone', data.phone); formData.append('comment', data.comment); - fetchForm('https://guild.craft-group.xyz/api/profile/add-to-interview', formData); + fetchForm(`${process.env.REACT_APP_API_URL}/api/profile/add-to-interview`, formData); }; const goBack = () => { diff --git a/src/components/Home/Home.js b/src/components/Home/Home.js index 52d1f491..84f7c31d 100644 --- a/src/components/Home/Home.js +++ b/src/components/Home/Home.js @@ -11,11 +11,11 @@ const Home = () => { const dispatch = useDispatch(); useEffect(() => { - fetchProfile('https://guild.craft-group.xyz/api/profile?limit=', index).then((profileArr) => + fetchProfile(`${process.env.REACT_APP_API_URL}/api/profile?limit=`, index).then((profileArr) => dispatch(profiles(profileArr)) ); - fetchSkills('https://guild.craft-group.xyz/api/skills/skills-on-main-page').then((skills) => { + fetchSkills(`${process.env.REACT_APP_API_URL}/api/skills/skills-on-main-page`).then((skills) => { const keys = Object.keys(skills); const values = Object.values(skills); diff --git a/src/components/Outstaffing/Outstaffing.js b/src/components/Outstaffing/Outstaffing.js index 2c1916d7..47dd8e74 100644 --- a/src/components/Outstaffing/Outstaffing.js +++ b/src/components/Outstaffing/Outstaffing.js @@ -28,7 +28,7 @@ const Outstaffing = () => {
tag.name === 'skills_front')} + dataTags={tagsArr && tagsArr.flat().filter((tag) => tag.name === 'skills_front')} img={front} header="Фронтенд" /> diff --git a/src/components/Select/TagSelect.js b/src/components/Select/TagSelect.js index 85fd2a94..a78075b4 100644 --- a/src/components/Select/TagSelect.js +++ b/src/components/Select/TagSelect.js @@ -15,7 +15,7 @@ const TagSelect = () => { const handleSubmit = () => { const filterItemsId = itemsArr.map((item) => item.id).join(); - fetchItemsForId(`https://guild.craft-group.xyz/api/profile?skills=`, filterItemsId).then((el) => + fetchItemsForId(`${process.env.REACT_APP_API_URL}/api/profile?skills=`, filterItemsId).then((el) => dispatch(filteredCandidates(el)) ); diff --git a/src/server/server.js b/src/server/server.js index 05f019ef..8effa413 100644 --- a/src/server/server.js +++ b/src/server/server.js @@ -2,7 +2,9 @@ export const fetchProfile = async (link, index) => { try { const response = await fetch(`${link}${index}`, { headers: { - 'Authorization': `Bearer ${localStorage.getItem('auth_token')}` + 'Access-Control-Request-Headers': 'authorization', + 'Authorization': `Bearer ${localStorage.getItem('auth_token')}`, + 'Origin': `${process.env.REACT_APP_BASE_URL}`, } }) let data = await response.json() @@ -15,7 +17,9 @@ export const fetchSkills = async (link) => { try { const response = await fetch(link, { headers: { - 'Authorization': `Bearer ${localStorage.getItem('auth_token')}` + 'Access-Control-Request-Headers': 'authorization', + 'Authorization': `Bearer ${localStorage.getItem('auth_token')}`, + 'Origin': `${process.env.REACT_APP_BASE_URL}`, } }) let data = await response.json() @@ -25,10 +29,13 @@ export const fetchSkills = async (link) => { } export const fetchItemsForId = async (link, id) => { + console.log(`Bearer ${localStorage.getItem('auth_token')}`); try { const response = await fetch(`${link}${id}`, { headers: { - 'Authorization': `Bearer ${localStorage.getItem('auth_token')}` + // 'Access-Control-Request-Headers': 'authorization', + 'Authorization': `Bearer ${localStorage.getItem('auth_token')}`, + 'Origin': `${process.env.REACT_APP_BASE_URL}`, } }) let data = await response.json() @@ -42,7 +49,9 @@ export const fetchForm = async (link, info) => { const response = await fetch(link, { method: 'POST', headers: { + 'Access-Control-Request-Headers': 'authorization', 'Authorization': `Bearer ${localStorage.getItem('auth_token')}`, + 'Origin': `${process.env.REACT_APP_BASE_URL}`, 'Content-Type': 'multipart/form-data' }, body: info