feat: activate/inactivate account from drawer details

This commit is contained in:
Ahmed Bouhuolia
2024-08-18 20:23:47 +02:00
parent 5fcb2d9cc9
commit e4fb126d39

View File

@@ -6,6 +6,11 @@ import {
NavbarGroup, NavbarGroup,
Intent, Intent,
NavbarDivider, NavbarDivider,
Popover,
Menu,
MenuItem,
PopoverInteractionKind,
Position,
} from '@blueprintjs/core'; } from '@blueprintjs/core';
import { import {
DashboardActionsBar, DashboardActionsBar,
@@ -23,6 +28,7 @@ import withAlertsActions from '@/containers/Alert/withAlertActions';
import { AccountDialogAction } from '@/containers/Dialogs/AccountDialog/utils'; import { AccountDialogAction } from '@/containers/Dialogs/AccountDialog/utils';
import { useAccountDrawerContext } from './AccountDrawerProvider'; import { useAccountDrawerContext } from './AccountDrawerProvider';
import { compose, safeCallback } from '@/utils'; import { compose, safeCallback } from '@/utils';
import { CLASSES } from '@/constants';
/** /**
* Account drawer action bar. * Account drawer action bar.
@@ -56,6 +62,14 @@ function AccountDrawerActionBar({
const onDeleteAccount = () => { const onDeleteAccount = () => {
openAlert('account-delete', { accountId: account.id }); openAlert('account-delete', { accountId: account.id });
}; };
// Handle inactivate button click.
const handleInactivateBtnClick = () => {
openAlert('account-inactivate', { accountId: account.id });
};
// Handle activate button click.
const handleActivateBtnClick = () => {
openAlert('account-activate', { accountId: account.id });
};
return ( return (
<DashboardActionsBar> <DashboardActionsBar>
@@ -85,6 +99,43 @@ function AccountDrawerActionBar({
onClick={safeCallback(onDeleteAccount)} onClick={safeCallback(onDeleteAccount)}
/> />
</Can> </Can>
{!account.active && (
<>
<NavbarDivider />
<Button
className={CLASSES.MINIMAL}
text={'Activate'}
intent={Intent.SUCCESS}
onClick={handleActivateBtnClick}
/>
</>
)}
{!!account.active && (
<>
<NavbarDivider />
<Popover
minimal={true}
interactionKind={PopoverInteractionKind.CLICK}
position={Position.BOTTOM_LEFT}
modifiers={{
offset: { offset: '0, 4' },
}}
content={
<Menu>
<MenuItem
onClick={handleInactivateBtnClick}
text={'Inactivate'}
/>
</Menu>
}
>
<Button
icon={<Icon icon="more-vert" iconSize={16} />}
minimal={true}
/>
</Popover>
</>
)}
</NavbarGroup> </NavbarGroup>
</DashboardActionsBar> </DashboardActionsBar>
); );