mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-20 06:40:31 +00:00
Merge pull request #304 from ANasouf/BIG-53-Add-approve-reject-buttons-on-action-bar-of-the-estimate-details-drawer
feat(webapp): add approve/reject to action bar of estimate details dr…
This commit is contained in:
@@ -1,5 +1,4 @@
|
|||||||
// @ts-nocheck
|
// @ts-nocheck
|
||||||
import React from 'react';
|
|
||||||
import { useHistory } from 'react-router-dom';
|
import { useHistory } from 'react-router-dom';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
@@ -22,6 +21,7 @@ import {
|
|||||||
Icon,
|
Icon,
|
||||||
FormattedMessage as T,
|
FormattedMessage as T,
|
||||||
Can,
|
Can,
|
||||||
|
Choose,
|
||||||
} from '@/components';
|
} from '@/components';
|
||||||
|
|
||||||
import { compose } from '@/utils';
|
import { compose } from '@/utils';
|
||||||
@@ -52,7 +52,6 @@ function EstimateDetailActionsBar({
|
|||||||
history.push(`/estimates/${estimateId}/edit`);
|
history.push(`/estimates/${estimateId}/edit`);
|
||||||
closeDrawer(DRAWERS.ESTIMATE_DETAILS);
|
closeDrawer(DRAWERS.ESTIMATE_DETAILS);
|
||||||
};
|
};
|
||||||
|
|
||||||
// Handle delete sale estimate.
|
// Handle delete sale estimate.
|
||||||
const handleDeleteEstimate = () => {
|
const handleDeleteEstimate = () => {
|
||||||
openAlert('estimate-delete', { estimateId });
|
openAlert('estimate-delete', { estimateId });
|
||||||
@@ -83,6 +82,7 @@ function EstimateDetailActionsBar({
|
|||||||
/>
|
/>
|
||||||
<NavbarDivider />
|
<NavbarDivider />
|
||||||
</Can>
|
</Can>
|
||||||
|
|
||||||
<Can I={SaleEstimateAction.View} a={AbilitySubject.Estimate}>
|
<Can I={SaleEstimateAction.View} a={AbilitySubject.Estimate}>
|
||||||
<Button
|
<Button
|
||||||
className={Classes.MINIMAL}
|
className={Classes.MINIMAL}
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
// @ts-nocheck
|
// @ts-nocheck
|
||||||
import React from 'react';
|
|
||||||
import {
|
import {
|
||||||
Intent,
|
Intent,
|
||||||
Button,
|
Button,
|
||||||
@@ -9,9 +8,15 @@ import {
|
|||||||
MenuItem,
|
MenuItem,
|
||||||
Menu,
|
Menu,
|
||||||
Tag,
|
Tag,
|
||||||
|
MenuDivider,
|
||||||
|
Classes,
|
||||||
} from '@blueprintjs/core';
|
} from '@blueprintjs/core';
|
||||||
|
import * as R from 'ramda';
|
||||||
|
|
||||||
import { Icon, T, Choose } from '@/components';
|
import { Icon, T, Choose, Can } from '@/components';
|
||||||
|
import { AbilitySubject, SaleEstimateAction } from '@/constants/abilityOption';
|
||||||
|
import withAlertsActions from '@/containers/Alert/withAlertActions';
|
||||||
|
import { useEstimateDetailDrawerContext } from './EstimateDetailDrawerProvider';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Estimate details status.
|
* Estimate details status.
|
||||||
@@ -49,25 +54,85 @@ export function EstimateDetailsStatus({ estimate }) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function EstimateMoreMenuItems({ payload: { onNotifyViaSMS } }) {
|
export const EstimateMoreMenuItems = R.compose(withAlertsActions)(
|
||||||
return (
|
({
|
||||||
<Popover
|
// # withAlertsActions,
|
||||||
minimal={true}
|
openAlert,
|
||||||
content={
|
|
||||||
<Menu>
|
// # rest
|
||||||
<MenuItem
|
payload: { onNotifyViaSMS },
|
||||||
onClick={onNotifyViaSMS}
|
}) => {
|
||||||
text={<T id={'notify_via_sms.dialog.notify_via_sms'} />}
|
const { estimateId, estimate } = useEstimateDetailDrawerContext();
|
||||||
/>
|
|
||||||
</Menu>
|
// Handle cancel/confirm estimate approve.
|
||||||
}
|
const handleApproveEstimate = () => {
|
||||||
interactionKind={PopoverInteractionKind.CLICK}
|
openAlert('estimate-Approve', { estimateId });
|
||||||
position={Position.BOTTOM_LEFT}
|
};
|
||||||
modifiers={{
|
// Handle cancel/confirm estimate reject.
|
||||||
offset: { offset: '0, 4' },
|
const handleRejectEstimate = () => {
|
||||||
}}
|
openAlert('estimate-reject', { estimateId });
|
||||||
>
|
};
|
||||||
<Button icon={<Icon icon="more-vert" iconSize={16} />} minimal={true} />
|
|
||||||
</Popover>
|
return (
|
||||||
);
|
<Popover
|
||||||
}
|
minimal={true}
|
||||||
|
content={
|
||||||
|
<Menu>
|
||||||
|
<MenuItem
|
||||||
|
onClick={onNotifyViaSMS}
|
||||||
|
text={<T id={'notify_via_sms.dialog.notify_via_sms'} />}
|
||||||
|
/>
|
||||||
|
<MenuDivider />
|
||||||
|
<Choose>
|
||||||
|
<Choose.When
|
||||||
|
condition={estimate.is_delivered && estimate.is_rejected}
|
||||||
|
>
|
||||||
|
<Can I={SaleEstimateAction.Edit} a={AbilitySubject.Estimate}>
|
||||||
|
<MenuItem
|
||||||
|
className={Classes.MINIMAL}
|
||||||
|
text={<T id={'mark_as_approved'} />}
|
||||||
|
onClick={handleApproveEstimate}
|
||||||
|
/>
|
||||||
|
</Can>
|
||||||
|
</Choose.When>
|
||||||
|
<Choose.When
|
||||||
|
condition={estimate.is_delivered && estimate.is_approved}
|
||||||
|
>
|
||||||
|
<Can I={SaleEstimateAction.Edit} a={AbilitySubject.Estimate}>
|
||||||
|
<MenuItem
|
||||||
|
className={Classes.MINIMAL}
|
||||||
|
text={<T id={'mark_as_rejected'} />}
|
||||||
|
onClick={handleRejectEstimate}
|
||||||
|
/>
|
||||||
|
</Can>
|
||||||
|
</Choose.When>
|
||||||
|
<Choose.When condition={estimate.is_delivered}>
|
||||||
|
<Can I={SaleEstimateAction.Edit} a={AbilitySubject.Estimate}>
|
||||||
|
<MenuItem
|
||||||
|
className={Classes.MINIMAL}
|
||||||
|
text={<T id={'mark_as_approved'} />}
|
||||||
|
onClick={handleApproveEstimate}
|
||||||
|
/>
|
||||||
|
</Can>
|
||||||
|
<Can I={SaleEstimateAction.Edit} a={AbilitySubject.Estimate}>
|
||||||
|
<MenuItem
|
||||||
|
className={Classes.MINIMAL}
|
||||||
|
text={<T id={'mark_as_rejected'} />}
|
||||||
|
onClick={handleRejectEstimate}
|
||||||
|
/>
|
||||||
|
</Can>
|
||||||
|
</Choose.When>
|
||||||
|
</Choose>
|
||||||
|
</Menu>
|
||||||
|
}
|
||||||
|
interactionKind={PopoverInteractionKind.CLICK}
|
||||||
|
position={Position.BOTTOM_LEFT}
|
||||||
|
modifiers={{
|
||||||
|
offset: { offset: '0, 4' },
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Button icon={<Icon icon="more-vert" iconSize={16} />} minimal={true} />
|
||||||
|
</Popover>
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user