[WEB-570] chore: toast refactor (#3836)

* new toast setup

* chore: new toast implementation.

* chore: move toast component to ui package.

* chore: replace `setToast` with `setPromiseToast` in required places for better UX.
* chore: code cleanup.

* chore: update theme.

* fix: theme switching issue.

* chore: remove toast from issue update operations.

* chore: add promise toast for add/ remove issue to cycle/ module and remove local spinners.

---------

Co-authored-by: rahulramesha <rahulramesham@gmail.com>
This commit is contained in:
Prateek Shourya
2024-03-06 14:18:41 +05:30
committed by GitHub
parent c06ef4d1d7
commit 53367a6bc4
167 changed files with 1827 additions and 1896 deletions

View File

@@ -1,9 +0,0 @@
import { useContext } from "react";
import { toastContext } from "contexts/toast.context";
const useToast = () => {
const toastContextData = useContext(toastContext);
return toastContextData;
};
export default useToast;

View File

@@ -5,12 +5,12 @@ import useSWR from "swr";
import useSWRInfinite from "swr/infinite";
// services
import { NotificationService } from "services/notification.service";
// hooks
import useToast from "./use-toast";
// fetch-keys
import { UNREAD_NOTIFICATIONS_COUNT, getPaginatedNotificationKey } from "constants/fetch-keys";
// type
import type { NotificationType, NotificationCount, IMarkAllAsReadPayload } from "@plane/types";
// ui
import { TOAST_TYPE, setToast } from "@plane/ui";
const PER_PAGE = 30;
@@ -20,8 +20,6 @@ const useUserNotification = () => {
const router = useRouter();
const { workspaceSlug } = router.query;
const { setToastAlert } = useToast();
const [snoozed, setSnoozed] = useState<boolean>(false);
const [archived, setArchived] = useState<boolean>(false);
const [readNotification, setReadNotification] = useState<boolean>(false);
@@ -265,15 +263,15 @@ const useUserNotification = () => {
await userNotificationServices
.markAllNotificationsAsRead(workspaceSlug.toString(), markAsReadParams)
.then(() => {
setToastAlert({
type: "success",
setToast({
type: TOAST_TYPE.SUCCESS,
title: "Success!",
message: "All Notifications marked as read.",
});
})
.catch(() => {
setToastAlert({
type: "error",
setToast({
type: TOAST_TYPE.ERROR,
title: "Error!",
message: "Something went wrong. Please try again.",
});