Initial commit
This commit is contained in:
42
src/screens/auth/registeration/lib/modalStore.ts
Normal file
42
src/screens/auth/registeration/lib/modalStore.ts
Normal file
@@ -0,0 +1,42 @@
|
||||
import { create } from 'zustand';
|
||||
|
||||
interface ModalState {
|
||||
isVisible: boolean;
|
||||
title: string;
|
||||
message: string;
|
||||
type: 'success' | 'error' | 'info';
|
||||
onConfirm: () => void;
|
||||
onCancel?: () => void;
|
||||
openModal: (
|
||||
title: string,
|
||||
message: string,
|
||||
type?: 'success' | 'error' | 'info',
|
||||
onConfirm?: () => void,
|
||||
onCancel?: () => void
|
||||
) => void;
|
||||
closeModal: () => void;
|
||||
}
|
||||
|
||||
export const useModalStore = create<ModalState>((set) => ({
|
||||
isVisible: false,
|
||||
title: '',
|
||||
message: '',
|
||||
type: 'info',
|
||||
onConfirm: () => { },
|
||||
onCancel: undefined,
|
||||
|
||||
openModal: (title, message, type = 'info', onConfirm, onCancel) =>
|
||||
set({
|
||||
isVisible: true,
|
||||
title,
|
||||
message,
|
||||
type,
|
||||
onConfirm: () => {
|
||||
if (onConfirm) onConfirm();
|
||||
set({ isVisible: false });
|
||||
},
|
||||
onCancel: onCancel || undefined,
|
||||
}),
|
||||
|
||||
closeModal: () => set({ isVisible: false }),
|
||||
}));
|
||||
Reference in New Issue
Block a user