rqbit/crates/librqbit/webui/src/stores/errorStore.ts

30 lines
809 B
TypeScript
Raw Normal View History

2023-12-17 19:27:22 +00:00
import { create } from "zustand";
import { ErrorDetails } from "../api-types";
export interface ErrorWithLabel {
text: string;
details?: ErrorDetails;
}
export const useErrorStore = create<{
alert: ErrorWithLabel | null;
setAlert: (alert: ErrorWithLabel) => void;
removeAlert: () => void;
2023-12-17 19:27:22 +00:00
closeableError: ErrorWithLabel | null;
setCloseableError: (error: ErrorWithLabel | null) => void;
otherError: ErrorWithLabel | null;
setOtherError: (error: ErrorWithLabel | null) => void;
}>((set) => ({
closeableError: null,
setCloseableError: (closeableError) => set(() => ({ closeableError })),
otherError: null,
setOtherError: (otherError) => set(() => ({ otherError })),
alert: null,
setAlert: (alert) => set(() => ({alert})),
removeAlert: () => set(() => ({alert: null}))
2023-12-17 19:27:22 +00:00
}));