From a353f96d1697b89bf77ab11f308ad078843f3abd Mon Sep 17 00:00:00 2001 From: Mikola Date: Tue, 5 Dec 2023 16:02:59 +0300 Subject: [PATCH] editSkills --- src/pages/Summary/Summary.js | 102 ++++++++++++++++++++--------------- 1 file changed, 59 insertions(+), 43 deletions(-) diff --git a/src/pages/Summary/Summary.js b/src/pages/Summary/Summary.js index 7fd95e8c..d5abaf34 100644 --- a/src/pages/Summary/Summary.js +++ b/src/pages/Summary/Summary.js @@ -17,10 +17,10 @@ import { ProfileHeader } from "@components/ProfileHeader/ProfileHeader"; import rightArrow from "assets/icons/arrows/arrowRight.svg"; 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 avatarMok from "assets/images/avatarMok.png"; -import deleteIcon from "assets/icons/closeProjectPersons.svg"; -import arrowDown from "assets/icons/arrows/selectArrow.png"; import "./summary.scss"; @@ -32,10 +32,10 @@ export const Summary = () => { const [openGit, setOpenGit] = useState(false); const [gitInfo, setGitInfo] = useState([]); const [editSummeryOpen, setEditSummeryOpen] = useState(false); - const [editSkills, setEditSkills] = useState(false) + const [editSkills, setEditSkills] = useState(false); const [summery, setSummery] = useState(""); - const [selectedSkills, setSelectedSkills] = useState([]) - const [selectSkillsOpen, setSelectSkillsOpen] = useState(false) + const [selectedSkills, setSelectedSkills] = useState([]); + const [selectSkillsOpen, setSelectSkillsOpen] = useState(false); const [skillsList, seSkillsList] = useState([]); useEffect(() => { @@ -46,23 +46,22 @@ export const Summary = () => { useEffect(() => { setSummery(profileInfo.vc_text); - setSelectedSkills(profileInfo.skillValues) + setSelectedSkills(profileInfo.skillValues); }, [profileInfo]); - useEffect(() => { apiRequest(`/skills/get-skills-list`).then((el) => { seSkillsList(el); }); - }, []) + }, []); function setSkills() { apiRequest("/resume/edit-skills", { method: "PUT", data: { - "UserCard": { - "skill": selectedSkills.map((item) => item.skill_id) - } + UserCard: { + skill: selectedSkills.map((item) => item.skill_id), + }, }, }).then(() => {}); } @@ -127,63 +126,80 @@ export const Summary = () => { className={editSkills ? "edit" : ""} onClick={() => { if (editSkills) { - setSkills() + setSkills(); } - setEditSkills(!editSkills) + setEditSkills(!editSkills); }} > {editSkills ? "Сохранить" : "Редактировать"}
- {editSkills ? -
+ {editSkills ? ( +
{selectedSkills && selectedSkills.map((skill) => { - return - {skill.skill.name} - deleteIcon setSelectedSkills((prevValue) => prevValue.filter((item) => item.skill_id !== skill.skill_id))} - /> - - }) - } -
-
setSelectSkillsOpen(!selectSkillsOpen)}> + return ( + + {skill.skill.name} + deleteIcon + setSelectedSkills((prevValue) => + prevValue.filter( + (item) => item.skill_id !== skill.skill_id + ) + ) + } + /> + + ); + })} +
+
setSelectSkillsOpen(!selectSkillsOpen)} + > Выберите скилл + />
- {selectSkillsOpen && -
+ {selectSkillsOpen && ( +
{skillsList.map((skill) => { - return

setSelectedSkills((prevValue) => [...prevValue, {'skill': skill, 'skill_id': skill.id}])} - key={skill.id} - className='selectSkills__item'> - {skill.name} -

- }) - } + return ( +

+ setSelectedSkills((prevValue) => [ + ...prevValue, + { skill: skill, skill_id: skill.id }, + ]) + } + key={skill.id} + className="selectSkills__item" + > + {skill.name} +

+ ); + })}
- } + )}
- : + ) : (
{selectedSkills && selectedSkills.map((skill, index) => ( - {skill.skill.name} + {skill.skill.name} {selectedSkills.length > index + 1 && ","} - + ))}
- } + )}
)}