prettier fixed
This commit is contained in:
@ -1,13 +1,10 @@
|
||||
import React from "react";
|
||||
|
||||
import "./basebutton.scss"
|
||||
import "./basebutton.scss";
|
||||
|
||||
export const BaseButton = ({ children, styles, ...props }) => {
|
||||
return (
|
||||
<button
|
||||
className={styles ? `${styles} button` : "button"}
|
||||
{...props}
|
||||
>
|
||||
<button className={styles ? `${styles} button` : "button"} {...props}>
|
||||
{children}
|
||||
</button>
|
||||
);
|
||||
|
@ -1,24 +1,23 @@
|
||||
import React, {useEffect, useState} from "react";
|
||||
|
||||
import React, { useEffect, useState } from "react";
|
||||
import { useDispatch, useSelector } from "react-redux";
|
||||
|
||||
import { apiRequest } from "../../../api/request";
|
||||
import { urlForLocal } from '../../../utils/helper'
|
||||
import arrowDown from "../../../assets/icons/arrows/selectArrow.png";
|
||||
import {
|
||||
setColumnName,
|
||||
setColumnPriority,
|
||||
addPersonToProject,
|
||||
editColumnName,
|
||||
editProjectName,
|
||||
getColumnId,
|
||||
getColumnName,
|
||||
getColumnPriority,
|
||||
getProjectBoard,
|
||||
getValueModalType,
|
||||
setColumnName,
|
||||
setColumnPriority,
|
||||
setProject,
|
||||
setProjectBoardFetch,
|
||||
editProjectName,
|
||||
editColumnName,
|
||||
getColumnName,
|
||||
getColumnId,
|
||||
addPersonToProject, getColumnPriority
|
||||
} from "../../../redux/projectsTrackerSlice";
|
||||
|
||||
import arrowDown from "../../../assets/icons/arrows/selectArrow.png"
|
||||
|
||||
import { urlForLocal } from "../../../utils/helper";
|
||||
import "./trackerModal.scss";
|
||||
|
||||
export const TrackerModal = ({
|
||||
@ -33,8 +32,8 @@ export const TrackerModal = ({
|
||||
const dispatch = useDispatch();
|
||||
const projectBoard = useSelector(getProjectBoard);
|
||||
const columnName = useSelector(getColumnName);
|
||||
const columnId = useSelector(getColumnId)
|
||||
const columnPriority = useSelector(getColumnPriority)
|
||||
const columnId = useSelector(getColumnId);
|
||||
const columnPriority = useSelector(getColumnPriority);
|
||||
|
||||
const modalType = useSelector(getValueModalType);
|
||||
const [projectName, setProjectName] = useState(defautlInput);
|
||||
@ -42,9 +41,9 @@ export const TrackerModal = ({
|
||||
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)
|
||||
const [workers, setWorkers] = useState([]);
|
||||
const [selectWorkersOpen, setSelectWorkersOpen] = useState(false);
|
||||
const [selectedWorker, setSelectedWorker] = useState(null);
|
||||
|
||||
function createTab() {
|
||||
if (!valueColumn) {
|
||||
@ -55,7 +54,9 @@ export const TrackerModal = ({
|
||||
method: "POST",
|
||||
data: {
|
||||
project_id: projectBoard.id,
|
||||
priority: projectBoard.columns.length ? projectBoard.columns.at(-1).priority + 1 : 1,
|
||||
priority: projectBoard.columns.length
|
||||
? projectBoard.columns.at(-1).priority + 1
|
||||
: 1,
|
||||
title: valueColumn,
|
||||
},
|
||||
}).then(() => {
|
||||
@ -106,36 +107,38 @@ export const TrackerModal = ({
|
||||
function changeColumnParams() {
|
||||
projectBoard.columns.forEach((column) => {
|
||||
if (column.id === columnId && column.priority !== columnPriority) {
|
||||
const priorityColumns = [{
|
||||
column_id: column.id,
|
||||
priority: Number(columnPriority)
|
||||
}]
|
||||
const priorityColumns = [
|
||||
{
|
||||
column_id: column.id,
|
||||
priority: Number(columnPriority),
|
||||
},
|
||||
];
|
||||
for (let i = column.priority; i < columnPriority; i++) {
|
||||
const currentColumn = {
|
||||
column_id: projectBoard.columns[i].id,
|
||||
priority: i
|
||||
}
|
||||
priorityColumns.push(currentColumn)
|
||||
priority: i,
|
||||
};
|
||||
priorityColumns.push(currentColumn);
|
||||
}
|
||||
for (let i = column.priority; i > columnPriority; i--) {
|
||||
const currentColumn = {
|
||||
column_id: projectBoard.columns[i - 2].id,
|
||||
priority: i
|
||||
}
|
||||
priorityColumns.push(currentColumn)
|
||||
priority: i,
|
||||
};
|
||||
priorityColumns.push(currentColumn);
|
||||
}
|
||||
apiRequest("/project-column/set-priority", {
|
||||
method: "POST",
|
||||
data: {
|
||||
project_id: projectBoard.id,
|
||||
data: JSON.stringify(priorityColumns)
|
||||
}
|
||||
data: JSON.stringify(priorityColumns),
|
||||
},
|
||||
}).then(() => {
|
||||
dispatch(setProjectBoardFetch(projectBoard.id));
|
||||
})
|
||||
});
|
||||
}
|
||||
})
|
||||
changeColumnTitle()
|
||||
});
|
||||
changeColumnTitle();
|
||||
}
|
||||
|
||||
function changeColumnTitle() {
|
||||
@ -376,12 +379,12 @@ export const TrackerModal = ({
|
||||
<h4>Приоритет колонки</h4>
|
||||
<div className="input-container">
|
||||
<input
|
||||
className="name-project"
|
||||
placeholder='Приоритет колонки'
|
||||
type='number'
|
||||
step='1'
|
||||
value={columnPriority}
|
||||
onChange={(e) => dispatch(setColumnPriority(e.target.value))}
|
||||
className="name-project"
|
||||
placeholder="Приоритет колонки"
|
||||
type="number"
|
||||
step="1"
|
||||
value={columnPriority}
|
||||
onChange={(e) => dispatch(setColumnPriority(e.target.value))}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -1,129 +1,161 @@
|
||||
import React, { useState } from "react";
|
||||
import TrackerTaskSubComment from "../TrackerTaskComment/TrackerTaskComment";
|
||||
|
||||
import { apiRequest } from "../../api/request";
|
||||
import {urlForLocal} from '../../utils/helper';
|
||||
import {getCorrectDate} from "../Calendar/calendarHelper";
|
||||
import edit from "../../assets/icons/edit.svg";
|
||||
import del from "../../assets/icons/delete.svg";
|
||||
import edit from "../../assets/icons/edit.svg";
|
||||
import accept from "../../assets/images/accept.png";
|
||||
import { urlForLocal } from "../../utils/helper";
|
||||
import { getCorrectDate } from "../Calendar/calendarHelper";
|
||||
import TrackerTaskSubComment from "../TrackerTaskComment/TrackerTaskComment";
|
||||
|
||||
export const TrackerTaskComment = ({
|
||||
taskId,
|
||||
comment,
|
||||
commentDelete,
|
||||
addSubComment,
|
||||
subCommentDelete
|
||||
taskId,
|
||||
comment,
|
||||
commentDelete,
|
||||
addSubComment,
|
||||
subCommentDelete,
|
||||
}) => {
|
||||
const [commentsEditOpen, setCommentsEditOpen] = useState(false)
|
||||
const [commentsEditText, setCommentsEditText] = useState(comment.text)
|
||||
const [subCommentsCreateOpen, setSubCommentsCreateOpen] = useState(false)
|
||||
const [subCommentsCreateText, setSubCommentsCreateText] = useState('')
|
||||
const [commentsEditOpen, setCommentsEditOpen] = useState(false);
|
||||
const [commentsEditText, setCommentsEditText] = useState(comment.text);
|
||||
const [subCommentsCreateOpen, setSubCommentsCreateOpen] = useState(false);
|
||||
const [subCommentsCreateText, setSubCommentsCreateText] = useState("");
|
||||
|
||||
function editComment() {
|
||||
if (commentsEditText === comment.text) return
|
||||
apiRequest("/comment/update", {
|
||||
method: "PUT",
|
||||
data: {
|
||||
comment_id: comment.id,
|
||||
text: commentsEditText
|
||||
}
|
||||
}).then(() => {
|
||||
})
|
||||
}
|
||||
function editComment() {
|
||||
if (commentsEditText === comment.text) return;
|
||||
apiRequest("/comment/update", {
|
||||
method: "PUT",
|
||||
data: {
|
||||
comment_id: comment.id,
|
||||
text: commentsEditText,
|
||||
},
|
||||
}).then(() => {});
|
||||
}
|
||||
|
||||
function deleteComment() {
|
||||
apiRequest("/comment/update", {
|
||||
method: "PUT",
|
||||
data: {
|
||||
comment_id: comment.id,
|
||||
status: 0
|
||||
}
|
||||
}).then(() => {
|
||||
if (comment.parent_id) {
|
||||
subCommentDelete(comment)
|
||||
} else {
|
||||
commentDelete(comment)
|
||||
}
|
||||
})
|
||||
}
|
||||
function deleteComment() {
|
||||
apiRequest("/comment/update", {
|
||||
method: "PUT",
|
||||
data: {
|
||||
comment_id: comment.id,
|
||||
status: 0,
|
||||
},
|
||||
}).then(() => {
|
||||
if (comment.parent_id) {
|
||||
subCommentDelete(comment);
|
||||
} else {
|
||||
commentDelete(comment);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function createSubComment() {
|
||||
setSubCommentsCreateOpen(false)
|
||||
if(!subCommentsCreateText) return
|
||||
apiRequest("/comment/create", {
|
||||
method: "POST",
|
||||
data: {
|
||||
text: subCommentsCreateText,
|
||||
entity_type: 2,
|
||||
entity_id: taskId,
|
||||
parent_id: comment.id
|
||||
}
|
||||
}).then((res) => {
|
||||
let newSubComment = res
|
||||
newSubComment.created_at = new Date()
|
||||
setSubCommentsCreateText('')
|
||||
addSubComment(comment.id, newSubComment)
|
||||
})
|
||||
}
|
||||
function createSubComment() {
|
||||
setSubCommentsCreateOpen(false);
|
||||
if (!subCommentsCreateText) return;
|
||||
apiRequest("/comment/create", {
|
||||
method: "POST",
|
||||
data: {
|
||||
text: subCommentsCreateText,
|
||||
entity_type: 2,
|
||||
entity_id: taskId,
|
||||
parent_id: comment.id,
|
||||
},
|
||||
}).then((res) => {
|
||||
let newSubComment = res;
|
||||
newSubComment.created_at = new Date();
|
||||
setSubCommentsCreateText("");
|
||||
addSubComment(comment.id, newSubComment);
|
||||
});
|
||||
}
|
||||
|
||||
return (
|
||||
<div className={[!comment.parent_id && comment.subComments.length ? 'comments__list__item__main': '',
|
||||
'comments__list__item',
|
||||
comment.parent_id ? 'comments__list__item__subComment' : ''].join(' ')}>
|
||||
<div className='comments__list__item__info'>
|
||||
<div className='comments__list__item__fio'>
|
||||
<img src={urlForLocal(comment.user.avatar)} alt='avatar' />
|
||||
<p>{comment.user.fio}</p>
|
||||
</div>
|
||||
<div className='comments__list__item__date'>
|
||||
<span>{getCorrectDate(comment.created_at)}</span>
|
||||
{comment.user_id === Number(localStorage.getItem('id')) &&
|
||||
<>
|
||||
<div className={commentsEditOpen ? 'edit edit__open' : 'edit'} >
|
||||
<img src={edit} alt='edit' onClick={() => {
|
||||
if (commentsEditOpen) {
|
||||
editComment()
|
||||
}
|
||||
setCommentsEditOpen(!commentsEditOpen)
|
||||
}} />
|
||||
</div>
|
||||
<img src={del} alt='delete' onClick={() => deleteComment()} />
|
||||
</>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
{commentsEditOpen ?
|
||||
<input className='comments__list__item__text' value={commentsEditText} onChange={(e) => {
|
||||
setCommentsEditText(e.target.value)
|
||||
}} /> :
|
||||
<p className='comments__list__item__text'>{commentsEditText}</p>}
|
||||
{!comment.parent_id &&
|
||||
<>
|
||||
{
|
||||
subCommentsCreateOpen ?
|
||||
<div className='comments__list__item__answer__new'>
|
||||
<input value={subCommentsCreateText} onChange={(e) => {
|
||||
setSubCommentsCreateText(e.target.value)
|
||||
}}/>
|
||||
<img src={accept} alt='accept'
|
||||
onClick={() => {
|
||||
createSubComment()
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
:
|
||||
<span onClick={() => {
|
||||
setSubCommentsCreateOpen(true)
|
||||
}} className='comments__list__item__answer'>Ответить</span>
|
||||
}
|
||||
</>
|
||||
}
|
||||
{Boolean(comment.subComments?.length) && comment.subComments.map((subComment) => {
|
||||
return <TrackerTaskSubComment key={subComment.id} taskId={taskId} comment={subComment} subCommentDelete={subCommentDelete}/>
|
||||
})
|
||||
}
|
||||
return (
|
||||
<div
|
||||
className={[
|
||||
!comment.parent_id && comment.subComments.length
|
||||
? "comments__list__item__main"
|
||||
: "",
|
||||
"comments__list__item",
|
||||
comment.parent_id ? "comments__list__item__subComment" : "",
|
||||
].join(" ")}
|
||||
>
|
||||
<div className="comments__list__item__info">
|
||||
<div className="comments__list__item__fio">
|
||||
<img src={urlForLocal(comment.user.avatar)} alt="avatar" />
|
||||
<p>{comment.user.fio}</p>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
<div className="comments__list__item__date">
|
||||
<span>{getCorrectDate(comment.created_at)}</span>
|
||||
{comment.user_id === Number(localStorage.getItem("id")) && (
|
||||
<>
|
||||
<div className={commentsEditOpen ? "edit edit__open" : "edit"}>
|
||||
<img
|
||||
src={edit}
|
||||
alt="edit"
|
||||
onClick={() => {
|
||||
if (commentsEditOpen) {
|
||||
editComment();
|
||||
}
|
||||
setCommentsEditOpen(!commentsEditOpen);
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
<img src={del} alt="delete" onClick={() => deleteComment()} />
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
{commentsEditOpen ? (
|
||||
<input
|
||||
className="comments__list__item__text"
|
||||
value={commentsEditText}
|
||||
onChange={(e) => {
|
||||
setCommentsEditText(e.target.value);
|
||||
}}
|
||||
/>
|
||||
) : (
|
||||
<p className="comments__list__item__text">{commentsEditText}</p>
|
||||
)}
|
||||
{!comment.parent_id && (
|
||||
<>
|
||||
{subCommentsCreateOpen ? (
|
||||
<div className="comments__list__item__answer__new">
|
||||
<input
|
||||
value={subCommentsCreateText}
|
||||
onChange={(e) => {
|
||||
setSubCommentsCreateText(e.target.value);
|
||||
}}
|
||||
/>
|
||||
<img
|
||||
src={accept}
|
||||
alt="accept"
|
||||
onClick={() => {
|
||||
createSubComment();
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
) : (
|
||||
<span
|
||||
onClick={() => {
|
||||
setSubCommentsCreateOpen(true);
|
||||
}}
|
||||
className="comments__list__item__answer"
|
||||
>
|
||||
Ответить
|
||||
</span>
|
||||
)}
|
||||
</>
|
||||
)}
|
||||
{Boolean(comment.subComments?.length) &&
|
||||
comment.subComments.map((subComment) => {
|
||||
return (
|
||||
<TrackerTaskSubComment
|
||||
key={subComment.id}
|
||||
taskId={taskId}
|
||||
comment={subComment}
|
||||
subCommentDelete={subCommentDelete}
|
||||
/>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default TrackerTaskComment
|
||||
export default TrackerTaskComment;
|
||||
|
Reference in New Issue
Block a user