* Trigger message thread top bar * Rename message thread to thread * Move all components in a directory --------- Co-authored-by: Thomas Trompette <thomast@twenty.com>
35 lines
1.2 KiB
TypeScript
35 lines
1.2 KiB
TypeScript
import { useRecoilState, useRecoilValue } from 'recoil';
|
|
|
|
import { viewableActivityIdState } from '@/activities/states/viewableActivityIdState';
|
|
import { CoreObjectNameSingular } from '@/object-metadata/types/CoreObjectNameSingular';
|
|
import { useDeleteOneRecord } from '@/object-record/hooks/useDeleteOneRecord';
|
|
import { IconTrash } from '@/ui/display/icon';
|
|
import { LightIconButton } from '@/ui/input/button/components/LightIconButton';
|
|
import { isRightDrawerOpenState } from '@/ui/layout/right-drawer/states/isRightDrawerOpenState';
|
|
|
|
export const ActivityActionBar = () => {
|
|
const viewableActivityId = useRecoilValue(viewableActivityIdState);
|
|
const [, setIsRightDrawerOpen] = useRecoilState(isRightDrawerOpenState);
|
|
const { deleteOneRecord: deleteOneActivity } = useDeleteOneRecord({
|
|
objectNameSingular: CoreObjectNameSingular.Activity,
|
|
refetchFindManyQuery: true,
|
|
});
|
|
|
|
const deleteActivity = () => {
|
|
if (viewableActivityId) {
|
|
deleteOneActivity?.(viewableActivityId);
|
|
}
|
|
|
|
setIsRightDrawerOpen(false);
|
|
};
|
|
|
|
return (
|
|
<LightIconButton
|
|
Icon={IconTrash}
|
|
onClick={deleteActivity}
|
|
accent="tertiary"
|
|
size="medium"
|
|
/>
|
|
);
|
|
};
|