refactor: replace Toast with Sonner

This commit is contained in:
tao.chen
2026-09-02 10:10:41 +08:00
committed by tao.chen
parent 635d80e3cf
commit ed58344add
18 changed files with 126 additions and 320 deletions
@@ -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 {