872ec9e6bb
* feat: no atomic * feat: update front not atomic operations * feat: optional fields for person model & use proper gql type * Fix bug display name * Fix bug update user * Fixed bug avatar URL * Fixed display name on people cell * Fix lint * Fixed storybook display name * Fix storybook requests --------- Co-authored-by: Lucas Bordeau <bordeau.lucas@gmail.com>
41 lines
1.2 KiB
TypeScript
41 lines
1.2 KiB
TypeScript
import { getOperationName } from '@apollo/client/utilities';
|
|
import { useRecoilValue } from 'recoil';
|
|
|
|
import { GET_PEOPLE } from '@/people/queries';
|
|
import { IconTrash } from '@/ui/icon/index';
|
|
import { EntityTableActionBarButton } from '@/ui/table/action-bar/components/EntityTableActionBarButton';
|
|
import { useResetTableRowSelection } from '@/ui/table/hooks/useResetTableRowSelection';
|
|
import { selectedRowIdsSelector } from '@/ui/table/states/selectedRowIdsSelector';
|
|
import { useDeleteManyPersonMutation } from '~/generated/graphql';
|
|
|
|
export function TableActionBarButtonDeletePeople() {
|
|
const selectedRowIds = useRecoilValue(selectedRowIdsSelector);
|
|
|
|
const resetRowSelection = useResetTableRowSelection();
|
|
|
|
const [deleteManyPerson] = useDeleteManyPersonMutation({
|
|
refetchQueries: [getOperationName(GET_PEOPLE) ?? ''],
|
|
});
|
|
|
|
async function handleDeleteClick() {
|
|
const rowIdsToDelete = selectedRowIds;
|
|
|
|
resetRowSelection();
|
|
|
|
await deleteManyPerson({
|
|
variables: {
|
|
ids: rowIdsToDelete,
|
|
},
|
|
});
|
|
}
|
|
|
|
return (
|
|
<EntityTableActionBarButton
|
|
label="Delete"
|
|
icon={<IconTrash size={16} />}
|
|
type="warning"
|
|
onClick={handleDeleteClick}
|
|
/>
|
|
);
|
|
}
|