mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-20 14:50:32 +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,7 +54,25 @@ export function EstimateDetailsStatus({ estimate }) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function EstimateMoreMenuItems({ payload: { onNotifyViaSMS } }) {
|
export const EstimateMoreMenuItems = R.compose(withAlertsActions)(
|
||||||
|
({
|
||||||
|
// # withAlertsActions,
|
||||||
|
openAlert,
|
||||||
|
|
||||||
|
// # rest
|
||||||
|
payload: { onNotifyViaSMS },
|
||||||
|
}) => {
|
||||||
|
const { estimateId, estimate } = useEstimateDetailDrawerContext();
|
||||||
|
|
||||||
|
// Handle cancel/confirm estimate approve.
|
||||||
|
const handleApproveEstimate = () => {
|
||||||
|
openAlert('estimate-Approve', { estimateId });
|
||||||
|
};
|
||||||
|
// Handle cancel/confirm estimate reject.
|
||||||
|
const handleRejectEstimate = () => {
|
||||||
|
openAlert('estimate-reject', { estimateId });
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Popover
|
<Popover
|
||||||
minimal={true}
|
minimal={true}
|
||||||
@@ -59,6 +82,47 @@ export function EstimateMoreMenuItems({ payload: { onNotifyViaSMS } }) {
|
|||||||
onClick={onNotifyViaSMS}
|
onClick={onNotifyViaSMS}
|
||||||
text={<T id={'notify_via_sms.dialog.notify_via_sms'} />}
|
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>
|
</Menu>
|
||||||
}
|
}
|
||||||
interactionKind={PopoverInteractionKind.CLICK}
|
interactionKind={PopoverInteractionKind.CLICK}
|
||||||
@@ -70,4 +134,5 @@ export function EstimateMoreMenuItems({ payload: { onNotifyViaSMS } }) {
|
|||||||
<Button icon={<Icon icon="more-vert" iconSize={16} />} minimal={true} />
|
<Button icon={<Icon icon="more-vert" iconSize={16} />} minimal={true} />
|
||||||
</Popover>
|
</Popover>
|
||||||
);
|
);
|
||||||
}
|
},
|
||||||
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user