summary-skills #1

Merged
nik.polishuk merged 4 commits from summary-skills into main 2023-12-05 16:03:57 +03:00
Showing only changes of commit a353f96d16 - Show all commits

View File

@ -17,10 +17,10 @@ import { ProfileHeader } from "@components/ProfileHeader/ProfileHeader";
import rightArrow from "assets/icons/arrows/arrowRight.svg"; import rightArrow from "assets/icons/arrows/arrowRight.svg";
import arrow from "assets/icons/arrows/left-arrow.png"; import arrow from "assets/icons/arrows/left-arrow.png";
import arrowDown from "assets/icons/arrows/selectArrow.png";
import deleteIcon from "assets/icons/closeProjectPersons.svg";
import gitImgItem from "assets/icons/gitItemImg.svg"; import gitImgItem from "assets/icons/gitItemImg.svg";
import avatarMok from "assets/images/avatarMok.png"; import avatarMok from "assets/images/avatarMok.png";
import deleteIcon from "assets/icons/closeProjectPersons.svg";
import arrowDown from "assets/icons/arrows/selectArrow.png";
import "./summary.scss"; import "./summary.scss";
@ -32,10 +32,10 @@ export const Summary = () => {
const [openGit, setOpenGit] = useState(false); const [openGit, setOpenGit] = useState(false);
const [gitInfo, setGitInfo] = useState([]); const [gitInfo, setGitInfo] = useState([]);
const [editSummeryOpen, setEditSummeryOpen] = useState(false); const [editSummeryOpen, setEditSummeryOpen] = useState(false);
const [editSkills, setEditSkills] = useState(false) const [editSkills, setEditSkills] = useState(false);
const [summery, setSummery] = useState(""); const [summery, setSummery] = useState("");
const [selectedSkills, setSelectedSkills] = useState([]) const [selectedSkills, setSelectedSkills] = useState([]);
const [selectSkillsOpen, setSelectSkillsOpen] = useState(false) const [selectSkillsOpen, setSelectSkillsOpen] = useState(false);
const [skillsList, seSkillsList] = useState([]); const [skillsList, seSkillsList] = useState([]);
useEffect(() => { useEffect(() => {
@ -46,23 +46,22 @@ export const Summary = () => {
useEffect(() => { useEffect(() => {
setSummery(profileInfo.vc_text); setSummery(profileInfo.vc_text);
setSelectedSkills(profileInfo.skillValues) setSelectedSkills(profileInfo.skillValues);
}, [profileInfo]); }, [profileInfo]);
useEffect(() => { useEffect(() => {
apiRequest(`/skills/get-skills-list`).then((el) => { apiRequest(`/skills/get-skills-list`).then((el) => {
seSkillsList(el); seSkillsList(el);
}); });
}, []) }, []);
function setSkills() { function setSkills() {
apiRequest("/resume/edit-skills", { apiRequest("/resume/edit-skills", {
method: "PUT", method: "PUT",
data: { data: {
"UserCard": { UserCard: {
"skill": selectedSkills.map((item) => item.skill_id) skill: selectedSkills.map((item) => item.skill_id),
} },
}, },
}).then(() => {}); }).then(() => {});
} }
@ -127,63 +126,80 @@ export const Summary = () => {
className={editSkills ? "edit" : ""} className={editSkills ? "edit" : ""}
onClick={() => { onClick={() => {
if (editSkills) { if (editSkills) {
setSkills() setSkills();
} }
setEditSkills(!editSkills) setEditSkills(!editSkills);
}} }}
> >
{editSkills ? "Сохранить" : "Редактировать"} {editSkills ? "Сохранить" : "Редактировать"}
</button> </button>
</div> </div>
<div className="skills__section__items"> <div className="skills__section__items">
{editSkills ? {editSkills ? (
<div className='editSkills'> <div className="editSkills">
{selectedSkills && {selectedSkills &&
selectedSkills.map((skill) => { selectedSkills.map((skill) => {
return <span key={skill.skill_id}> return (
{skill.skill.name} <span key={skill.skill_id}>
<img {skill.skill.name}
src={deleteIcon} <img
alt='deleteIcon' src={deleteIcon}
onClick={() => setSelectedSkills((prevValue) => prevValue.filter((item) => item.skill_id !== skill.skill_id))} alt="deleteIcon"
/> onClick={() =>
</span> setSelectedSkills((prevValue) =>
}) prevValue.filter(
} (item) => item.skill_id !== skill.skill_id
<div className='selectSkills'> )
<div className='selectSkills__name' onClick={() => setSelectSkillsOpen(!selectSkillsOpen)}> )
}
/>
</span>
);
})}
<div className="selectSkills">
<div
className="selectSkills__name"
onClick={() => setSelectSkillsOpen(!selectSkillsOpen)}
>
Выберите скилл Выберите скилл
<img <img
className={selectSkillsOpen ? "open" : ""} className={selectSkillsOpen ? "open" : ""}
src={arrowDown} src={arrowDown}
/> />
</div> </div>
{selectSkillsOpen && {selectSkillsOpen && (
<div className='selectSkills__dropDown'> <div className="selectSkills__dropDown">
{skillsList.map((skill) => { {skillsList.map((skill) => {
return <p return (
onClick={() => setSelectedSkills((prevValue) => [...prevValue, {'skill': skill, 'skill_id': skill.id}])} <p
key={skill.id} onClick={() =>
className='selectSkills__item'> setSelectedSkills((prevValue) => [
{skill.name} ...prevValue,
</p> { skill: skill, skill_id: skill.id },
}) ])
} }
key={skill.id}
className="selectSkills__item"
>
{skill.name}
</p>
);
})}
</div> </div>
} )}
</div> </div>
</div> </div>
: ) : (
<div className="skills__section__items__wrapper"> <div className="skills__section__items__wrapper">
{selectedSkills && {selectedSkills &&
selectedSkills.map((skill, index) => ( selectedSkills.map((skill, index) => (
<span key={skill.id} className="skill_item"> <span key={skill.id} className="skill_item">
{skill.skill.name} {skill.skill.name}
{selectedSkills.length > index + 1 && ","} {selectedSkills.length > index + 1 && ","}
</span> </span>
))} ))}
</div> </div>
} )}
</div> </div>
</div> </div>
)} )}