refactor(web): remove typescript
This commit is contained in:
@@ -3,18 +3,11 @@ import DeleteIcon from '@mui/icons-material/Delete';
|
||||
import IconButton from '@mui/material/IconButton';
|
||||
import useEnqueueSnackbar from 'hooks/useEnqueueSnackbar';
|
||||
import * as React from 'react';
|
||||
|
||||
import Can from 'components/Can';
|
||||
import ConfirmationDialog from 'components/ConfirmationDialog';
|
||||
import { DELETE_ROLE } from 'graphql/mutations/delete-role.ee';
|
||||
import useFormatMessage from 'hooks/useFormatMessage';
|
||||
|
||||
type DeleteRoleButtonProps = {
|
||||
disabled?: boolean;
|
||||
roleId: string;
|
||||
};
|
||||
|
||||
export default function DeleteRoleButton(props: DeleteRoleButtonProps) {
|
||||
export default function DeleteRoleButton(props) {
|
||||
const { disabled, roleId } = props;
|
||||
const [showConfirmation, setShowConfirmation] = React.useState(false);
|
||||
const [deleteRole] = useMutation(DELETE_ROLE, {
|
||||
@@ -23,23 +16,20 @@ export default function DeleteRoleButton(props: DeleteRoleButtonProps) {
|
||||
});
|
||||
const formatMessage = useFormatMessage();
|
||||
const enqueueSnackbar = useEnqueueSnackbar();
|
||||
|
||||
const handleConfirm = React.useCallback(async () => {
|
||||
try {
|
||||
await deleteRole();
|
||||
|
||||
setShowConfirmation(false);
|
||||
enqueueSnackbar(formatMessage('deleteRoleButton.successfullyDeleted'), {
|
||||
variant: 'success',
|
||||
SnackbarProps: {
|
||||
'data-test': 'snackbar-delete-role-success'
|
||||
}
|
||||
'data-test': 'snackbar-delete-role-success',
|
||||
},
|
||||
});
|
||||
} catch (error) {
|
||||
throw new Error('Failed while deleting!');
|
||||
}
|
||||
}, [deleteRole]);
|
||||
|
||||
return (
|
||||
<>
|
||||
<Can I="delete" a="Role" passThrough>
|
Reference in New Issue
Block a user