From 5067746178f91060cbb4eb2d060da3468225bba1 Mon Sep 17 00:00:00 2001 From: M1kola Date: Tue, 18 Apr 2023 13:58:36 +0300 Subject: [PATCH] partnerRequests --- .../PartnerAddRequest/PartnerAddRequest.js | 161 ++++++++++++---- .../PartnerAddRequest/partnerAddRequest.scss | 79 +++++++- src/pages/PartnerBid/PartnerBid.js | 176 +++++++++++------- src/pages/PartnerBid/partnerBid.scss | 5 + src/pages/PartnerRequests/PartnerRequests.js | 133 ++++++------- src/pages/ViewReport/ViewReport.js | 5 +- src/redux/outstaffingSlice.js | 14 +- 7 files changed, 396 insertions(+), 177 deletions(-) diff --git a/src/pages/PartnerAddRequest/PartnerAddRequest.js b/src/pages/PartnerAddRequest/PartnerAddRequest.js index c4728bbb..35af4381 100644 --- a/src/pages/PartnerAddRequest/PartnerAddRequest.js +++ b/src/pages/PartnerAddRequest/PartnerAddRequest.js @@ -1,9 +1,11 @@ -import React, { useState } from 'react'; +import React, {useEffect, useState } from 'react'; import {ProfileHeader} from "../../components/ProfileHeader/ProfileHeader"; import {ProfileBreadcrumbs} from "../../components/ProfileBreadcrumbs/ProfileBreadcrumbs" import {Footer} from "../../components/Footer/Footer"; -import {Navigate} from "react-router-dom"; +import {Link, Navigate, useNavigate} from "react-router-dom"; + +import {apiRequest} from "../../api/request"; import arrowDown from "../../images/selectArrow.png" import processImg from "../../images/partnerAddRequestFirstImg.png" @@ -19,11 +21,62 @@ export const PartnerAddRequest = () => { return } - const [skills, setSkills] = useState(['REST API', 'Async/await']) - const [selectedSkills, setSelectedSkills] = useState([]) - const [filteredSkills, setFilteredSkills] = useState(skills) + const navigate= useNavigate(); + const [skills, setSkills] = useState([]) + const [filteredSkills, setFilteredSkills] = useState([]) + const [specializationList, setSpecializationList] = useState([]) + const [levelList, setLevelList] = useState([]) + const [countList] = useState([1, 2, 3, 4, 5]) const [openSkillsSelect, setOpenSkillsSelect] = useState(false) + const [openSpecializationList, setOpenSpecializationListOpen] = useState(false) + const [openLevelList, setOpenLevelList] = useState(false) + const [openCountList, setOpenCountList] = useState(false) + const [selectedSkills, setSelectedSkills] = useState([]) + const [selectedSpecialization, setSelectedSpecialization] = useState('Выберите специализацию') + const [selectedLevel, setSelectedLevel] = useState('Выберите уровень') + const [selectedCount, setSelectedCount] = useState('Выберите кол-во сотрудников') + const [inputs, setInputs] = useState({title: '', description: ''}) + + useEffect(() => { + apiRequest(`/profile/positions-list`).then((el) => setSpecializationList(el)) + apiRequest(`/profile/level-list`).then((el) => setLevelList(el)) + apiRequest(`/skills/get-skills-list`).then((el) => { + setSkills(el) + setFilteredSkills(el) + }) + }, []) + + const disableBtn = () => { + if (!inputs.title || + typeof selectedSpecialization === "string" || + typeof selectedLevel === "string" || + typeof selectedCount === "string" || + !inputs.description || + !selectedSkills.length) { + return false + } + return true + } + + const handler = () => { + apiRequest('/request/create-request', { + method: 'POST', + data: { + user_id: localStorage.getItem('id'), + title: inputs.title, + position_id: selectedSpecialization.id, + knowledge_level_id: selectedLevel.id, + specialist_count: selectedCount, + status: 1, + descr: inputs.description, + skill_ids: selectedSkills.map((skill) => {return skill.id}) + } + }).then((res) => { + navigate('/profile/requests'); + }) + } + return (
@@ -43,31 +96,42 @@ export const PartnerAddRequest = () => {

Название вакансии

- + setInputs((prevValue) => ({...prevValue, title: e.target.value}) )} type='text' placeholder='Вакансия'/>

Выберите специализацию

-
+
{setOpenSpecializationListOpen(!openSpecializationList)}}>
- Разработка - -
-
- Backend Developer - + {typeof selectedSpecialization === "string" ? selectedSpecialization : selectedSpecialization.name} +
+ {openSpecializationList && Boolean(specializationList.length) && +
+ {specializationList.map((specialization, index) => { + return

{ + setOpenSpecializationListOpen(false) + setSelectedSpecialization(specialization) + }} + > + {specialization.name}

+ })} +
+ }

Навыки

{setOpenSkillsSelect(true)}}> {Boolean(selectedSkills.length) && selectedSkills.map((skill, index) => { - return
- {skill} + return
+ {skill.name} delete { + setSkills(prevArray => [...prevArray, skill]) setFilteredSkills(prevArray => [...prevArray, skill]) setSelectedSkills(selectedSkills.filter((skill, indexSkill) => { return indexSkill !== index @@ -76,29 +140,30 @@ export const PartnerAddRequest = () => {
}) } - {!selectedSkills.length && - { - setFilteredSkills(skills.filter((skill) => { - return skill.toLowerCase().includes(e.target.value.toLowerCase()) - })) - }} /> - } + { + setFilteredSkills(skills.filter((skill) => { + return skill.name.toLowerCase().includes(e.target.value.toLowerCase()) + })) + }} />
{openSkillsSelect && Boolean(filteredSkills.length) &&
{filteredSkills.map((skill, index) => { return { setSelectedSkills(prevArray => [...prevArray, skill]) setFilteredSkills(filteredSkills.filter((skill, skillIndex) => { return skillIndex !== index })) + setSkills(skills.filter((initSkill) => { + return initSkill.id !==skill.id + })) setOpenSkillsSelect(false) }} > - {skill} + {skill.name} })}
} @@ -108,25 +173,53 @@ export const PartnerAddRequest = () => {

Квалификация

Выберите уровень знаний

-
- Разработка - +
setOpenLevelList(!openLevelList)}> + {typeof selectedLevel === "string" ? selectedLevel : selectedLevel.name} +
+ {openLevelList && Boolean(Object.values(levelList).length) && +
+ {Object.values(levelList).map((level, index) => { + return

{ + setOpenLevelList(false) + setSelectedLevel({name: level, id: index + 1}) + }} + > + {level}

+ })} +
+ }

Введите необходимое описание

-