redirect buttons and api url fixes

This commit is contained in:
kurpfish 2021-08-05 16:44:49 +03:00
parent 9a55d65db1
commit ffd679a0a9
14 changed files with 61 additions and 9 deletions

8
package-lock.json generated
View File

@ -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",

View File

@ -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",

5
src/api/index.js Normal file
View File

@ -0,0 +1,5 @@
import axios from 'axios';
export default axios.create({
baseURL: process.env.REACT_APP_API_URL
});

View File

@ -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()
@ -77,6 +77,10 @@ const AuthForDevelopers = () => {
>
Войти
</button>
<button className={`${style.form__btn} ${style.auth__link}`}>
<Link to='/auth'>Для партнёров</Link>
</button>
</form>
</div>
</div>

View File

@ -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;
}

View File

@ -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 AuthForPartners = () => {
const dispatch = useDispatch()
@ -70,6 +70,10 @@ const AuthForPartners = () => {
}>
Войти
</button>
<button className={`${style.form__btn} ${style.auth__link}`}>
<Link to='/authdev'>Для разработчиков</Link>
</button>
</form>
</div>
</div>

View File

@ -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;
}

View File

@ -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]);

View File

@ -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 (

View File

@ -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 = () => {

View File

@ -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);

View File

@ -28,7 +28,7 @@ const Outstaffing = () => {
<div className="row">
<div className="col-12 col-xl-4">
<OutstaffingBlock
dataTags={tagsArr.flat().filter((tag) => tag.name === 'skills_front')}
dataTags={tagsArr && tagsArr.flat().filter((tag) => tag.name === 'skills_front')}
img={front}
header="Фронтенд"
/>

View File

@ -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))
);

View File

@ -2,6 +2,7 @@ export const fetchProfile = async (link, index) => {
try {
const response = await fetch(`${link}${index}`, {
headers: {
'Access-Control-Request-Headers': 'authorization',
'Authorization': `Bearer ${localStorage.getItem('auth_token')}`,
'Origin': `${process.env.REACT_APP_BASE_URL}`,
}
@ -16,6 +17,7 @@ export const fetchSkills = async (link) => {
try {
const response = await fetch(link, {
headers: {
'Access-Control-Request-Headers': 'authorization',
'Authorization': `Bearer ${localStorage.getItem('auth_token')}`,
'Origin': `${process.env.REACT_APP_BASE_URL}`,
}
@ -27,9 +29,11 @@ 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: {
// 'Access-Control-Request-Headers': 'authorization',
'Authorization': `Bearer ${localStorage.getItem('auth_token')}`,
'Origin': `${process.env.REACT_APP_BASE_URL}`,
}
@ -45,6 +49,7 @@ 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'