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,53 +126,70 @@ 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 (
<span key={skill.skill_id}>
{skill.skill.name} {skill.skill.name}
<img <img
src={deleteIcon} src={deleteIcon}
alt='deleteIcon' alt="deleteIcon"
onClick={() => setSelectedSkills((prevValue) => prevValue.filter((item) => item.skill_id !== skill.skill_id))} onClick={() =>
setSelectedSkills((prevValue) =>
prevValue.filter(
(item) => item.skill_id !== skill.skill_id
)
)
}
/> />
</span> </span>
}) );
} })}
<div className='selectSkills'> <div className="selectSkills">
<div className='selectSkills__name' onClick={() => setSelectSkillsOpen(!selectSkillsOpen)}> <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
onClick={() =>
setSelectedSkills((prevValue) => [
...prevValue,
{ skill: skill, skill_id: skill.id },
])
}
key={skill.id} key={skill.id}
className='selectSkills__item'> className="selectSkills__item"
>
{skill.name} {skill.name}
</p> </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) => (
@ -183,7 +199,7 @@ export const Summary = () => {
</span> </span>
))} ))}
</div> </div>
} )}
</div> </div>
</div> </div>
)} )}