From f9ebddd6065bc7d8fd7df211f35a4a52c10823dd Mon Sep 17 00:00:00 2001 From: M1kola Date: Wed, 17 May 2023 02:51:31 +0300 Subject: [PATCH] fixes --- .../UI/TrackerModal/TrackerModal.jsx | 67 ++++++++++++++----- .../UI/TrackerModal/trackerModal.scss | 50 ++++++++++++++ src/pages/ProjectTracker/ProjectTracker.js | 44 ++++++------ src/pages/Tracker/tracker.scss | 2 + 4 files changed, 126 insertions(+), 37 deletions(-) diff --git a/src/components/UI/TrackerModal/TrackerModal.jsx b/src/components/UI/TrackerModal/TrackerModal.jsx index b0d3c77a..d8361f34 100644 --- a/src/components/UI/TrackerModal/TrackerModal.jsx +++ b/src/components/UI/TrackerModal/TrackerModal.jsx @@ -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 (

Добавьте участника

-

Введите имя или e-mail

-
- setEmailWorker(e.target.value)} - /> + {/*
*/} + {/* setEmailWorker(e.target.value)}*/} + {/* />*/} + {/*
*/} +
setSelectWorkersOpen(!selectWorkersOpen)}> +

{selectedWorker ? selectedWorker.employee.fio : 'Выберите пользователя'}

+ arrow + {Boolean(selectWorkersOpen) && +
+ {workers.map((worker) => { + if (worker === selectedWorker) { + return + } + return
setSelectedWorker(worker)}> +

{worker.employee.fio}

+ avatar +
+ }) + } +
+ }
diff --git a/src/components/UI/TrackerModal/trackerModal.scss b/src/components/UI/TrackerModal/trackerModal.scss index ca46330b..ab934e11 100644 --- a/src/components/UI/TrackerModal/trackerModal.scss +++ b/src/components/UI/TrackerModal/trackerModal.scss @@ -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 { diff --git a/src/pages/ProjectTracker/ProjectTracker.js b/src/pages/ProjectTracker/ProjectTracker.js index 12cbf8e5..854e5ced 100644 --- a/src/pages/ProjectTracker/ProjectTracker.js +++ b/src/pages/ProjectTracker/ProjectTracker.js @@ -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 && } @@ -277,7 +279,7 @@ export const ProjectTracker = () => {
selectedTabTask(column.id)} + onClick={() => selectedTabTask(column.id, column.tasks.length)} > + @@ -322,11 +324,11 @@ export const ProjectTracker = () => {
)} {column.tasks.map((task, index) => { - if (index > 2) { - if (!column.open) { - return; - } - } + // if (index > 2) { + // if (!column.open) { + // return; + // } + // } return (
{
commentsImg - {task.comments} коментариев + {task.comment_count} коментариев
filesImg @@ -361,18 +363,18 @@ export const ProjectTracker = () => {
); })} - {column.tasks.length > 3 && ( - toggleMoreTasks(column.id)} - > - {column.open ? "-" : "+"} - - )} + {/*{column.tasks.length > 3 && (*/} + {/* toggleMoreTasks(column.id)}*/} + {/* >*/} + {/* {column.open ? "-" : "+"}*/} + {/* */} + {/*)}*/}
); })} diff --git a/src/pages/Tracker/tracker.scss b/src/pages/Tracker/tracker.scss index 725d3178..f7452790 100644 --- a/src/pages/Tracker/tracker.scss +++ b/src/pages/Tracker/tracker.scss @@ -453,6 +453,8 @@ &__more { cursor: pointer; + display: flex; + align-items: center; span { font-weight: 500; font-size: 12px;