mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-21 15:20:34 +00:00
feat(webapp): add approve/reject to action bar of estimate details drawer
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';
|
||||||
@@ -42,7 +42,7 @@ function EstimateDetailActionsBar({
|
|||||||
closeDrawer,
|
closeDrawer,
|
||||||
}) {
|
}) {
|
||||||
// Estimate details drawer context.
|
// Estimate details drawer context.
|
||||||
const { estimateId } = useEstimateDetailDrawerContext();
|
const { estimateId, estimate } = useEstimateDetailDrawerContext();
|
||||||
|
|
||||||
// History.
|
// History.
|
||||||
const history = useHistory();
|
const history = useHistory();
|
||||||
@@ -53,6 +53,16 @@ function EstimateDetailActionsBar({
|
|||||||
closeDrawer(DRAWERS.ESTIMATE_DETAILS);
|
closeDrawer(DRAWERS.ESTIMATE_DETAILS);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Handle cancel/confirm estimate approve.
|
||||||
|
const handleApproveEstimate = () => {
|
||||||
|
openAlert('estimate-Approve', { estimateId });
|
||||||
|
};
|
||||||
|
|
||||||
|
// Handle cancel/confirm estimate reject.
|
||||||
|
const handleRejectEstimate = () => {
|
||||||
|
openAlert('estimate-reject', { estimateId });
|
||||||
|
};
|
||||||
|
|
||||||
// Handle delete sale estimate.
|
// Handle delete sale estimate.
|
||||||
const handleDeleteEstimate = () => {
|
const handleDeleteEstimate = () => {
|
||||||
openAlert('estimate-delete', { estimateId });
|
openAlert('estimate-delete', { estimateId });
|
||||||
@@ -83,6 +93,50 @@ function EstimateDetailActionsBar({
|
|||||||
/>
|
/>
|
||||||
<NavbarDivider />
|
<NavbarDivider />
|
||||||
</Can>
|
</Can>
|
||||||
|
<Choose>
|
||||||
|
<Choose.When
|
||||||
|
condition={estimate.is_delivered && estimate.is_rejected}
|
||||||
|
>
|
||||||
|
<Can I={SaleEstimateAction.Edit} a={AbilitySubject.Estimate}>
|
||||||
|
<Button
|
||||||
|
className={Classes.MINIMAL}
|
||||||
|
icon={<Icon icon="check" />}
|
||||||
|
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}>
|
||||||
|
<Button
|
||||||
|
className={Classes.MINIMAL}
|
||||||
|
icon={<Icon icon="close-black" />}
|
||||||
|
text={<T id={'mark_as_rejected'} />}
|
||||||
|
onClick={handleRejectEstimate}
|
||||||
|
/>
|
||||||
|
</Can>
|
||||||
|
</Choose.When>
|
||||||
|
<Choose.When condition={estimate.is_delivered}>
|
||||||
|
<Can I={SaleEstimateAction.Edit} a={AbilitySubject.Estimate}>
|
||||||
|
<Button
|
||||||
|
className={Classes.MINIMAL}
|
||||||
|
icon={<Icon icon="check" />}
|
||||||
|
text={<T id={'mark_as_approved'} />}
|
||||||
|
onClick={handleApproveEstimate}
|
||||||
|
/>
|
||||||
|
</Can>
|
||||||
|
<Can I={SaleEstimateAction.Edit} a={AbilitySubject.Estimate}>
|
||||||
|
<Button
|
||||||
|
className={Classes.MINIMAL}
|
||||||
|
icon={<Icon icon="close-black" />}
|
||||||
|
text={<T id={'mark_as_rejected'} />}
|
||||||
|
onClick={handleRejectEstimate}
|
||||||
|
/>
|
||||||
|
</Can>
|
||||||
|
</Choose.When>
|
||||||
|
</Choose>
|
||||||
<Can I={SaleEstimateAction.View} a={AbilitySubject.Estimate}>
|
<Can I={SaleEstimateAction.View} a={AbilitySubject.Estimate}>
|
||||||
<Button
|
<Button
|
||||||
className={Classes.MINIMAL}
|
className={Classes.MINIMAL}
|
||||||
|
|||||||
Reference in New Issue
Block a user