Files
twenty/front/src/modules/activities/hooks/useOpenCreateActivityDrawerForSelectedRowIds.ts
brendanlaschke c91844071a Add task to action bar (#1153)
- add task to action bar
2023-08-10 09:17:58 -07:00

28 lines
880 B
TypeScript

import { useRecoilValue } from 'recoil';
import { selectedRowIdsSelector } from '@/ui/table/states/selectedRowIdsSelector';
import { ActivityType, CommentableType } from '~/generated/graphql';
import { CommentableEntity } from '../types/CommentableEntity';
import { useOpenCreateActivityDrawer } from './useOpenCreateActivityDrawer';
export function useOpenCreateActivityDrawerForSelectedRowIds() {
const selectedEntityIds = useRecoilValue(selectedRowIdsSelector);
const openCreateActivityDrawer = useOpenCreateActivityDrawer();
return function openCreateCommentDrawerForSelectedRowIds(
type: ActivityType,
entityType: CommentableType,
) {
const commentableEntityArray: CommentableEntity[] = selectedEntityIds.map(
(id) => ({
type: entityType,
id,
}),
);
openCreateActivityDrawer(type, commentableEntityArray);
};
}