mirror of
https://github.com/muerwre/vault-frontend.git
synced 2025-05-06 01:56:41 +07:00
completely removed modal reducer
This commit is contained in:
parent
b1e8bddbaf
commit
8d5afb4f98
34 changed files with 189 additions and 300 deletions
src/hooks/modal
16
src/hooks/modal/useModal.ts
Normal file
16
src/hooks/modal/useModal.ts
Normal file
|
@ -0,0 +1,16 @@
|
|||
import { useModalStore } from '~/store/modal/useModalStore';
|
||||
import { useCallback } from 'react';
|
||||
import { Dialog } from '~/constants/modal';
|
||||
|
||||
export const useModal = () => {
|
||||
const { setCurrent, hide } = useModalStore();
|
||||
|
||||
const showModal = useCallback(
|
||||
(dialog: Dialog) => {
|
||||
setCurrent(dialog);
|
||||
},
|
||||
[setCurrent]
|
||||
);
|
||||
|
||||
return { showModal, hideModal: hide };
|
||||
};
|
11
src/hooks/modal/useShowModal.ts
Normal file
11
src/hooks/modal/useShowModal.ts
Normal file
|
@ -0,0 +1,11 @@
|
|||
import { useCallback } from 'react';
|
||||
import { useModal } from '~/hooks/modal/useModal';
|
||||
import { Dialog } from '~/constants/modal';
|
||||
|
||||
export const useShowModal = (dialog: Dialog) => {
|
||||
const modal = useModal();
|
||||
|
||||
return useCallback(() => {
|
||||
modal.showModal(dialog);
|
||||
}, [dialog, modal]);
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue