♻️ refactor: create remove member dialog component

This commit is contained in:
Wahyu Kurniawan 2024-03-14 21:56:29 +07:00
parent f5807c1126
commit 4c936b1eb7
No known key found for this signature in database
GPG Key ID: 040A1549143A8E33
2 changed files with 46 additions and 15 deletions

View File

@ -0,0 +1,38 @@
import ConfirmDialog, {
ConfirmDialogProps,
} from 'components/shared/ConfirmDialog';
import React from 'react';
import { formatAddress } from 'utils/format';
interface RemoveMemberDialogProps extends ConfirmDialogProps {
memberName: string;
ethAddress: string;
emailDomain: string;
}
export const RemoveMemberDialog = ({
memberName,
ethAddress,
emailDomain,
open,
handleCancel,
handleConfirm,
...props
}: RemoveMemberDialogProps) => {
return (
<ConfirmDialog
{...props}
dialogTitle="Remove member?"
handleCancel={handleCancel}
open={open}
confirmButtonTitle="Yes, remove member"
handleConfirm={handleConfirm}
confirmButtonProps={{ variant: 'danger' }}
>
<p className="text-sm text-elements-high-em">
Once removed, {formatAddress(memberName)} ({formatAddress(ethAddress)}@
{emailDomain}) will not be able to access this project.
</p>
</ConfirmDialog>
);
};

View File

@ -3,15 +3,14 @@ import { Permission, User } from 'gql-client';
import { import {
Select, Select,
Typography,
Option, Option,
Chip, Chip,
IconButton, IconButton,
Tooltip, Tooltip,
} from '@material-tailwind/react'; } from '@material-tailwind/react';
import ConfirmDialog from '../../../shared/ConfirmDialog'; import { formatAddress } from 'utils/format';
import { formatAddress } from '../../../../utils/format'; import { RemoveMemberDialog } from 'components/projects/Dialog/RemoveMemberDialog';
const PERMISSION_OPTIONS = [ const PERMISSION_OPTIONS = [
{ {
@ -141,25 +140,19 @@ const MemberCard = ({
</div> </div>
)} )}
</div> </div>
<ConfirmDialog <RemoveMemberDialog
dialogTitle="Remove member?" handleCancel={() => setRemoveMemberDialogOpen((preVal) => !preVal)}
handleOpen={() => setRemoveMemberDialogOpen((preVal) => !preVal)}
open={removeMemberDialogOpen} open={removeMemberDialogOpen}
confirmButtonTitle="Yes, Remove member"
handleConfirm={() => { handleConfirm={() => {
setRemoveMemberDialogOpen((preVal) => !preVal); setRemoveMemberDialogOpen((preVal) => !preVal);
if (onRemoveProjectMember) { if (onRemoveProjectMember) {
onRemoveProjectMember(); onRemoveProjectMember();
} }
}} }}
color="red" memberName={member.name ?? ''}
> ethAddress={ethAddress}
<Typography variant="small" placeholder={''}> emailDomain={emailDomain}
Once removed, {formatAddress(member.name ?? '')} ( />
{formatAddress(ethAddress)}@{emailDomain}) will not be able to access
this project.
</Typography>
</ConfirmDialog>
</div> </div>
); );
}; };