refactor: replace Toast with Sonner
This commit is contained in:
@@ -1,10 +1,14 @@
|
||||
import { useScriptWorkspaceStore } from "../platform/state/scriptWorkspaceStore";
|
||||
import { useUiStore } from "../platform/state/uiStore";
|
||||
import { toast } from "sonner";
|
||||
import SchedulePage from "./SchedulePage";
|
||||
|
||||
export default function SchedulesPageRoute() {
|
||||
const setApiOnline = useScriptWorkspaceStore((s) => s.setApiOnline);
|
||||
const pushToast = useUiStore((s) => s.pushToast);
|
||||
const pushToast = (notice: { tone: "success" | "error" | "info"; message: string }) => {
|
||||
if (notice.tone === "error") toast.error(notice.message);
|
||||
else if (notice.tone === "info") toast.info(notice.message);
|
||||
else toast.success(notice.message);
|
||||
};
|
||||
|
||||
return (
|
||||
<SchedulePage
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
import { ApiRequestError, type Schedule, type ScheduleNode, type WorkspaceBoundApi } from "../../../services/api";
|
||||
|
||||
import { useScriptWorkspaceStore } from "../../platform/state/scriptWorkspaceStore";
|
||||
import { useUiStore } from "../../platform/state/uiStore";
|
||||
import { toast } from "sonner";
|
||||
|
||||
import type { NodeForm, NodePositionDraft, Notice, ScheduleForm } from "./types";
|
||||
import type { SchedulesStore } from "./useSchedulesStore";
|
||||
@@ -22,7 +22,9 @@ export function requireApi(): WorkspaceBoundApi {
|
||||
}
|
||||
|
||||
export function notify(notice: Notice): void {
|
||||
useUiStore.getState().pushToast(notice);
|
||||
if (notice.tone === "error") toast.error(notice.message);
|
||||
else if (notice.tone === "info") toast.info(notice.message);
|
||||
else toast.success(notice.message);
|
||||
}
|
||||
|
||||
export function setApiOnline(online: boolean): void {
|
||||
|
||||
Reference in New Issue
Block a user