fix Summary skills
This commit is contained in:
parent
ca0a509077
commit
9909101660
@ -58,6 +58,25 @@ export const Summary = () => {
|
|||||||
});
|
});
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
|
const addSkill = (skill) => {
|
||||||
|
const isSkillFound = selectedSkills.some(
|
||||||
|
(item) => item.skill_id == skill.id
|
||||||
|
);
|
||||||
|
|
||||||
|
if (!isSkillFound) {
|
||||||
|
setSelectedSkills((prevValue) => [
|
||||||
|
...prevValue,
|
||||||
|
{ skill: skill, skill_id: skill.id }
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const deleteSkill = (skill) => {
|
||||||
|
setSelectedSkills((prevValue) =>
|
||||||
|
prevValue.filter((item) => item.skill_id !== skill.skill_id)
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
function setSkills() {
|
function setSkills() {
|
||||||
apiRequest("/resume/edit-skills", {
|
apiRequest("/resume/edit-skills", {
|
||||||
method: "PUT",
|
method: "PUT",
|
||||||
@ -157,13 +176,7 @@ export const Summary = () => {
|
|||||||
<img
|
<img
|
||||||
src={deleteIcon}
|
src={deleteIcon}
|
||||||
alt="deleteIcon"
|
alt="deleteIcon"
|
||||||
onClick={() =>
|
onClick={() => deleteSkill(skill)}
|
||||||
setSelectedSkills((prevValue) =>
|
|
||||||
prevValue.filter(
|
|
||||||
(item) => item.skill_id !== skill.skill_id
|
|
||||||
)
|
|
||||||
)
|
|
||||||
}
|
|
||||||
/>
|
/>
|
||||||
</span>
|
</span>
|
||||||
);
|
);
|
||||||
@ -184,12 +197,7 @@ export const Summary = () => {
|
|||||||
{skillsList.map((skill) => {
|
{skillsList.map((skill) => {
|
||||||
return (
|
return (
|
||||||
<p
|
<p
|
||||||
onClick={() =>
|
onClick={() => addSkill(skill)}
|
||||||
setSelectedSkills((prevValue) => [
|
|
||||||
...prevValue,
|
|
||||||
{ skill: skill, skill_id: skill.id }
|
|
||||||
])
|
|
||||||
}
|
|
||||||
key={skill.id}
|
key={skill.id}
|
||||||
className="select-skills__item"
|
className="select-skills__item"
|
||||||
>
|
>
|
||||||
@ -205,7 +213,7 @@ export const Summary = () => {
|
|||||||
<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.skill_id} className="skill_item">
|
||||||
{skill.skill.name}
|
{skill.skill.name}
|
||||||
{selectedSkills.length > index + 1 && ","}
|
{selectedSkills.length > index + 1 && ","}
|
||||||
</span>
|
</span>
|
||||||
|
Loading…
Reference in New Issue
Block a user