1
0
Fork 0
mirror of https://github.com/muerwre/vault-frontend.git synced 2025-04-24 20:36:40 +07:00

removed all router-modals

This commit is contained in:
Fedor Katurov 2022-01-09 20:27:23 +07:00
parent 85d20e5009
commit ffce400398
15 changed files with 99 additions and 143 deletions

View file

@ -2,8 +2,12 @@ import { INode } from '~/types';
import { useCallback } from 'react';
import { apiLockNode, apiPostNodeHeroic, apiPostNodeLike } from '~/api/node';
import { showErrorToast } from '~/utils/errors/showToast';
import { useModal } from '~/hooks/modal/useModal';
import { Dialog } from '~/constants/modal';
export const useNodeActions = (node: INode, update: (node: Partial<INode>) => Promise<unknown>) => {
const { showModal } = useModal();
const onLike = useCallback(async () => {
try {
const result = await apiPostNodeLike({ id: node.id });
@ -37,5 +41,7 @@ export const useNodeActions = (node: INode, update: (node: Partial<INode>) => Pr
}
}, [node.deleted_at, node.id, update]);
return { onLike, onStar, onLock };
const onEdit = useCallback(() => showModal(Dialog.EditNode, { nodeId: node.id! }), [node]);
return { onLike, onStar, onLock, onEdit };
};