All files / web/modules/admin/users/delete DeleteUser.tsx

0% Statements 0/15
100% Branches 0/0
0% Functions 0/4
0% Lines 0/13

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38                                                                           
import { Button } from 'antd';
import * as React from 'react';
import { Mutation } from 'react-apollo';
import { confirmModal } from '../helpers';
import { REMOVE_USER } from '../mutations';
import { USERS } from '../queries';
 
interface IProps {
  user: any;
}
 
const DeleteUser = ({ user }: IProps) => (
  <Mutation mutation={REMOVE_USER} refetchQueries={[{ query: USERS }]}>
    {(removeUser, { error }) => {
      const handleOnRemoveButtonClick = () => {
        confirmModal(
          'Remove user',
          `You are about to remove "${user.username}". Are you sure?`,
          'Remove',
          () => removeUser({ variables: { username: user.username } }),
          'User was removed',
        );
      };
 
      return (
        <Button
          type="danger"
          shape="circle"
          icon="delete"
          onClick={handleOnRemoveButtonClick}
        />
      );
    }}
  </Mutation>
);
 
export default DeleteUser;