1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-09-15 17:50:48 +02:00
unleash.unleash/frontend/src/component/admin/users/UsersList/DeleteUser/DeleteUser.tsx
olav 24c11332b5 chore: update MUI to v5 (#923)
* refactor: update mui packages

* refactor: run mui codemods

* refactor: format files after codemods

* refactor: fix broken types

* refactor: clean up theme

* refactor: fix broken tests

* refactor: replace @mui/styles with tss-react

* refactor: move breakpoints into classes for tss

* refactor: fix crash on missing feature description

* refactor: remove void classNames

* refactor: adjust styles to new defaults

* refactor: remove broken rollout slider e2e test

* refactor: fix duplicate e2e testid

* refactor: update makeStyles after rebase

* refactor: add missing snapshot after rebase

* refactor: fix TableCellSortable focus styles

* refactor: use 1.4 as the default line-height

* refactor: hide webkit search field icons

* refactor: fix select box label

* refactor: make AutocompleteBox smaller

* refactor: make heading smaller

* refactor: fix toast close icon color

* refactor: update snapshots

* refactor: add missing test event awaits

* refactor: fix default button line-height
2022-05-02 15:52:41 +02:00

88 lines
2.8 KiB
TypeScript

import React from 'react';
import { Dialogue } from 'component/common/Dialogue/Dialogue';
import { ConditionallyRender } from 'component/common/ConditionallyRender/ConditionallyRender';
import { REMOVE_USER_ERROR } from 'hooks/api/actions/useAdminUsersApi/useAdminUsersApi';
import { Alert } from '@mui/material';
import useLoading from 'hooks/useLoading';
import { Avatar, Typography } from '@mui/material';
import { useThemeStyles } from 'themes/themeStyles';
import { IUser } from 'interfaces/user';
interface IDeleteUserProps {
showDialog: boolean;
closeDialog: () => void;
user: IUser;
userLoading: boolean;
removeUser: () => void;
userApiErrors: Record<string, string>;
}
const DeleteUser = ({
showDialog,
closeDialog,
user,
userLoading,
removeUser,
userApiErrors,
}: IDeleteUserProps) => {
const ref = useLoading(userLoading);
const { classes: themeStyles } = useThemeStyles();
return (
<Dialogue
open={showDialog}
title="Really delete user?"
onClose={closeDialog}
onClick={removeUser}
primaryButtonText="Delete user"
secondaryButtonText="Cancel"
>
<div ref={ref}>
<ConditionallyRender
condition={Boolean(userApiErrors[REMOVE_USER_ERROR])}
show={
<Alert
data-loading
severity="error"
style={{ margin: '1rem 0' }}
>
{userApiErrors[REMOVE_USER_ERROR]}
</Alert>
}
/>
<div data-loading className={themeStyles.flexRow}>
<Avatar
variant="rounded"
alt="Gravatar"
src={user.imageUrl}
title={`${
user.name || user.email || user.username
} (id: ${user.id})`}
/>
<Typography
variant="subtitle1"
style={{ marginLeft: '1rem' }}
>
{user.username || user.email}
</Typography>
</div>
<Typography
data-loading
variant="body1"
style={{ marginTop: '1rem' }}
>
Are you sure you want to delete{' '}
{user
? `${user.name || 'user'} (${
user.email || user.username
})`
: ''}
?
</Typography>
</div>
</Dialogue>
);
};
export default DeleteUser;