import React from "react";
import type { NotificationProvider } from "@refinedev/core";
import { useSnackbar } from "notistack";
import { CircularDeterminate } from "@components";
import Box from "@mui/material/Box";
import IconButton from "@mui/material/IconButton";
import Typography from "@mui/material/Typography";
import UndoOutlined from "@mui/icons-material/UndoOutlined";
export const useNotificationProvider = (): NotificationProvider => {
const { closeSnackbar, enqueueSnackbar } = useSnackbar();
const notificationProvider: NotificationProvider = {
open: ({
message,
type,
undoableTimeout,
key,
cancelMutation,
description,
}) => {
if (type === "progress") {
const action = (key: any) => (
{
cancelMutation?.();
closeSnackbar(key);
}}
color="inherit"
>
);
enqueueSnackbar(
<>
>,
{
action,
preventDuplicate: true,
key,
autoHideDuration: (undoableTimeout ?? 0) * 1000,
},
);
} else {
enqueueSnackbar(
{description}
{message}
,
{
key,
variant: type,
},
);
}
},
close: (key) => {
closeSnackbar(key);
},
};
return notificationProvider;
};