diff --git a/packages/webapp/src/containers/TaxRates/drawers/TaxRateDetailsDrawer/TaxRateDetailsContentActionsBar.tsx b/packages/webapp/src/containers/TaxRates/drawers/TaxRateDetailsDrawer/TaxRateDetailsContentActionsBar.tsx
index e87d6f63b..758372bc2 100644
--- a/packages/webapp/src/containers/TaxRates/drawers/TaxRateDetailsDrawer/TaxRateDetailsContentActionsBar.tsx
+++ b/packages/webapp/src/containers/TaxRates/drawers/TaxRateDetailsDrawer/TaxRateDetailsContentActionsBar.tsx
@@ -4,17 +4,26 @@ import {
Button,
Classes,
Intent,
+ Menu,
+ MenuItem,
NavbarDivider,
NavbarGroup,
+ Popover,
+ PopoverInteractionKind,
+ Position,
} from '@blueprintjs/core';
import * as R from 'ramda';
-import { Can, DashboardActionsBar, Icon } from '@/components';
+import { AppToaster, Can, DashboardActionsBar, Icon } from '@/components';
import { AbilitySubject, TaxRateAction } from '@/constants/abilityOption';
import withDrawerActions from '@/containers/Drawer/withDrawerActions';
import withAlertsActions from '@/containers/Alert/withAlertActions';
import withDialogActions from '@/containers/Dialog/withDialogActions';
import { useTaxRateDetailsContext } from './TaxRateDetailsContentBoot';
import { DialogsName } from '@/constants/dialogs';
+import {
+ useActivateTaxRate,
+ useInactivateTaxRate,
+} from '@/hooks/query/taxRates';
/**
* Tax rate details content actions bar.
@@ -27,7 +36,10 @@ function TaxRateDetailsContentActionsBar({
// #withAlertsActions
openAlert,
}) {
- const { taxRateId } = useTaxRateDetailsContext();
+ const { taxRateId, taxRate } = useTaxRateDetailsContext();
+
+ const { mutateAsync: activateTaxRateMutate } = useActivateTaxRate();
+ const { mutateAsync: inactivateTaxRateMutate } = useInactivateTaxRate();
// Handle edit tax rate.
const handleEditTaxRate = () => {
@@ -37,6 +49,38 @@ function TaxRateDetailsContentActionsBar({
const handleDeleteTaxRate = () => {
openAlert('tax-rate-delete', { taxRateId });
};
+ // Handle activate tax rate.
+ const handleActivateTaxRate = () => {
+ activateTaxRateMutate(taxRateId)
+ .then(() => {
+ AppToaster.show({
+ message: 'The tax rate has been activated successfully.',
+ intent: Intent.SUCCESS,
+ });
+ })
+ .catch(() => {
+ AppToaster.show({
+ message: 'Something went wrong.',
+ intent: Intent.DANGER,
+ });
+ });
+ };
+ // Handle inactivate tax rate.
+ const handleInactivateTaxRate = () => {
+ inactivateTaxRateMutate(taxRateId)
+ .then(() => {
+ AppToaster.show({
+ message: 'The tax rate has been inactivated successfully.',
+ intent: Intent.SUCCESS,
+ });
+ })
+ .catch(() => {
+ AppToaster.show({
+ message: 'Something went wrong.',
+ intent: Intent.DANGER,
+ });
+ });
+ };
return (