diff --git a/src/components/UI/ModalTicket/ModalTicket.jsx b/src/components/UI/ModalTicket/ModalTicket.jsx index 290ff0bd..a7ccd426 100644 --- a/src/components/UI/ModalTicket/ModalTicket.jsx +++ b/src/components/UI/ModalTicket/ModalTicket.jsx @@ -33,7 +33,8 @@ export const ModalTiсket = ({ const dispatch = useDispatch(); const [addSubtask, setAddSubtask] = useState(false); const [editOpen, setEditOpen] = useState(false); - const [inputsValue, setInputsValue] = useState({title: task.title, description: task.description}) + const [inputsValue, setInputsValue] = useState({title: task.title, description: task.description, comment: ''}); + const [comments, setComments] = useState([]); function deleteTask() { apiRequest("/task/update-task", { @@ -61,6 +62,23 @@ export const ModalTiсket = ({ }); } + function editComment() { + apiRequest("/comment/create", { + method: "POST", + data: { + text: inputsValue.comment, + entity_type: 2, + entity_id: task.id + } + }).then((res) => { + setInputsValue((prevValue) => ({...prevValue, comment: ''})) + }) + } + + useEffect(() => { + apiRequest(`/comment/get-by-entity?entity_type=2&entity_id=${task.id}`).then((res) => setComments(res)) + }, []) + return (
- - + { + setInputsValue((prevValue) => ({...prevValue, comment: e.target.value})) + }} /> +
diff --git a/src/components/UI/TicketFullScreen/TicketFullScreen.jsx b/src/components/UI/TicketFullScreen/TicketFullScreen.jsx index 46f1c769..38a6d084 100644 --- a/src/components/UI/TicketFullScreen/TicketFullScreen.jsx +++ b/src/components/UI/TicketFullScreen/TicketFullScreen.jsx @@ -39,13 +39,15 @@ export const TicketFullScreen = ({}) => { const [projectInfo, setProjectInfo] = useState({}); const [taskInfo, setTaskInfo] = useState({}); const [editOpen, setEditOpen] = useState(false); - const [inputsValue, setInputsValue] = useState({}) - const [loader, setLoader] = useState(true) + const [inputsValue, setInputsValue] = useState({}); + const [loader, setLoader] = useState(true); + const [comments, setComments] = useState([]); useEffect(() => { apiRequest(`/task/get-task?task_id=${ticketId.id}`).then((taskInfo) => { setTaskInfo(taskInfo); - setInputsValue({title: taskInfo.title, description: taskInfo.description}) + setInputsValue({title: taskInfo.title, description: taskInfo.description, comment: ''}) + apiRequest(`/comment/get-by-entity?entity_type=2&entity_id=${taskInfo.id}`).then((res) => setComments(res)) apiRequest(`/project/get-project?project_id=${taskInfo.project_id}`).then( (project) => { setProjectInfo(project); @@ -79,6 +81,19 @@ export const TicketFullScreen = ({}) => { }); } + function editComment() { + apiRequest("/comment/create", { + method: "POST", + data: { + text: inputsValue.comment, + entity_type: 2, + entity_id: taskInfo.id + } + }).then((res) => { + setInputsValue((prevValue) => ({...prevValue, comment: ''})) + }) + } + const toggleTabs = (index) => { dispatch(setToggleTab(index)); }; @@ -204,8 +219,10 @@ export const TicketFullScreen = ({}) => {

- - + { + setInputsValue((prevValue) => ({...prevValue, comment: e.target.value})) + }} /> +
diff --git a/src/components/UI/TrackerModal/TrackerModal.jsx b/src/components/UI/TrackerModal/TrackerModal.jsx index d8361f34..37c33809 100644 --- a/src/components/UI/TrackerModal/TrackerModal.jsx +++ b/src/components/UI/TrackerModal/TrackerModal.jsx @@ -142,17 +142,25 @@ export const TrackerModal = ({ }).then((el) => { setActive(false); selectedWorker(null) + setSelectWorkersOpen(false) }) } useEffect(() => { - modalType === "addWorker" ? apiRequest('/project/my-employee').then((el) => setWorkers(el.managerEmployees)) : '' + modalType === "addWorker" ? apiRequest('/project/my-employee').then((el) => { + let persons = el.managerEmployees + projectBoard.projectUsers.forEach(person => persons.splice(persons.indexOf(person), 1)) + setWorkers(persons) + }) : '' }, [modalType]) return (
setActive(false)} + onClick={() => { + setActive(false) + setSelectWorkersOpen(false) + }} >
e.stopPropagation()}> {modalType === "addWorker" && ( @@ -172,6 +180,9 @@ export const TrackerModal = ({ {Boolean(selectWorkersOpen) &&
{workers.map((worker) => { + if ((workers.length === 1 || 0) && worker === selectedWorker) { + return

Пользователей нет

+ } if (worker === selectedWorker) { return }