handlePositionClick({dispatch, positionId, isSelected, onSelect})}>
+
handlePositionClick({dispatch, positionId, isSelected, onSelect, history, role})}>
{header}
diff --git a/src/components/Select/TagSelect.js b/src/components/Select/TagSelect.js
index f1456bf7..3e0b4f6d 100644
--- a/src/components/Select/TagSelect.js
+++ b/src/components/Select/TagSelect.js
@@ -5,8 +5,12 @@ import { Loader } from '../Loader/Loader';
import style from './TagSelect.module.css';
import { selectedItems, selectItems, selectTags, filteredCandidates, setPositionId } from '../../redux/outstaffingSlice';
import { fetchItemsForId } from '../../server/server';
+import { useHistory } from 'react-router-dom';
+import { getRole } from '../../redux/roleSlice';
const TagSelect = () => {
+ const history = useHistory;
+ const role = useSelector(getRole);
const [searchLoading, setSearchLoading] = useState(false);
const dispatch = useDispatch();
@@ -20,7 +24,7 @@ const TagSelect = () => {
dispatch(setPositionId(null));
const filterItemsId = itemsArr.map((item) => item.id).join();
- fetchItemsForId(`${process.env.REACT_APP_API_URL}/api/profile?skills=`, filterItemsId).then((el) => {
+ fetchItemsForId({ link: `${process.env.REACT_APP_API_URL}/api/profile?skills=`, index: filterItemsId, history, role, }).then((el) => {
dispatch(filteredCandidates(el))
setSearchLoading(false)
});
diff --git a/src/components/Sidebar/Sidebar.module.css b/src/components/Sidebar/Sidebar.module.css
index e5b358dc..04efe60f 100644
--- a/src/components/Sidebar/Sidebar.module.css
+++ b/src/components/Sidebar/Sidebar.module.css
@@ -84,7 +84,6 @@
}
@media (max-width: 575.98px) {
- .candidateSidebar__info__btn,
.candidateSidebar__info__l,
.candidateSidebar__arrows {
display: none;
diff --git a/src/pages/FormPage.js b/src/pages/FormPage.js
index fa8446fb..5b51d11b 100644
--- a/src/pages/FormPage.js
+++ b/src/pages/FormPage.js
@@ -1,6 +1,6 @@
import React from 'react';
import { useDispatch, useSelector } from 'react-redux';
-import { useHistory, useParams, } from 'react-router-dom';
+import { useHistory, useParams, Link } from 'react-router-dom';
import { currentCandidate, selectCurrentCandidate } from '../redux/outstaffingSlice';
import SVG from 'react-inlinesvg';
import { WithLogout } from '../hoc/withLogout';
@@ -14,6 +14,7 @@ import rectangle from '../images/rectangle_secondPage.png';
import telegramIcon from '../images/telegram-icon.svg';
import './formPage.scss';
+import { getRole } from '../redux/roleSlice';
const goBack = (history) => {
history.goBack();
@@ -23,10 +24,11 @@ const FormPage = () => {
const params = useParams();
const history = useHistory();
const dispatch = useDispatch();
- const candidate = useSelector(selectCurrentCandidate)
+ const candidate = useSelector(selectCurrentCandidate);
+ const role = useSelector(getRole);
if(!candidate.id) {
- fetchItemsForId(`${process.env.REACT_APP_API_URL}/api/profile/`, Number(params.id)).then((el) =>
+ fetchItemsForId({ link: `${process.env.REACT_APP_API_URL}/api/profile/`, index: Number(params.id), history, role, }).then((el) =>
dispatch(currentCandidate(el))
);
}
@@ -67,7 +69,7 @@ const FormPage = () => {
Заявка на собеседование через телеграм
diff --git a/src/redux/roleSlice.js b/src/redux/roleSlice.js
new file mode 100644
index 00000000..e3354344
--- /dev/null
+++ b/src/redux/roleSlice.js
@@ -0,0 +1,21 @@
+import { createSlice } from '@reduxjs/toolkit';
+
+const initialState = {
+ role: null,
+};
+
+export const roleSlice = createSlice({
+ name: 'role',
+ initialState,
+ reducers: {
+ setRole: (state, action) => {
+ state.role = action.payload;
+ },
+ },
+});
+
+export const { setRole } = roleSlice.actions;
+
+export const getRole = (state) => state.role.role;
+
+export default roleSlice.reducer;
diff --git a/src/server/authRedirect.js b/src/server/authRedirect.js
index 36ad6c40..6b317427 100644
--- a/src/server/authRedirect.js
+++ b/src/server/authRedirect.js
@@ -1,11 +1,15 @@
-export const withAuthRedirect = actionCall => (link, index) => {
+export const withAuthRedirect = actionCall => ({link, index, history, role}) => {
return actionCall(link, index)
.then(res => {
if(res.status && res.status == 401) {
localStorage.clear();
+ history.push(role === 'ROLE_DEV' ? '/authdev' : '/auth')
}
return res;
})
- .catch(err => localStorage.clear())
+ .catch(err => {
+ localStorage.clear();
+ history.push(role === 'ROLE_DEV' ? '/authdev' : '/auth');
+ })
}
\ No newline at end of file
diff --git a/src/store/store.js b/src/store/store.js
index 84773a33..7de953b4 100644
--- a/src/store/store.js
+++ b/src/store/store.js
@@ -1,10 +1,12 @@
import { configureStore } from '@reduxjs/toolkit';
import outstaffingReducer from '../redux/outstaffingSlice';
import loaderReducer from '../redux/loaderSlice';
+import roleReducer from '../redux/roleSlice';
export const store = configureStore({
reducer: {
outstaffing: outstaffingReducer,
loader: loaderReducer,
+ role: roleReducer
},
});