Client: Notifications now appear in center instead

Closes #59
This commit is contained in:
Donkie
2023-08-12 20:38:26 +02:00
parent 130aed4ed6
commit 5a8a5b185d
2 changed files with 35 additions and 2 deletions

View File

@@ -1,7 +1,7 @@
import { Refine } from "@refinedev/core";
import { RefineKbar, RefineKbarProvider } from "@refinedev/kbar";
import { ErrorComponent, notificationProvider, ThemedLayoutV2, ThemedSiderV2, ThemedTitleV2 } from "@refinedev/antd";
import { ErrorComponent, ThemedLayoutV2, ThemedSiderV2, ThemedTitleV2 } from "@refinedev/antd";
import "@refinedev/antd/dist/reset.css";
import routerBindings, {
@@ -23,6 +23,7 @@ import React from "react";
import { Locale } from "antd/es/locale";
import { languages } from "./i18n";
import loadable from "@loadable/component";
import SpoolmanNotificationProvider from "./components/notificationProvider";
interface PageProps {
resource: "spools" | "filaments" | "vendors";
@@ -82,7 +83,7 @@ function App() {
>
<Refine
dataProvider={dataProvider(import.meta.env.VITE_APIURL)}
notificationProvider={notificationProvider}
notificationProvider={SpoolmanNotificationProvider}
i18nProvider={i18nProvider}
routerProvider={routerBindings}
resources={[

View File

@@ -0,0 +1,32 @@
import { NotificationProvider } from "@refinedev/core";
import { message } from "antd";
import { UndoableNotification } from "@refinedev/antd/src/components/undoableNotification";
const SpoolmanNotificationProvider: NotificationProvider = {
open: ({ key, message: content, type, cancelMutation, undoableTimeout }) => {
if (type === "progress") {
message.open({
key,
content: (
<UndoableNotification
notificationKey={key}
message={content}
cancelMutation={cancelMutation}
undoableTimeout={undoableTimeout}
/>
),
duration: 0,
});
} else {
message.open({
key,
content,
type,
});
}
},
close: (key) => message.destroy(key),
};
export default SpoolmanNotificationProvider;