pop-up notifications

This commit is contained in:
2024-03-12 16:14:44 +03:00
parent 8797ba0778
commit 727d55798a
12 changed files with 186 additions and 40 deletions

View File

@ -4,10 +4,15 @@ import { backendImg } from "@utils/helper";
import { apiRequest } from "@api/request";
import { useNotification } from "@hooks/useNotification";
import close from "assets/icons/closeProjectPersons.svg";
const FileTracker = ({ file, setDeletedTask, taskId }) => {
const [openImg, setOpenImg] = useState(false);
const { showNotification } = useNotification();
function deleteFile(file) {
apiRequest("/file/detach", {
method: "DELETE",
@ -17,9 +22,22 @@ const FileTracker = ({ file, setDeletedTask, taskId }) => {
entity_id: taskId,
status: 0
}
}).then(() => {
setDeletedTask(file);
});
})
.then(() => {
setDeletedTask(file);
showNotification({
show: true,
text: "Файл успешно удален",
type: "success"
});
})
.catch(() => {
showNotification({
show: true,
text: "Ошибка при удалении файла",
type: "error"
});
});
}
return (

View File

@ -7,6 +7,8 @@ import withReactContent from "sweetalert2-react-content";
import { apiRequest } from "@api/request";
import { useNotification } from "@hooks/useNotification";
import { Loader } from "@components/Common/Loader/Loader";
import "./form.scss";
@ -18,6 +20,8 @@ const Form = () => {
const urlParams = useParams();
const { showNotification } = useNotification();
const [status, setStatus] = useState(null);
const [data, setData] = useState({
email: "",
@ -75,10 +79,23 @@ const Form = () => {
profile_id: urlParams.id,
...data
}
}).then((res) => {
setStatus(res);
setIsFetching(false);
});
})
.then((res) => {
setStatus(res);
setIsFetching(false);
showNotification({
show: true,
text: "Отправка успешно завершена",
type: "success"
});
})
.catch(() => {
showNotification({
show: true,
text: "Ошибка отправки",
type: "error"
});
});
};
return (

View File

@ -10,6 +10,8 @@ import { caseOfNum, removeLast, urlForLocal } from "@utils/helper";
import { apiRequest } from "@api/request";
import { useNotification } from "@hooks/useNotification";
import ModalLayout from "@components/Common/ModalLayout/ModalLayout";
import close from "assets/icons/close.png";
@ -24,6 +26,7 @@ const ListEmployees = ({
setModalAdd
}) => {
const dispatch = useDispatch();
const { showNotification } = useNotification();
function deletePerson(userId) {
apiRequest("/project/del-user", {
@ -32,9 +35,22 @@ const ListEmployees = ({
project_id: projectBoard.id,
user_id: userId
}
}).then(() => {
dispatch(deletePersonOnProject(userId));
});
})
.then(() => {
dispatch(deletePersonOnProject(userId));
showNotification({
show: true,
text: "Участник успешно удален",
type: "success"
});
})
.catch(() => {
showNotification({
show: true,
text: "Ошибка удаления участника",
type: "error"
});
});
}
return (

View File

@ -118,15 +118,23 @@ export const ModalTiсket = ({
task_id: task.id,
status: 0
}
}).then(() => {
closeModal();
dispatch(setProjectBoardFetch(projectId));
showNotification({
show: true,
text: "Задача успешно была перемещена в архив",
type: "archive"
})
.then(() => {
closeModal();
dispatch(setProjectBoardFetch(projectId));
showNotification({
show: true,
text: "Задача успешно удалена",
type: "success"
});
})
.catch(() => {
showNotification({
show: true,
text: "Ошибка удаления",
type: "error"
});
});
});
}
const priority = {
@ -169,15 +177,23 @@ export const ModalTiсket = ({
title: inputsValue.title,
description: inputsValue.description
}
}).then((res) => {
setEditOpen(!editOpen);
dispatch(setProjectBoardFetch(projectId));
showNotification({
show: true,
text: "Изменения сохранены",
type: "success"
})
.then((res) => {
setEditOpen(!editOpen);
dispatch(setProjectBoardFetch(projectId));
showNotification({
show: true,
text: "Изменения сохранены",
type: "success"
});
})
.catch(() => {
showNotification({
show: true,
text: "Ошибка при сохранении изменений",
type: "error"
});
});
});
}
function createComment() {

View File

@ -137,14 +137,22 @@ export const TrackerModal = ({
: 1,
title: valueColumn
}
}).then(() => {
dispatch(setProjectBoardFetch(projectBoard.id));
showNotification({
show: true,
text: "Колонка создана",
type: "success"
})
.then(() => {
dispatch(setProjectBoardFetch(projectBoard.id));
showNotification({
show: true,
text: "Колонка успешно создана",
type: "success"
});
})
.catch(() => {
showNotification({
show: true,
text: "Ошибка при создании колонки",
type: "error"
});
});
});
setValueColumn("");
setActive(false);
}
@ -221,7 +229,7 @@ export const TrackerModal = ({
setDeadLineDate("");
showNotification({
show: true,
text: "Задача создана",
text: "Задача успешно создана",
type: "success"
});
}
@ -295,7 +303,7 @@ export const TrackerModal = ({
dispatch(editColumnName({ id: columnId, title: columnName }));
showNotification({
show: true,
text: "Колонка создана",
text: "Колонка успешно изменена",
type: "success"
});
});
@ -316,6 +324,11 @@ export const TrackerModal = ({
dispatch(setProject(result));
setActive(false);
setNameProject("");
showNotification({
show: true,
text: "Проект успешно создан",
type: "success"
});
} else {
showNotification({
show: true,

View File

@ -34,6 +34,11 @@ export const QuizPassingInformation = ({ setStartTest, uuid, timer }) => {
}
dispatch(setQuestions(res));
setStartTest(true);
showNotification({
show: true,
text: "Тест успешно запущен",
type: "success"
});
restart(
moment()
.add(res[0]?.time_limit.split(":")[0], "hours")