1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-11-24 20:06:55 +01:00
unleash.unleash/frontend/src/component/admin/groups/RemoveGroup/RemoveGroup.tsx
Nuno Góis 4167a60588
feat: biome lint frontend (#4903)
Follows up on https://github.com/Unleash/unleash/pull/4853 to add Biome
to the frontend as well.


![image](https://github.com/Unleash/unleash/assets/14320932/1906faf1-fc29-4172-a4d4-b2716d72cd65)

Added a few `biome-ignore` to speed up the process but we may want to
check and fix them in the future.
2023-10-02 13:25:46 +01:00

61 lines
1.8 KiB
TypeScript

import { Typography } from '@mui/material';
import { Dialogue } from 'component/common/Dialogue/Dialogue';
import { useGroupApi } from 'hooks/api/actions/useGroupApi/useGroupApi';
import { useGroups } from 'hooks/api/getters/useGroups/useGroups';
import useToast from 'hooks/useToast';
import { IGroup } from 'interfaces/group';
import { FC } from 'react';
import { useNavigate } from 'react-router-dom';
import { formatUnknownError } from 'utils/formatUnknownError';
interface IRemoveGroupProps {
open: boolean;
setOpen: React.Dispatch<React.SetStateAction<boolean>>;
group: IGroup;
}
export const RemoveGroup: FC<IRemoveGroupProps> = ({
open,
setOpen,
group,
}) => {
const { refetchGroups } = useGroups();
const { removeGroup } = useGroupApi();
const { setToastData, setToastApiError } = useToast();
const navigate = useNavigate();
const onRemoveClick = async () => {
try {
await removeGroup(group.id);
refetchGroups();
setOpen(false);
navigate('/admin/groups');
setToastData({
title: 'Group removed successfully',
type: 'success',
});
} catch (error: unknown) {
setToastApiError(formatUnknownError(error));
}
};
return (
<Dialogue
open={open}
primaryButtonText='Delete group'
secondaryButtonText='Cancel'
onClick={onRemoveClick}
onClose={() => {
setOpen(false);
}}
title='Delete group?'
>
<Typography>
Do you really want to delete <strong>{group.name}</strong>?
Users who are granted access to projects only via this group
will lose access to those projects.
</Typography>
</Dialogue>
);
};