This commit is contained in:
Николай Полтщук 2023-05-17 02:51:31 +03:00
parent 56ef7061fa
commit f9ebddd606
4 changed files with 126 additions and 37 deletions

View File

@ -1,7 +1,8 @@
import React, { useState } from "react";
import React, {useEffect, useState} from "react";
import { useDispatch, useSelector } from "react-redux";
import { apiRequest } from "../../../api/request";
import { urlForLocal } from '../../../helper'
import {
setColumnName,
getProjectBoard,
@ -14,6 +15,8 @@ import {
getColumnId
} from "../../../redux/projectsTrackerSlice";
import arrowDown from "../../../images/selectArrow.png"
import "./trackerModal.scss";
export const TrackerModal = ({
@ -23,6 +26,7 @@ export const TrackerModal = ({
defautlInput,
titleProject,
projectId,
priorityTask
}) => {
const dispatch = useDispatch();
const projectBoard = useSelector(getProjectBoard);
@ -30,15 +34,14 @@ export const TrackerModal = ({
const columnId = useSelector(getColumnId)
const modalType = useSelector(getValueModalType);
const [emailWorker, setEmailWorker] = useState("");
const [projectName, setProjectName] = useState(defautlInput);
const [valueColumn, setValueColumn] = useState("");
const [nameProject, setNameProject] = useState("");
const [valueTiket, setValueTiket] = useState("");
const [descriptionTicket, setDescriptionTicket] = useState("");
const [workers, setWorkers] = useState([])
const [selectWorkersOpen, setSelectWorkersOpen] = useState(false)
const [selectedWorker, setSelectedWorker] = useState(null)
function createTab() {
if (!valueColumn) {
@ -72,6 +75,7 @@ export const TrackerModal = ({
status: 1,
user_id: localStorage.getItem("id"),
column_id: selectedTab,
priority: priorityTask
},
}).then((res) => {
dispatch(setProjectBoardFetch(projectBoard.id));
@ -128,6 +132,23 @@ export const TrackerModal = ({
}
}
function addUserToProject() {
apiRequest("/project/add-user", {
method: "POST",
data: {
user_id: selectedWorker.id,
project_id: projectBoard.id
}
}).then((el) => {
setActive(false);
selectedWorker(null)
})
}
useEffect(() => {
modalType === "addWorker" ? apiRequest('/project/my-employee').then((el) => setWorkers(el.managerEmployees)) : ''
}, [modalType])
return (
<div
className={active ? "modal-add active" : "modal-add"}
@ -138,21 +159,35 @@ export const TrackerModal = ({
<div>
<div className="title-project">
<h4>Добавьте участника</h4>
<p className="title-project__decs">Введите имя или e-mail </p>
<div className="input-container">
<input
className="name-project"
value={emailWorker}
onChange={(e) => setEmailWorker(e.target.value)}
/>
{/*<div className="input-container">*/}
{/* <input*/}
{/* className="name-project"*/}
{/* value={emailWorker}*/}
{/* onChange={(e) => setEmailWorker(e.target.value)}*/}
{/* />*/}
{/*</div>*/}
<div className={selectWorkersOpen ? 'select__worker open' : 'select__worker'} onClick={() => setSelectWorkersOpen(!selectWorkersOpen)}>
<p>{selectedWorker ? selectedWorker.employee.fio : 'Выберите пользователя'}</p>
<img className='arrow' src={arrowDown} alt='arrow' />
{Boolean(selectWorkersOpen) &&
<div className='select__worker__dropDown'>
{workers.map((worker) => {
if (worker === selectedWorker) {
return
}
return <div className='worker' key={worker.id} onClick={() => setSelectedWorker(worker)}>
<p>{worker.employee.fio}</p>
<img src={urlForLocal(worker.employee.avatar)} alt='avatar'/>
</div>
})
}
</div>
}
</div>
</div>
<button
className="button-add"
onClick={(e) => {
e.preventDefault();
setActive(false);
}}
onClick={addUserToProject}
>
Добавить
</button>

View File

@ -61,6 +61,56 @@
font-size: 15px;
line-height: 18px;
}
.select__worker {
display: flex;
justify-content: space-between;
align-items: center;
padding: 5px;
background: white;
border-radius: 5px;
cursor: pointer;
width: 100%;
position: relative;
p {
max-width: 150px;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
font-size: 14px;
}
img {
transition: all 0.3s ease;
width: 16px;
height: 16px;
}
&__dropDown {
display: flex;
flex-direction: column;
position: absolute;
width: 100%;
padding: 5px;
top: 35px;
left: 0;
background: white;
border-radius: 5px;
row-gap: 5px;
.worker {
display: flex;
justify-content: space-between;
}
}
}
.open {
.arrow {
transform: rotate(180deg);
}
}
}
.name-project {

View File

@ -26,7 +26,6 @@ import TrackerModal from "../../components/UI/TrackerModal/TrackerModal";
import project from "../../images/trackerProject.svg";
import tasks from "../../images/trackerTasks.svg";
import archive from "../../images/archiveTracker.svg";
import avatarTest from "../../images/AvatarTest .png";
import selectArrow from "../../images/select.svg";
import commentsBoard from "../../images/commentsBoard.svg";
import filesBoard from "../../images/filesBoard.svg";
@ -40,6 +39,7 @@ export const ProjectTracker = () => {
const [openColumnSelect, setOpenColumnSelect] = useState({});
const [selectedTab, setSelectedTab] = useState(0);
const [priorityTask, setPriorityTask] = useState(0);
const [wrapperHover, setWrapperHover] = useState({});
const [modalAdd, setModalAdd] = useState(false);
const [modalActiveTicket, setModalActiveTicket] = useState(false);
@ -126,10 +126,11 @@ export const ProjectTracker = () => {
}
}
function selectedTabTask(columnId) {
function selectedTabTask(columnId, length) {
setSelectedTab(columnId);
dispatch(modalToggle("createTiketProject"));
setModalAdd(true);
setPriorityTask(length + 1)
}
function openTicket(e, task) {
@ -197,6 +198,7 @@ export const ProjectTracker = () => {
active={modalAdd}
setActive={setModalAdd}
selectedTab={selectedTab}
priorityTask={priorityTask}
/>
{loader && <Loader style="green" />}
@ -277,7 +279,7 @@ export const ProjectTracker = () => {
<div>
<span
className="add"
onClick={() => selectedTabTask(column.id)}
onClick={() => selectedTabTask(column.id, column.tasks.length)}
>
+
</span>
@ -322,11 +324,11 @@ export const ProjectTracker = () => {
</div>
)}
{column.tasks.map((task, index) => {
if (index > 2) {
if (!column.open) {
return;
}
}
// if (index > 2) {
// if (!column.open) {
// return;
// }
// }
return (
<div
key={task.id}
@ -347,7 +349,7 @@ export const ProjectTracker = () => {
<div className="tasks__board__item__info">
<div className="tasks__board__item__info__more">
<img src={commentsBoard} alt="commentsImg" />
<span>{task.comments} коментариев</span>
<span>{task.comment_count} коментариев</span>
</div>
<div className="tasks__board__item__info__more">
<img src={filesBoard} alt="filesImg" />
@ -361,18 +363,18 @@ export const ProjectTracker = () => {
</div>
);
})}
{column.tasks.length > 3 && (
<span
className={
column.open
? "lessItems openItems"
: "moreItems openItems"
}
// onClick={() => toggleMoreTasks(column.id)}
>
{column.open ? "-" : "+"}
</span>
)}
{/*{column.tasks.length > 3 && (*/}
{/* <span*/}
{/* className={*/}
{/* column.open*/}
{/* ? "lessItems openItems"*/}
{/* : "moreItems openItems"*/}
{/* }*/}
{/* // onClick={() => toggleMoreTasks(column.id)}*/}
{/* >*/}
{/* {column.open ? "-" : "+"}*/}
{/* </span>*/}
{/*)}*/}
</div>
);
})}

View File

@ -453,6 +453,8 @@
&__more {
cursor: pointer;
display: flex;
align-items: center;
span {
font-weight: 500;
font-size: 12px;