modal accept with notifications

This commit is contained in:
2023-07-14 03:03:49 +03:00
parent 001920a840
commit 7c7ea86c8c
9 changed files with 155 additions and 112 deletions

View File

@ -2,23 +2,32 @@ import React from "react";
import close from "assets/icons/closeProjectPersons.svg";
import './acceptModal.scss'
import "./acceptModal.scss";
export const AcceptModal = ({closeModal, agreeHandler}) => {
return (
<div className='backDrop'>
<div className='acceptModal'>
<h3 className='acceptModal__title'>
Вы точно хотите переместить задачу в архив?
</h3>
<div className='acceptModal__buttons'>
<button className='agree' onClick={agreeHandler}>Да</button>
<button className='cancel' onClick={closeModal}>Нет</button>
</div>
<img className='acceptModal__close' src={close} alt='close' onClick={closeModal} />
</div>
export const AcceptModal = ({ closeModal, agreeHandler }) => {
return (
<div className="backDrop">
<div className="acceptModal">
<h3 className="acceptModal__title">
Вы точно хотите переместить задачу в архив?
</h3>
<div className="acceptModal__buttons">
<button className="agree" onClick={agreeHandler}>
Да
</button>
<button className="cancel" onClick={closeModal}>
Нет
</button>
</div>
)
}
<img
className="acceptModal__close"
src={close}
alt="close"
onClick={closeModal}
/>
</div>
</div>
);
};
export default AcceptModal
export default AcceptModal;

View File

@ -9,7 +9,6 @@ import { Link } from "react-router-dom";
import { getProfileInfo } from "@redux/outstaffingSlice";
import { setProjectBoardFetch } from "@redux/projectsTrackerSlice";
import { useNotification } from "@hooks/useNotification";
import {
backendImg,
@ -21,9 +20,11 @@ import {
import { apiRequest } from "@api/request";
import { useNotification } from "@hooks/useNotification";
import AcceptModal from "@components/Modal/AcceptModal/AcceptModal";
import TrackerModal from "@components/Modal/Tracker/TrackerModal/TrackerModal";
import TrackerTaskComment from "@components/TrackerTaskComment/TrackerTaskComment";
import AcceptModal from "@components/Modal/AcceptModal/AcceptModal";
import archive from "assets/icons/archive.svg";
import arrow from "assets/icons/arrows/arrowStart.png";
@ -84,8 +85,8 @@ export const ModalTiсket = ({
const [correctProjectUsers, setCorrectProjectUsers] = useState(projectUsers);
const [executorId, setExecutorId] = useState(task.executor_id);
const profileInfo = useSelector(getProfileInfo);
const [acceptModalOpen, setAcceptModalOpen] = useState(false)
const { showNotification } = useNotification()
const [acceptModalOpen, setAcceptModalOpen] = useState(false);
const { showNotification } = useNotification();
function deleteTask() {
apiRequest("/task/update-task", {
@ -97,12 +98,16 @@ export const ModalTiсket = ({
}).then(() => {
setActive(false);
dispatch(setProjectBoardFetch(projectId));
showNotification({show: true, text: 'Задача успешно была перемещена в архив', type: 'archive'})
showNotification({
show: true,
text: "Задача успешно была перемещена в архив",
type: "archive",
});
});
}
function archiveTask () {
setAcceptModalOpen(true)
function archiveTask() {
setAcceptModalOpen(true);
}
function editTask() {
@ -425,7 +430,11 @@ export const ModalTiсket = ({
navigator.clipboard.writeText(
`https://itguild.info/tracker/task/${task.id}`
);
showNotification({show: true, text: 'Ссылка скопирована в буфер обмена', type: 'copy'})
showNotification({
show: true,
text: "Ссылка скопирована в буфер обмена",
type: "copy",
});
}
function selectDeadLine(date) {
@ -440,8 +449,8 @@ export const ModalTiсket = ({
});
}
function closeAcceptModal () {
setAcceptModalOpen(false)
function closeAcceptModal() {
setAcceptModalOpen(false);
}
return (
@ -833,12 +842,12 @@ export const ModalTiсket = ({
</div>
</div>
</div>
{acceptModalOpen &&
<AcceptModal
closeModal={closeAcceptModal}
agreeHandler={deleteTask}
/>
}
{acceptModalOpen && (
<AcceptModal
closeModal={closeAcceptModal}
agreeHandler={deleteTask}
/>
)}
</div>
<TrackerModal
active={addSubtask}

View File

@ -26,12 +26,12 @@ import { apiRequest } from "@api/request";
import { getCorrectDate } from "@components/Calendar/calendarHelper";
import { Footer } from "@components/Common/Footer/Footer";
import { Loader } from "@components/Common/Loader/Loader";
import AcceptModal from "@components/Modal/AcceptModal/AcceptModal";
import TrackerModal from "@components/Modal/Tracker/TrackerModal/TrackerModal";
import { Navigation } from "@components/Navigation/Navigation";
import { ProfileBreadcrumbs } from "@components/ProfileBreadcrumbs/ProfileBreadcrumbs";
import { ProfileHeader } from "@components/ProfileHeader/ProfileHeader";
import TrackerTaskComment from "@components/TrackerTaskComment/TrackerTaskComment";
import AcceptModal from "@components/Modal/AcceptModal/AcceptModal";
import arrow from "assets/icons/arrows/arrowCalendar.png";
import arrowStart from "assets/icons/arrows/arrowStart.png";
@ -83,7 +83,7 @@ export const TicketFullScreen = () => {
const [startDate, setStartDate] = useState(null);
const [uploadedFile, setUploadedFile] = useState(null);
const [taskFiles, setTaskFiles] = useState([]);
const [acceptModalOpen, setAcceptModalOpen] = useState(false)
const [acceptModalOpen, setAcceptModalOpen] = useState(false);
useEffect(() => {
apiRequest(`/task/get-task?task_id=${ticketId.id}`).then((taskInfo) => {
@ -163,8 +163,8 @@ export const TicketFullScreen = () => {
});
}
function archiveTask () {
setAcceptModalOpen(true)
function archiveTask() {
setAcceptModalOpen(true);
}
function editTask() {
@ -456,8 +456,8 @@ export const TicketFullScreen = () => {
});
}
function closeAcceptModal () {
setAcceptModalOpen(false)
function closeAcceptModal() {
setAcceptModalOpen(false);
}
return (
@ -1000,12 +1000,9 @@ export const TicketFullScreen = () => {
</>
)}
</div>
{acceptModalOpen &&
<AcceptModal
closeModal={closeAcceptModal}
agreeHandler={deleteTask}
/>
}
{acceptModalOpen && (
<AcceptModal closeModal={closeAcceptModal} agreeHandler={deleteTask} />
)}
<Footer />
</section>
);

View File

@ -23,6 +23,8 @@ import { urlForLocal } from "@utils/helper";
import { apiRequest } from "@api/request";
import { useNotification } from "@hooks/useNotification";
import BaseButton from "@components/Common/BaseButton/BaseButton";
import ModalLayout from "@components/Common/ModalLayout/ModalLayout";
@ -30,7 +32,6 @@ import arrowDown from "assets/icons/arrows/selectArrow.png";
import avatarMok from "assets/images/avatarMok.png";
import "./trackerModal.scss";
import {useNotification} from "@hooks/useNotification";
export const TrackerModal = ({
active,
@ -68,11 +69,11 @@ export const TrackerModal = ({
const [correctProjectUsers, setCorrectProjectUsers] = useState([]);
const [selectColumnPriorityOpen, setSelectColumnPriorityOpen] =
useState(false);
const { showNotification } = useNotification()
const { showNotification } = useNotification();
function createTab() {
if (!valueColumn) {
showNotification({show: true, text: 'Введите название', type: 'error'})
showNotification({ show: true, text: "Введите название", type: "error" });
return;
}
@ -94,7 +95,11 @@ export const TrackerModal = ({
function createTiket() {
if (!valueTiket || !descriptionTicket) {
showNotification({show: true, text: 'Введите название и описание', type: 'error'})
showNotification({
show: true,
text: "Введите название и описание",
type: "error",
});
return;
}
@ -111,7 +116,11 @@ export const TrackerModal = ({
},
}).then((res) => {
if (res.status === 500) {
showNotification({show: true, text: 'Задача с таким именем уже существует', type: 'error'})
showNotification({
show: true,
text: "Задача с таким именем уже существует",
type: "error",
});
} else {
if (selectedExecutorTask.user_id) {
apiRequest("/task/update-task", {
@ -133,7 +142,11 @@ export const TrackerModal = ({
setDescriptionTicket("Описание задачи");
dispatch(setProjectBoardFetch(projectBoard.id));
}
showNotification({show: true, text: 'Задача создана', type: 'success'})
showNotification({
show: true,
text: "Задача создана",
type: "success",
});
}
});
}
@ -219,7 +232,11 @@ export const TrackerModal = ({
setActive(false);
setNameProject("");
} else {
showNotification({show: true, text: 'Проект с таким именем уже существует', type: 'error'})
showNotification({
show: true,
text: "Проект с таким именем уже существует",
type: "error",
});
}
});
}