This commit is contained in:
Николай Полтщук 2023-05-17 23:18:46 +03:00
parent f9ebddd606
commit a443bad839
3 changed files with 58 additions and 10 deletions

View File

@ -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 (
<div
className={active ? "modal-tiket active" : "modal-tiket"}
@ -115,8 +133,10 @@ export const ModalTiсket = ({
</p>
</div>
<div className="content__input">
<input placeholder="Оставить комментарий"></input>
<img src={send}></img>
<input placeholder="Оставить комментарий" value={inputsValue.comment} onChange={(e) => {
setInputsValue((prevValue) => ({...prevValue, comment: e.target.value}))
}} />
<img src={send} onClick={editComment}></img>
</div>
</div>
</div>

View File

@ -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 = ({}) => {
</p>
</div>
<div className="content__input">
<input placeholder="Оставить комментарий"></input>
<img src={send}></img>
<input placeholder="Оставить комментарий" value={inputsValue.comment} onChange={(e) => {
setInputsValue((prevValue) => ({...prevValue, comment: e.target.value}))
}} />
<img src={send} onClick={editComment}></img>
</div>
</div>
</div>

View File

@ -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 (
<div
className={active ? "modal-add active" : "modal-add"}
onClick={() => setActive(false)}
onClick={() => {
setActive(false)
setSelectWorkersOpen(false)
}}
>
<div className="modal-add__content" onClick={(e) => e.stopPropagation()}>
{modalType === "addWorker" && (
@ -172,6 +180,9 @@ export const TrackerModal = ({
{Boolean(selectWorkersOpen) &&
<div className='select__worker__dropDown'>
{workers.map((worker) => {
if ((workers.length === 1 || 0) && worker === selectedWorker) {
return <p>Пользователей нет</p>
}
if (worker === selectedWorker) {
return
}