From 596c54b0027ac6570f71036993e480c3e8040e18 Mon Sep 17 00:00:00 2001 From: kurpfish Date: Mon, 9 Aug 2021 18:40:06 +0300 Subject: [PATCH] sort fixes --- src/components/Description/Description.js | 103 ++++++++++++---------- src/redux/outstaffingSlice.js | 2 +- 2 files changed, 58 insertions(+), 47 deletions(-) diff --git a/src/components/Description/Description.js b/src/components/Description/Description.js index 17e298b7..313fa3b6 100644 --- a/src/components/Description/Description.js +++ b/src/components/Description/Description.js @@ -4,12 +4,13 @@ import male from '../../images/medium_male.png'; import rectangle from '../../images/rectangle_secondPage.png'; import { Link } from 'react-router-dom'; import { LEVELS, SKILLS } from '../constants/constants'; -import { selectProfiles, selectFilteredCandidates } from '../../redux/outstaffingSlice'; +import { selectProfiles, selectFilteredCandidates, selectItems } from '../../redux/outstaffingSlice'; import { useSelector } from 'react-redux'; import { fetchProfile } from '../../server/server'; const Description = ({ onLoadMore }) => { const candidatesListArr = useSelector(selectProfiles); + const itemsArr = useSelector(selectItems); const filteredListArr = useSelector(selectFilteredCandidates); const [allCandidates, getAllCandidates] = useState([]); @@ -17,60 +18,69 @@ const Description = ({ onLoadMore }) => { fetchProfile(`${process.env.REACT_APP_API_URL}/api/profile?limit=`, 1000).then((p) => getAllCandidates(p)); }, []); + console.log('render',filteredListArr, itemsArr) + + if(!filteredListArr) { + return ( +
+
+
+ { + candidatesListArr.map((el) => ( +
+
+ +
+
+

+ {SKILLS[el.position_id]}, {LEVELS[el.level]} +

+ + {el.vc_text_short ? ( +
{el.vc_text_short}
+ ) : ( +

Описание отсутствует...

+ )} +
+
+ + + +
+
+
+
    + {el.skillValues.map((e) => ( +
  • + {e.skill.name} +
  • + ))} +
+ +
+
+
+ ))} +
+ +
+
+ ); + } + return (
{filteredListArr - ? (filteredListArr.length > 0 - ? <> - : filteredListArr.map((el) => ( -
-
- -
-
-

- - {SKILLS[el.position_id]}, {LEVELS[el.level]} - -

- - {el.vc_text_short ? ( -
{el.vc_text_short}
- ) : ( -

Описание отсутствует...

- )} -
-
- - - -
-
-
-
    - {el.skillValues.map((e) => ( -
  • - {e.skill.name} -
  • - ))} -
- -
-
-
- ))) - : candidatesListArr.map((el) => ( + ? filteredListArr.map((el) => (

- - {SKILLS[el.position_id]}, {LEVELS[el.level]} - + {SKILLS[el.position_id]}, {LEVELS[el.level]}

{el.vc_text_short ? ( @@ -97,14 +107,15 @@ const Description = ({ onLoadMore }) => {
- ))} + )) + : filteredListArr.length && filteredListArr.length === 0 && <> }
- {candidatesListArr.length !== allCandidates.length && filteredListArr.length === 0 ? ( + {(candidatesListArr.length !== allCandidates.length && filteredListArr.length > 0) || filteredListArr===null ? ( ) : null}
diff --git a/src/redux/outstaffingSlice.js b/src/redux/outstaffingSlice.js index a2e893f9..44f9fdaf 100644 --- a/src/redux/outstaffingSlice.js +++ b/src/redux/outstaffingSlice.js @@ -3,7 +3,7 @@ import { createSlice } from '@reduxjs/toolkit'; const initialState = { tags: [], profiles: [], - filteredCandidates: [], + filteredCandidates:null, selectedItems: [], currentCandidate: {}, auth: false,