import { useCallback } from 'react' ; import { useSelector , useDispatch } from 'react-redux' ; import { actions , selectors , State } from './index' ; export function useCreateUser ( ) { const dispatch = useDispatch ( ) ; return useCallback ( ( user ) => { dispatch ( actions . createUser ( user ) ) ; } , [ dispatch ] ) ; } export function useUpdateUser ( ) { const dispatch = useDispatch ( ) ; return useCallback ( ( id , user ) => { dispatch ( actions . updateUser ( id , user ) ) ; } , [ dispatch ] ) ; } export function useCreateTask ( ) { const dispatch = useDispatch ( ) ; return useCallback ( ( task ) => { dispatch ( actions . createTask ( task ) ) ; } , [ dispatch ] ) ; } export function useUpdateTask ( ) { const dispatch = useDispatch ( ) ; return useCallback ( ( id , task ) => { dispatch ( actions . updateTask ( id , task ) ) ; } , [ dispatch ] ) ; } export function useDeleteTask ( ) { const dispatch = useDispatch ( ) ; return useCallback ( ( id ) => { dispatch ( actions . deleteTask ( id ) ) ; } , [ dispatch ] ) ; } export function useAssignTask ( ) { const dispatch = useDispatch ( ) ; return useCallback ( ( taskId , userId ) => { dispatch ( actions . assignTask ( taskId , userId ) ) ; } , [ dispatch ] ) ; } export function useUnassignTask ( ) { const dispatch = useDispatch ( ) ; return useCallback ( ( taskId , userId ) => { dispatch ( actions . unassignTask ( taskId , userId ) ) ; } , [ dispatch ] ) ; } export function useCreateStatus ( ) { const dispatch = useDispatch ( ) ; return useCallback ( ( status ) => { dispatch ( actions . createStatus ( status ) ) ; } , [ dispatch ] ) ; } export function useUpdateStatus ( ) { const dispatch = useDispatch ( ) ; return useCallback ( ( id , status ) => { dispatch ( actions . updateStatus ( id , status ) ) ; } , [ dispatch ] ) ; } export function useDeleteStatus ( ) { const dispatch = useDispatch ( ) ; return useCallback ( ( id ) => { dispatch ( actions . deleteStatus ( id ) ) ; } , [ dispatch ] ) ; } export function useCreateTag ( ) { const dispatch = useDispatch ( ) ; return useCallback ( ( tag ) => { dispatch ( actions . createTag ( tag ) ) ; } , [ dispatch ] ) ; } export function useCreateRootComment ( ) { const dispatch = useDispatch ( ) ; return useCallback ( ( comment ) => { dispatch ( actions . createRootComment ( comment ) ) ; } , [ dispatch ] ) ; } export function useCreateChildComment ( ) { const dispatch = useDispatch ( ) ; return useCallback ( ( comment ) => { dispatch ( actions . createChildComment ( comment ) ) ; } , [ dispatch ] ) ; } export function useDeleteComment ( ) { const dispatch = useDispatch ( ) ; return useCallback ( ( id ) => { dispatch ( actions . deleteComment ( id ) ) ; } , [ dispatch ] ) ; } export function useMoveStatus ( ) { const dispatch = useDispatch ( ) ; return useCallback ( ( src , dest ) => { dispatch ( actions . moveStatus ( src , dest ) ) ; } , [ dispatch ] ) ; } export function useMoveStatusTask ( ) { const dispatch = useDispatch ( ) ; return useCallback ( ( taskId , srcStatusId , src , destStatusId , dest ) => { dispatch ( actions . moveStatusTask ( taskId , srcStatusId , src , destStatusId , dest ) ) ; } , [ dispatch ] ) ; } export function useUserIds ( ) { return useSelector ( ( state ) => selectors . getUserIds ( state ) ) ; } export function useTaskIds ( ) { return useSelector ( ( state ) => selectors . getTaskIds ( state ) ) ; } export function useStatusIds ( ) { return useSelector ( ( state ) => selectors . getStatusIds ( state ) ) ; } export function useTagIds ( ) { return useSelector ( ( state ) => selectors . getTagIds ( state ) ) ; } export function useCommentIds ( ) { return useSelector ( ( state ) => selectors . getCommentIds ( state ) ) ; } export function useUser ( id ) { return useSelector ( ( state ) => selectors . getUser ( state , { id } ) ) ; } export function useTask ( id ) { return useSelector ( ( state ) => selectors . getTask ( state , { id } ) ) ; } export function useStatus ( id ) { return useSelector ( ( state ) => selectors . getStatus ( state , { id } ) ) ; } export function useTag ( id ) { return useSelector ( ( state ) => selectors . getTag ( state , { id } ) ) ; } export function useComment ( id ) { return useSelector ( ( state ) => selectors . getComment ( state , { id } ) ) ; } export function useCommentUsername ( id ) { return useSelector ( ( state ) => selectors . getCommentUsername ( state , { id } ) ) ; }