Fixed copmonents
This commit is contained in:
@ -1,118 +0,0 @@
|
||||
import React from 'react'
|
||||
import OutsideClickHandler from 'react-outside-click-handler'
|
||||
import {useDispatch, useSelector} from 'react-redux'
|
||||
import {
|
||||
selectItems,
|
||||
selectedItems,
|
||||
profiles,
|
||||
} from '../../redux/outstaffingSlice'
|
||||
|
||||
import {apiRequest} from "../../api/request";
|
||||
|
||||
import './outstaffingBlock.scss'
|
||||
|
||||
|
||||
const handlePositionClick = (
|
||||
{
|
||||
dispatch,
|
||||
positionId,
|
||||
isSelected,
|
||||
onSelect,
|
||||
apiRequest
|
||||
}) => {
|
||||
if (isSelected) {
|
||||
apiRequest('/profile', {
|
||||
params: {
|
||||
limit: 1000
|
||||
},
|
||||
}).then((profileArr) => {
|
||||
dispatch(profiles(profileArr));
|
||||
dispatch(selectedItems([]));
|
||||
onSelect(positionId)
|
||||
})
|
||||
} else {
|
||||
apiRequest('/profile', {
|
||||
params: {
|
||||
limit: '1000',
|
||||
position_id: positionId
|
||||
},
|
||||
}).then((res) => {
|
||||
dispatch(profiles(res));
|
||||
dispatch(selectedItems([]));
|
||||
onSelect(positionId)
|
||||
})
|
||||
}
|
||||
};
|
||||
|
||||
const OutstaffingBlock = (
|
||||
{
|
||||
dataTags = [],
|
||||
selected,
|
||||
img,
|
||||
header,
|
||||
positionId,
|
||||
isSelected,
|
||||
onSelect
|
||||
}) => {
|
||||
|
||||
|
||||
const dispatch = useDispatch();
|
||||
|
||||
const itemsArr = useSelector(selectItems);
|
||||
|
||||
|
||||
const handleBlockClick = (item, id) => {
|
||||
if (!itemsArr.find((el) => item === el.value)) {
|
||||
dispatch(selectedItems([...itemsArr, {id, value: item, label: item}]))
|
||||
}
|
||||
};
|
||||
|
||||
let classes;
|
||||
|
||||
dataTags.forEach((el) => {
|
||||
if (el.name === 'skills_back') {
|
||||
classes = 'back'
|
||||
} else if (el.name === 'skills_design') {
|
||||
classes = 'des'
|
||||
} else if (el.name === 'skills_front') {
|
||||
classes = 'front'
|
||||
}
|
||||
});
|
||||
|
||||
return (
|
||||
<OutsideClickHandler onOutsideClick={() => isSelected && onSelect(null)}>
|
||||
<div className={`outstaffing-block${isSelected ? ' outstaffing-block__selected' : ''}`}>
|
||||
<div className={`outstaffing-block__img ${selected ? ' outstaffing-block__border' : ''}`}
|
||||
onClick={() => handlePositionClick(
|
||||
{
|
||||
dispatch,
|
||||
positionId,
|
||||
isSelected,
|
||||
onSelect,
|
||||
apiRequest
|
||||
})
|
||||
}>
|
||||
<h3>{header}</h3>
|
||||
<img className={classes} src={img} alt='img'/>
|
||||
</div>
|
||||
<div className={`${selected ? 'outstaffing-block__mobile--block' : 'outstaffing-block__mobile--none'}`} >
|
||||
<p className='outstaffing-block__text'># Популярный стек</p>
|
||||
{dataTags && (
|
||||
<ul className='outstaffing-block__items'>
|
||||
{dataTags.map((item) => (
|
||||
<li
|
||||
key={item.id}
|
||||
onClick={() => handleBlockClick(item.value, item.id)}
|
||||
>
|
||||
{item.value}
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</OutsideClickHandler>
|
||||
)
|
||||
};
|
||||
|
||||
export default OutstaffingBlock
|
126
src/components/OutstaffingBlock/OutstaffingBlock.jsx
Normal file
126
src/components/OutstaffingBlock/OutstaffingBlock.jsx
Normal file
@ -0,0 +1,126 @@
|
||||
import React from "react";
|
||||
import OutsideClickHandler from "react-outside-click-handler";
|
||||
import { useDispatch, useSelector } from "react-redux";
|
||||
import {
|
||||
selectItems,
|
||||
selectedItems,
|
||||
profiles,
|
||||
} from "../../redux/outstaffingSlice";
|
||||
|
||||
import { apiRequest } from "../../api/request";
|
||||
|
||||
import "./outstaffingBlock.scss";
|
||||
|
||||
const handlePositionClick = ({
|
||||
dispatch,
|
||||
positionId,
|
||||
isSelected,
|
||||
onSelect,
|
||||
apiRequest,
|
||||
}) => {
|
||||
if (isSelected) {
|
||||
apiRequest("/profile", {
|
||||
params: {
|
||||
limit: 1000,
|
||||
},
|
||||
}).then((profileArr) => {
|
||||
dispatch(profiles(profileArr));
|
||||
dispatch(selectedItems([]));
|
||||
onSelect(positionId);
|
||||
});
|
||||
} else {
|
||||
apiRequest("/profile", {
|
||||
params: {
|
||||
limit: "1000",
|
||||
position_id: positionId,
|
||||
},
|
||||
}).then((res) => {
|
||||
dispatch(profiles(res));
|
||||
dispatch(selectedItems([]));
|
||||
onSelect(positionId);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
const OutstaffingBlock = ({
|
||||
dataTags = [],
|
||||
selected,
|
||||
img,
|
||||
header,
|
||||
positionId,
|
||||
isSelected,
|
||||
onSelect,
|
||||
}) => {
|
||||
const dispatch = useDispatch();
|
||||
|
||||
const itemsArr = useSelector(selectItems);
|
||||
|
||||
const handleBlockClick = (item, id) => {
|
||||
if (!itemsArr.find((el) => item === el.value)) {
|
||||
dispatch(selectedItems([...itemsArr, { id, value: item, label: item }]));
|
||||
}
|
||||
};
|
||||
|
||||
let classes;
|
||||
|
||||
dataTags.forEach((el) => {
|
||||
if (el.name === "skills_back") {
|
||||
classes = "back";
|
||||
} else if (el.name === "skills_design") {
|
||||
classes = "des";
|
||||
} else if (el.name === "skills_front") {
|
||||
classes = "front";
|
||||
}
|
||||
});
|
||||
|
||||
return (
|
||||
<OutsideClickHandler onOutsideClick={() => isSelected && onSelect(null)}>
|
||||
<div
|
||||
className={`outstaffing-block${
|
||||
isSelected ? " outstaffing-block__selected" : ""
|
||||
}`}
|
||||
>
|
||||
<div
|
||||
className={`outstaffing-block__img ${
|
||||
selected ? " outstaffing-block__border" : ""
|
||||
}`}
|
||||
onClick={() =>
|
||||
handlePositionClick({
|
||||
dispatch,
|
||||
positionId,
|
||||
isSelected,
|
||||
onSelect,
|
||||
apiRequest,
|
||||
})
|
||||
}
|
||||
>
|
||||
<h3>{header}</h3>
|
||||
<img className={classes} src={img} alt="img" />
|
||||
</div>
|
||||
<div
|
||||
className={`${
|
||||
selected
|
||||
? "outstaffing-block__mobile--block"
|
||||
: "outstaffing-block__mobile--none"
|
||||
}`}
|
||||
>
|
||||
<p className="outstaffing-block__text"># Популярный стек</p>
|
||||
{dataTags && (
|
||||
<ul className="outstaffing-block__items">
|
||||
{dataTags.map((item) => (
|
||||
<li
|
||||
key={item.id}
|
||||
onClick={() => handleBlockClick(item.value, item.id)}
|
||||
>
|
||||
{item.value}
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</OutsideClickHandler>
|
||||
);
|
||||
};
|
||||
|
||||
export default OutstaffingBlock;
|
@ -1,15 +1,15 @@
|
||||
body {
|
||||
font-family: 'LabGrotesque', sans-serif !important;
|
||||
font-family: "LabGrotesque", sans-serif !important;
|
||||
}
|
||||
|
||||
.container {
|
||||
max-width: 1160px !important;
|
||||
}
|
||||
.catalog {
|
||||
background: #F1F1F1;
|
||||
background: #f1f1f1;
|
||||
height: 100%;
|
||||
min-height: 100vh;
|
||||
font-family: 'LabGrotesque', sans-serif;
|
||||
font-family: "LabGrotesque", sans-serif;
|
||||
padding-top: 23px;
|
||||
|
||||
&__title {
|
||||
@ -37,7 +37,7 @@ body {
|
||||
}
|
||||
|
||||
& > p {
|
||||
font-family: 'GT Eesti Pro Display';
|
||||
font-family: "GT Eesti Pro Display";
|
||||
font-size: 1.2em;
|
||||
font-weight: 300;
|
||||
font-style: normal;
|
||||
@ -60,7 +60,7 @@ body {
|
||||
right: 13%;
|
||||
top: 30%;
|
||||
max-width: 130px;
|
||||
font-family: 'GT Eesti Pro Display';
|
||||
font-family: "GT Eesti Pro Display";
|
||||
font-size: 18px;
|
||||
font-weight: 400;
|
||||
font-style: normal;
|
||||
@ -85,7 +85,7 @@ body {
|
||||
|
||||
&__items {
|
||||
li {
|
||||
font-family: 'GT Eesti Pro Display';
|
||||
font-family: "GT Eesti Pro Display";
|
||||
font-size: 1.8em;
|
||||
font-weight: 100;
|
||||
font-style: normal;
|
||||
|
Reference in New Issue
Block a user