first commit
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
import { create } from "zustand";
|
||||
|
||||
interface IConfirmStore {
|
||||
visible: boolean;
|
||||
message: string;
|
||||
title: string;
|
||||
onConfirm: () => void;
|
||||
onCancel: () => void;
|
||||
show: (message: string, onConfirm: () => void, onCancel: () => void) => void;
|
||||
close: () => void;
|
||||
clear: () => void;
|
||||
}
|
||||
|
||||
export type ConfirmState = IConfirmStore;
|
||||
|
||||
const useConfirmStore = create<ConfirmState>()((set) => ({
|
||||
visible: false,
|
||||
message: "",
|
||||
title: "",
|
||||
onConfirm: () => {},
|
||||
onCancel: () => {},
|
||||
show: (message: string, onConfirm: () => void, onCancel: () => void) =>
|
||||
set(() => ({
|
||||
visible: true,
|
||||
message: message,
|
||||
onConfirm: onConfirm,
|
||||
onCancel: onCancel,
|
||||
title: "Atención",
|
||||
})),
|
||||
close: () =>
|
||||
set(() => ({
|
||||
visible: false,
|
||||
message: "",
|
||||
onConfirm: () => {},
|
||||
onCancel: () => {},
|
||||
title: "",
|
||||
})),
|
||||
clear: () =>
|
||||
set(() => ({
|
||||
visible: false,
|
||||
message: "",
|
||||
onConfirm: () => {},
|
||||
onCancel: () => {},
|
||||
title: "",
|
||||
})),
|
||||
}));
|
||||
|
||||
export { useConfirmStore };
|
||||
Reference in New Issue
Block a user