This commit is contained in:
Mikola 2023-10-28 17:57:58 +03:00
parent 6dd8ac7604
commit 7fb04005bb
3 changed files with 112 additions and 105 deletions

View File

@ -94,7 +94,7 @@ export const ModalTiсket = ({
const [acceptModalOpen, setAcceptModalOpen] = useState(false); const [acceptModalOpen, setAcceptModalOpen] = useState(false);
const [selectTagsOpen, setSelectTagsOpen] = useState(false); const [selectTagsOpen, setSelectTagsOpen] = useState(false);
const { showNotification } = useNotification(); const { showNotification } = useNotification();
const [commentSendDisable, setCommentSendDisable] = useState(false) const [commentSendDisable, setCommentSendDisable] = useState(false);
function deleteTask() { function deleteTask() {
apiRequest("/task/update-task", { apiRequest("/task/update-task", {
@ -145,8 +145,8 @@ export const ModalTiсket = ({
} }
function createComment() { function createComment() {
if (!inputsValue.comment) return if (!inputsValue.comment) return;
setCommentSendDisable(true) setCommentSendDisable(true);
apiRequest("/comment/create", { apiRequest("/comment/create", {
method: "POST", method: "POST",
data: { data: {
@ -156,7 +156,7 @@ export const ModalTiсket = ({
}, },
}).then((res) => { }).then((res) => {
let newComment = res; let newComment = res;
setCommentSendDisable(false) setCommentSendDisable(false);
newComment.created_at = new Date(); newComment.created_at = new Date();
newComment.subComments = []; newComment.subComments = [];
setInputsValue((prevValue) => ({ ...prevValue, comment: "" })); setInputsValue((prevValue) => ({ ...prevValue, comment: "" }));
@ -289,7 +289,7 @@ export const ModalTiсket = ({
} }
useEffect(() => { useEffect(() => {
initListeners() initListeners();
apiRequest( apiRequest(
`/comment/get-by-entity?entity_type=2&entity_id=${task.id}` `/comment/get-by-entity?entity_type=2&entity_id=${task.id}`
).then((res) => { ).then((res) => {
@ -515,53 +515,51 @@ export const ModalTiсket = ({
const path = event.path || (event.composedPath && event.composedPath()); const path = event.path || (event.composedPath && event.composedPath());
if ( if (
event && event &&
!path.find( !path.find(
(div) => (div) =>
div.classList && div.classList &&
(div.classList.contains("button-add-worker") || (div.classList.contains("button-add-worker") ||
div.classList.contains("dropdownList")) div.classList.contains("dropdownList"))
) )
) { ) {
setDropListOpen(false); setDropListOpen(false);
setDropListMembersOpen(false) setDropListMembersOpen(false);
} }
if ( if (
event && event &&
!path.find( !path.find(
(div) => (div) =>
div.classList && div.classList &&
(div.classList.contains("deadLine") || (div.classList.contains("deadLine") ||
div.classList.contains("react-datepicker-popper")) div.classList.contains("react-datepicker-popper"))
) )
) { ) {
setDatePickerOpen(false) setDatePickerOpen(false);
} }
if ( if (
event && event &&
!path.find( !path.find(
(div) => (div) =>
div.classList && div.classList &&
(div.classList.contains("tags") || (div.classList.contains("tags") ||
div.classList.contains("tags__dropDown")) div.classList.contains("tags__dropDown"))
) )
) { ) {
setSelectTagsOpen(false) setSelectTagsOpen(false);
} }
} };
return ( return (
<div <div
className={active ? "modal-tiket active" : "modal-tiket"} className={active ? "modal-tiket active" : "modal-tiket"}
onClick={(e) => { onClick={(e) => {
if(e.target.className.includes('modal-tiket')) setActive(false) if (e.target.className.includes("modal-tiket")) setActive(false);
}} }}
> >
<div <div className="modal-tiket__content">
className="modal-tiket__content"
>
<div className="content"> <div className="content">
<h3 className="title-project"> <h3 className="title-project">
<img src={category} className="title-project__category"></img> <img src={category} className="title-project__category"></img>
@ -697,7 +695,11 @@ export const ModalTiсket = ({
})); }));
}} }}
/> />
<img className={commentSendDisable ? 'disable' : ''} src={send} onClick={createComment}></img> <img
className={commentSendDisable ? "disable" : ""}
src={send}
onClick={createComment}
></img>
</div> </div>
<div className="comments__list"> <div className="comments__list">
{comments.map((comment) => { {comments.map((comment) => {

View File

@ -93,10 +93,10 @@ export const TicketFullScreen = () => {
const [selectTagsOpen, setSelectTagsOpen] = useState(false); const [selectTagsOpen, setSelectTagsOpen] = useState(false);
const [correctProjectTags, setCorrectProjectTags] = useState([]); const [correctProjectTags, setCorrectProjectTags] = useState([]);
const { showNotification } = useNotification(); const { showNotification } = useNotification();
const [commentSendDisable, setCommentSendDisable] = useState(false) const [commentSendDisable, setCommentSendDisable] = useState(false);
useEffect(() => { useEffect(() => {
initListeners() initListeners();
apiRequest(`/task/get-task?task_id=${ticketId.id}&expand=mark`).then( apiRequest(`/task/get-task?task_id=${ticketId.id}&expand=mark`).then(
(taskInfo) => { (taskInfo) => {
setTaskInfo(taskInfo); setTaskInfo(taskInfo);
@ -219,8 +219,8 @@ export const TicketFullScreen = () => {
} }
function createComment() { function createComment() {
if (!inputsValue.comment) return if (!inputsValue.comment) return;
setCommentSendDisable(true) setCommentSendDisable(true);
apiRequest("/comment/create", { apiRequest("/comment/create", {
method: "POST", method: "POST",
data: { data: {
@ -230,7 +230,7 @@ export const TicketFullScreen = () => {
}, },
}).then((res) => { }).then((res) => {
let newComment = res; let newComment = res;
setCommentSendDisable(false) setCommentSendDisable(false);
newComment.created_at = new Date(); newComment.created_at = new Date();
newComment.subComments = []; newComment.subComments = [];
setInputsValue((prevValue) => ({ ...prevValue, comment: "" })); setInputsValue((prevValue) => ({ ...prevValue, comment: "" }));
@ -538,54 +538,54 @@ export const TicketFullScreen = () => {
const path = event.path || (event.composedPath && event.composedPath()); const path = event.path || (event.composedPath && event.composedPath());
if ( if (
event && event &&
!path.find( !path.find(
(div) => (div) =>
div.classList && div.classList &&
(div.classList.contains("button-add-worker") || (div.classList.contains("button-add-worker") ||
div.classList.contains("dropdownList")) div.classList.contains("dropdownList"))
) )
) { ) {
setDropListOpen(false); setDropListOpen(false);
setDropListMembersOpen(false) setDropListMembersOpen(false);
} }
if ( if (
event && event &&
!path.find( !path.find(
(div) => (div) =>
div.classList && div.classList &&
(div.classList.contains("deadLine") || (div.classList.contains("deadLine") ||
div.classList.contains("react-datepicker-popper")) div.classList.contains("react-datepicker-popper"))
) )
) { ) {
setDatePickerOpen(false) setDatePickerOpen(false);
} }
if ( if (
event && event &&
!path.find( !path.find(
(div) => (div) =>
div.classList && div.classList &&
(div.classList.contains("tags") || (div.classList.contains("tags") ||
div.classList.contains("tags__dropDown")) div.classList.contains("tags__dropDown"))
) )
) { ) {
setSelectTagsOpen(false) setSelectTagsOpen(false);
} }
if ( if (
event && event &&
!path.find( !path.find(
(div) => (div) =>
div.classList && div.classList &&
(div.classList.contains("addPerson") || (div.classList.contains("addPerson") ||
div.classList.contains("persons__list")) div.classList.contains("persons__list"))
) )
) { ) {
setPersonListOpen(false) setPersonListOpen(false);
} }
} };
return ( return (
<section className="ticket-full-screen"> <section className="ticket-full-screen">
@ -882,7 +882,12 @@ export const TicketFullScreen = () => {
})); }));
}} }}
/> />
<img className={commentSendDisable ? 'disable' : ''} src={send} onClick={createComment} alt="send"></img> <img
className={commentSendDisable ? "disable" : ""}
src={send}
onClick={createComment}
alt="send"
></img>
</div> </div>
<div className="comments__list"> <div className="comments__list">
{comments.map((comment) => { {comments.map((comment) => {

View File

@ -90,7 +90,7 @@ export const ProjectTracker = () => {
useEffect(() => { useEffect(() => {
dispatch(activeLoader()); dispatch(activeLoader());
dispatch(setProjectBoardFetch(projectId.id)); dispatch(setProjectBoardFetch(projectId.id));
initListeners() initListeners();
}, []); }, []);
useEffect(() => { useEffect(() => {
@ -362,37 +362,37 @@ export const ProjectTracker = () => {
const path = event.path || (event.composedPath && event.composedPath()); const path = event.path || (event.composedPath && event.composedPath());
if ( if (
event && event &&
!path.find( !path.find(
(div) => (div) =>
div.classList && div.classList &&
(div.classList.contains("addPerson") || (div.classList.contains("addPerson") ||
div.classList.contains("persons__list")) div.classList.contains("persons__list"))
) )
) { ) {
setPersonListOpen(false); setPersonListOpen(false);
} }
if ( if (
event && event &&
!path.find( !path.find(
(div) => (div) =>
div.classList && div.classList &&
(div.classList.contains("tasks__head__executor") || (div.classList.contains("tasks__head__executor") ||
div.classList.contains("tasks__head__executorDropdown")) div.classList.contains("tasks__head__executorDropdown"))
) )
) { ) {
setSelectedExecutorOpen(false); setSelectedExecutorOpen(false);
} }
if ( if (
event && event &&
!path.find( !path.find(
(div) => (div) =>
div.classList && div.classList &&
(div.classList.contains("tasks__head__tags") || (div.classList.contains("tasks__head__tags") ||
div.classList.contains("tags__list")) div.classList.contains("tags__list"))
) )
) { ) {
setTags({ setTags({
open: false, open: false,
@ -402,21 +402,21 @@ export const ProjectTracker = () => {
} }
if ( if (
event && event &&
!path.find( !path.find(
(div) => (div) =>
div.classList && div.classList &&
(div.classList.contains("board__head__more") || (div.classList.contains("board__head__more") ||
div.classList.contains("column__select")) div.classList.contains("column__select"))
) )
) { ) {
setOpenColumnSelect((prevState) => { setOpenColumnSelect((prevState) => {
const newState = {} const newState = {};
for (const key in prevState) { for (const key in prevState) {
newState[key] = false; newState[key] = false;
} }
return newState; return newState;
}) });
} }
}; };