From 727d55798a061a505c6807a3a27b6a1a653c6c2a Mon Sep 17 00:00:00 2001 From: Gubar Nikita Date: Tue, 12 Mar 2024 16:14:44 +0300 Subject: [PATCH] pop-up notifications --- package-lock.json | 10 ++-- src/components/FileTracker/FileTracker.jsx | 24 ++++++++-- src/components/Form/Form.jsx | 25 ++++++++-- .../Tracker/ListEmployees/ListEmployees.jsx | 22 +++++++-- .../Modal/Tracker/ModalTicket/ModalTicket.jsx | 48 ++++++++++++------- .../Tracker/TrackerModal/TrackerModal.jsx | 31 ++++++++---- .../quiz/Quiz-passing-information.jsx | 5 ++ .../PartnerAddRequest/PartnerAddRequest.jsx | 13 +++++ src/pages/PartnerBid/PartnerBid.jsx | 8 ++++ src/pages/ProjectTracker/ProjectTracker.jsx | 21 +++++++- src/pages/Summary/Summary.jsx | 11 ++++- src/pages/ViewReport/ViewReport.jsx | 8 ++++ 12 files changed, 186 insertions(+), 40 deletions(-) diff --git a/package-lock.json b/package-lock.json index 5818c71a..c747c6c0 100644 --- a/package-lock.json +++ b/package-lock.json @@ -8148,9 +8148,9 @@ } }, "node_modules/caniuse-lite": { - "version": "1.0.30001458", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001458.tgz", - "integrity": "sha512-lQ1VlUUq5q9ro9X+5gOEyH7i3vm+AYVT1WDCVB69XOZ17KZRhnZ9J0Sqz7wTHQaLBJccNCHq8/Ww5LlOIZbB0w==", + "version": "1.0.30001597", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001597.tgz", + "integrity": "sha512-7LjJvmQU6Sj7bL0j5b5WY/3n7utXUJvAe1lxhsHDbLmwX9mdL86Yjtr+5SRCyf8qME4M7pU2hswj0FpyBVCv9w==", "funding": [ { "type": "opencollective", @@ -8159,6 +8159,10 @@ { "type": "tidelift", "url": "https://tidelift.com/funding/github/npm/caniuse-lite" + }, + { + "type": "github", + "url": "https://github.com/sponsors/ai" } ] }, diff --git a/src/components/FileTracker/FileTracker.jsx b/src/components/FileTracker/FileTracker.jsx index 62ae64c7..02b5f570 100644 --- a/src/components/FileTracker/FileTracker.jsx +++ b/src/components/FileTracker/FileTracker.jsx @@ -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 ( diff --git a/src/components/Form/Form.jsx b/src/components/Form/Form.jsx index dbe43cbd..77e04a19 100644 --- a/src/components/Form/Form.jsx +++ b/src/components/Form/Form.jsx @@ -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 ( diff --git a/src/components/Modal/Tracker/ListEmployees/ListEmployees.jsx b/src/components/Modal/Tracker/ListEmployees/ListEmployees.jsx index ab220748..4709cfa6 100644 --- a/src/components/Modal/Tracker/ListEmployees/ListEmployees.jsx +++ b/src/components/Modal/Tracker/ListEmployees/ListEmployees.jsx @@ -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 ( diff --git a/src/components/Modal/Tracker/ModalTicket/ModalTicket.jsx b/src/components/Modal/Tracker/ModalTicket/ModalTicket.jsx index 89d197fe..fe91c37e 100644 --- a/src/components/Modal/Tracker/ModalTicket/ModalTicket.jsx +++ b/src/components/Modal/Tracker/ModalTicket/ModalTicket.jsx @@ -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() { diff --git a/src/components/Modal/Tracker/TrackerModal/TrackerModal.jsx b/src/components/Modal/Tracker/TrackerModal/TrackerModal.jsx index 34dc7400..569a9abb 100644 --- a/src/components/Modal/Tracker/TrackerModal/TrackerModal.jsx +++ b/src/components/Modal/Tracker/TrackerModal/TrackerModal.jsx @@ -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, diff --git a/src/components/features/quiz/Quiz-passing-information.jsx b/src/components/features/quiz/Quiz-passing-information.jsx index ff1f3b73..4709f2e3 100644 --- a/src/components/features/quiz/Quiz-passing-information.jsx +++ b/src/components/features/quiz/Quiz-passing-information.jsx @@ -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") diff --git a/src/pages/PartnerAddRequest/PartnerAddRequest.jsx b/src/pages/PartnerAddRequest/PartnerAddRequest.jsx index 869a79ab..dbc2bdae 100644 --- a/src/pages/PartnerAddRequest/PartnerAddRequest.jsx +++ b/src/pages/PartnerAddRequest/PartnerAddRequest.jsx @@ -6,6 +6,8 @@ import { getPartnerRequestInfo } from "@redux/outstaffingSlice"; import { apiRequest } from "@api/request"; +import { useNotification } from "@hooks/useNotification"; + import { Footer } from "@components/Common/Footer/Footer"; import { Navigation } from "@components/Navigation/Navigation"; import { ProfileBreadcrumbs } from "@components/ProfileBreadcrumbs/ProfileBreadcrumbs"; @@ -47,6 +49,7 @@ export const PartnerAddRequest = () => { "Выберите кол-во сотрудников" ); const [inputs, setInputs] = useState({ title: "", description: "" }); + const { showNotification } = useNotification(); if ( currentUrl[0] === "/profile/requests-edit" && @@ -120,6 +123,11 @@ export const PartnerAddRequest = () => { } }).then(() => { navigate("/profile/requests"); + showNotification({ + show: true, + text: "Вакансия успешно изменена", + type: "success" + }); }); } else { apiRequest("/request/create-request", { @@ -138,6 +146,11 @@ export const PartnerAddRequest = () => { } }).then(() => { navigate("/profile/requests"); + showNotification({ + show: true, + text: "Вакансия успешно создана", + type: "success" + }); }); } }; diff --git a/src/pages/PartnerBid/PartnerBid.jsx b/src/pages/PartnerBid/PartnerBid.jsx index 67e454fc..8b12fb01 100644 --- a/src/pages/PartnerBid/PartnerBid.jsx +++ b/src/pages/PartnerBid/PartnerBid.jsx @@ -14,6 +14,8 @@ import { urlForLocal } from "@utils/helper"; import { apiRequest } from "@api/request"; +import { useNotification } from "@hooks/useNotification"; + import { Footer } from "@components/Common/Footer/Footer"; import { Loader } from "@components/Common/Loader/Loader"; import ModalLayout from "@components/Common/ModalLayout/ModalLayout"; @@ -37,6 +39,7 @@ export const PartnerBid = () => { const requestId = useSelector(getPartnerRequestId); const partnerRequests = useSelector(getPartnerRequests); const navigate = useNavigate(); + const { showNotification } = useNotification(); if (!requestId) { return ; @@ -61,6 +64,11 @@ export const PartnerBid = () => { } }).then(() => { navigate("/profile/requests"); + showNotification({ + show: true, + text: "Вакансия удалена", + type: "success" + }); }); }; diff --git a/src/pages/ProjectTracker/ProjectTracker.jsx b/src/pages/ProjectTracker/ProjectTracker.jsx index 52b95c10..13ea7a6b 100644 --- a/src/pages/ProjectTracker/ProjectTracker.jsx +++ b/src/pages/ProjectTracker/ProjectTracker.jsx @@ -256,7 +256,11 @@ export const ProjectTracker = () => { } else { dispatch(setProjectBoardFetch(projectBoard.id)); } - showNotification({ show: true, text: "Колонка удалена", type: "error" }); + showNotification({ + show: true, + text: "Колонка удалена", + type: "error" + }); }); } @@ -319,6 +323,11 @@ export const ProjectTracker = () => { ...prevState, add: false })); + showNotification({ + show: true, + text: "Тег успешно создан", + type: "success" + }); }); }); } @@ -340,6 +349,11 @@ export const ProjectTracker = () => { })); setTagInfo({ description: "", name: "" }); setColor("#aabbcc"); + showNotification({ + show: true, + text: "Тег успешно изменён", + type: "success" + }); }); } @@ -353,6 +367,11 @@ export const ProjectTracker = () => { } }).then(() => { dispatch(deleteTagProject(tagId)); + showNotification({ + show: true, + text: "Тег удален", + type: "success" + }); }); } diff --git a/src/pages/Summary/Summary.jsx b/src/pages/Summary/Summary.jsx index 641ac32d..b5f30d5b 100644 --- a/src/pages/Summary/Summary.jsx +++ b/src/pages/Summary/Summary.jsx @@ -10,6 +10,8 @@ import { urlForLocal } from "@utils/helper"; import { apiRequest } from "@api/request"; +import { useNotification } from "@hooks/useNotification"; + import { Footer } from "@components/Common/Footer/Footer"; import { Navigation } from "@components/Navigation/Navigation"; import { ProfileBreadcrumbs } from "@components/ProfileBreadcrumbs/ProfileBreadcrumbs"; @@ -37,6 +39,7 @@ export const Summary = () => { const [selectedSkills, setSelectedSkills] = useState([]); const [selectSkillsOpen, setSelectSkillsOpen] = useState(false); const [skillsList, seSkillsList] = useState([]); + const { showNotification } = useNotification(); useEffect(() => { apiRequest( @@ -72,7 +75,13 @@ export const Summary = () => { data: { resume: summery } - }).then(() => {}); + }).then(() => { + showNotification({ + show: true, + text: "Изменения успешно сохранены", + type: "success" + }); + }); } return (
diff --git a/src/pages/ViewReport/ViewReport.jsx b/src/pages/ViewReport/ViewReport.jsx index ab210b1d..6169cf6f 100644 --- a/src/pages/ViewReport/ViewReport.jsx +++ b/src/pages/ViewReport/ViewReport.jsx @@ -12,6 +12,8 @@ import { import { apiRequest } from "@api/request"; +import { useNotification } from "@hooks/useNotification"; + import { Footer } from "@components/Common/Footer/Footer"; import { Loader } from "@components/Common/Loader/Loader"; import { Navigation } from "@components/Navigation/Navigation"; @@ -38,6 +40,7 @@ export const ViewReport = () => { const [loader, setLoader] = useState(false); const [deleteLoader, setDeleteLoader] = useState(false); const [reportInfo, setReportInfo] = useState({}); + const { showNotification } = useNotification(); function getReportFromDate(day) { setLoader(true); @@ -84,6 +87,11 @@ export const ViewReport = () => { if (res) { window.location.replace("/profile/calendar"); } + showNotification({ + show: true, + text: "Отчет удален", + type: "success" + }); }); }