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

10
package-lock.json generated
View File

@ -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"
}
]
},

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")

View File

@ -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"
});
});
}
};

View File

@ -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 <Navigate to="/profile/requests" replace />;
@ -61,6 +64,11 @@ export const PartnerBid = () => {
}
}).then(() => {
navigate("/profile/requests");
showNotification({
show: true,
text: "Вакансия удалена",
type: "success"
});
});
};

View File

@ -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"
});
});
}

View File

@ -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 (
<div className="summary">

View File

@ -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"
});
});
}