umami/components/pages/settings/teams/TeamMemberRemoveButton.js

32 lines
841 B
JavaScript
Raw Normal View History

2023-04-02 21:24:50 +02:00
import useApi from 'hooks/useApi';
import useMessages from 'hooks/useMessages';
import { Icon, Icons, LoadingButton, Text } from 'react-basics';
2023-04-21 17:00:42 +02:00
export function TeamMemberRemoveButton({ teamId, userId, disabled, onSave }) {
2023-04-02 21:24:50 +02:00
const { formatMessage, labels } = useMessages();
const { del, useMutation } = useApi();
2023-04-10 01:04:28 +02:00
const { mutate, isLoading } = useMutation(() => del(`/team/${teamId}/users/${userId}`));
2023-04-02 21:24:50 +02:00
const handleRemoveTeamMember = () => {
mutate(
2023-04-10 01:04:28 +02:00
{},
2023-04-02 21:24:50 +02:00
{
onSuccess: () => {
onSave();
},
},
);
};
return (
<LoadingButton onClick={() => handleRemoveTeamMember()} disabled={disabled} loading={isLoading}>
<Icon>
<Icons.Close />
</Icon>
<Text>{formatMessage(labels.remove)}</Text>
</LoadingButton>
);
}
2023-04-21 17:00:42 +02:00
export default TeamMemberRemoveButton;