mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-22 07:40:32 +00:00
feat: print action when click on print button
This commit is contained in:
@@ -30,6 +30,7 @@ import withSettings from '@/containers/Settings/withSettings';
|
|||||||
import withSettingsActions from '@/containers/Settings/withSettingsActions';
|
import withSettingsActions from '@/containers/Settings/withSettingsActions';
|
||||||
import withDialogActions from '@/containers/Dialog/withDialogActions';
|
import withDialogActions from '@/containers/Dialog/withDialogActions';
|
||||||
|
|
||||||
|
import { useResourceExportPdf } from '@/hooks/query/FinancialReports/use-export-pdf';
|
||||||
import { compose } from '@/utils';
|
import { compose } from '@/utils';
|
||||||
import { DialogsName } from '@/constants/dialogs';
|
import { DialogsName } from '@/constants/dialogs';
|
||||||
|
|
||||||
@@ -50,7 +51,7 @@ function ManualJournalActionsBar({
|
|||||||
addSetting,
|
addSetting,
|
||||||
|
|
||||||
// #withDialogActions
|
// #withDialogActions
|
||||||
openDialog
|
openDialog,
|
||||||
}) {
|
}) {
|
||||||
// History context.
|
// History context.
|
||||||
const history = useHistory();
|
const history = useHistory();
|
||||||
@@ -58,6 +59,10 @@ function ManualJournalActionsBar({
|
|||||||
// Manual journals context.
|
// Manual journals context.
|
||||||
const { journalsViews, fields } = useManualJournalsContext();
|
const { journalsViews, fields } = useManualJournalsContext();
|
||||||
|
|
||||||
|
// Exports the given resource into pdf.
|
||||||
|
const { mutateAsync: exportPdf, isLoading: isExportPdfLoading } =
|
||||||
|
useResourceExportPdf();
|
||||||
|
|
||||||
// Manual journals refresh action.
|
// Manual journals refresh action.
|
||||||
const { refresh } = useRefreshJournals();
|
const { refresh } = useRefreshJournals();
|
||||||
|
|
||||||
@@ -91,6 +96,11 @@ function ManualJournalActionsBar({
|
|||||||
openDialog(DialogsName.Export, { resource: 'manual_journal' });
|
openDialog(DialogsName.Export, { resource: 'manual_journal' });
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Handle the pdf print button click.
|
||||||
|
const handlePdfPrintBtnSubmit = () => {
|
||||||
|
exportPdf({ resource: 'ManualJournal' });
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<DashboardActionsBar>
|
<DashboardActionsBar>
|
||||||
<NavbarGroup>
|
<NavbarGroup>
|
||||||
@@ -134,10 +144,13 @@ function ManualJournalActionsBar({
|
|||||||
/>
|
/>
|
||||||
</If>
|
</If>
|
||||||
|
|
||||||
|
<NavbarDivider />
|
||||||
<Button
|
<Button
|
||||||
className={Classes.MINIMAL}
|
className={Classes.MINIMAL}
|
||||||
icon={<Icon icon="print-16" iconSize={16} />}
|
icon={<Icon icon="print-16" iconSize={16} />}
|
||||||
text={<T id={'print'} />}
|
text={<T id={'print'} />}
|
||||||
|
onClick={handlePdfPrintBtnSubmit}
|
||||||
|
disabled={isExportPdfLoading}
|
||||||
/>
|
/>
|
||||||
<Button
|
<Button
|
||||||
className={Classes.MINIMAL}
|
className={Classes.MINIMAL}
|
||||||
|
|||||||
@@ -26,8 +26,10 @@ import {
|
|||||||
import { AccountAction, AbilitySubject } from '@/constants/abilityOption';
|
import { AccountAction, AbilitySubject } from '@/constants/abilityOption';
|
||||||
import { DialogsName } from '@/constants/dialogs';
|
import { DialogsName } from '@/constants/dialogs';
|
||||||
|
|
||||||
|
import { useHistory } from 'react-router-dom';
|
||||||
import { useRefreshAccounts } from '@/hooks/query/accounts';
|
import { useRefreshAccounts } from '@/hooks/query/accounts';
|
||||||
import { useAccountsChartContext } from './AccountsChartProvider';
|
import { useAccountsChartContext } from './AccountsChartProvider';
|
||||||
|
import { useResourceExportPdf } from '@/hooks/query/FinancialReports/use-export-pdf';
|
||||||
|
|
||||||
import withAccounts from './withAccounts';
|
import withAccounts from './withAccounts';
|
||||||
import withAccountsTableActions from './withAccountsTableActions';
|
import withAccountsTableActions from './withAccountsTableActions';
|
||||||
@@ -37,7 +39,6 @@ import withSettings from '@/containers/Settings/withSettings';
|
|||||||
import withSettingsActions from '@/containers/Settings/withSettingsActions';
|
import withSettingsActions from '@/containers/Settings/withSettingsActions';
|
||||||
|
|
||||||
import { compose } from '@/utils';
|
import { compose } from '@/utils';
|
||||||
import { useHistory } from 'react-router-dom';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Accounts actions bar.
|
* Accounts actions bar.
|
||||||
@@ -57,22 +58,18 @@ function AccountsActionsBar({
|
|||||||
// #withAccountsTableActions
|
// #withAccountsTableActions
|
||||||
setAccountsTableState,
|
setAccountsTableState,
|
||||||
|
|
||||||
// #ownProps
|
|
||||||
onFilterChanged,
|
|
||||||
|
|
||||||
// #withSettings
|
// #withSettings
|
||||||
accountsTableSize,
|
accountsTableSize,
|
||||||
|
|
||||||
// #withSettingsActions
|
// #withSettingsActions
|
||||||
addSetting,
|
addSetting,
|
||||||
}) {
|
}) {
|
||||||
const { resourceViews, fields } = useAccountsChartContext();
|
|
||||||
|
|
||||||
const history = useHistory();
|
const history = useHistory();
|
||||||
|
|
||||||
const onClickNewAccount = () => {
|
const { resourceViews, fields } = useAccountsChartContext();
|
||||||
openDialog(DialogsName.AccountForm, {});
|
|
||||||
};
|
const { mutateAsync: exportPdf, isLoading: isExportPdfLoading } =
|
||||||
|
useResourceExportPdf();
|
||||||
|
|
||||||
// Accounts refresh action.
|
// Accounts refresh action.
|
||||||
const { refresh } = useRefreshAccounts();
|
const { refresh } = useRefreshAccounts();
|
||||||
@@ -81,35 +78,29 @@ function AccountsActionsBar({
|
|||||||
const handleBulkDelete = () => {
|
const handleBulkDelete = () => {
|
||||||
openAlert('accounts-bulk-delete', { accountsIds: accountsSelectedRows });
|
openAlert('accounts-bulk-delete', { accountsIds: accountsSelectedRows });
|
||||||
};
|
};
|
||||||
|
|
||||||
// Handle bulk accounts activate.
|
// Handle bulk accounts activate.
|
||||||
const handelBulkActivate = () => {
|
const handelBulkActivate = () => {
|
||||||
openAlert('accounts-bulk-activate', { accountsIds: accountsSelectedRows });
|
openAlert('accounts-bulk-activate', { accountsIds: accountsSelectedRows });
|
||||||
};
|
};
|
||||||
|
|
||||||
// Handle bulk accounts inactivate.
|
// Handle bulk accounts inactivate.
|
||||||
const handelBulkInactive = () => {
|
const handelBulkInactive = () => {
|
||||||
openAlert('accounts-bulk-inactivate', {
|
openAlert('accounts-bulk-inactivate', {
|
||||||
accountsIds: accountsSelectedRows,
|
accountsIds: accountsSelectedRows,
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
// Handle tab changing.
|
// Handle tab changing.
|
||||||
const handleTabChange = (view) => {
|
const handleTabChange = (view) => {
|
||||||
setAccountsTableState({ viewSlug: view ? view.slug : null });
|
setAccountsTableState({ viewSlug: view ? view.slug : null });
|
||||||
};
|
};
|
||||||
|
|
||||||
// Handle inactive switch changing.
|
// Handle inactive switch changing.
|
||||||
const handleInactiveSwitchChange = (event) => {
|
const handleInactiveSwitchChange = (event) => {
|
||||||
const checked = event.target.checked;
|
const checked = event.target.checked;
|
||||||
setAccountsTableState({ inactiveMode: checked });
|
setAccountsTableState({ inactiveMode: checked });
|
||||||
};
|
};
|
||||||
|
|
||||||
// Handle click a refresh accounts
|
// Handle click a refresh accounts
|
||||||
const handleRefreshBtnClick = () => {
|
const handleRefreshBtnClick = () => {
|
||||||
refresh();
|
refresh();
|
||||||
};
|
};
|
||||||
|
|
||||||
// Handle table row size change.
|
// Handle table row size change.
|
||||||
const handleTableRowSizeChange = (size) => {
|
const handleTableRowSizeChange = (size) => {
|
||||||
addSetting('accounts', 'tableSize', size);
|
addSetting('accounts', 'tableSize', size);
|
||||||
@@ -122,6 +113,14 @@ function AccountsActionsBar({
|
|||||||
const handleExportBtnClick = () => {
|
const handleExportBtnClick = () => {
|
||||||
openDialog(DialogsName.Export, { resource: 'account' });
|
openDialog(DialogsName.Export, { resource: 'account' });
|
||||||
};
|
};
|
||||||
|
// Handle the print button click.
|
||||||
|
const handlePrintBtnClick = () => {
|
||||||
|
exportPdf({ resource: 'Account' });
|
||||||
|
};
|
||||||
|
// Handle click new account.
|
||||||
|
const onClickNewAccount = () => {
|
||||||
|
openDialog(DialogsName.AccountForm, {});
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<DashboardActionsBar>
|
<DashboardActionsBar>
|
||||||
@@ -185,6 +184,8 @@ function AccountsActionsBar({
|
|||||||
className={Classes.MINIMAL}
|
className={Classes.MINIMAL}
|
||||||
icon={<Icon icon="print-16" iconSize={16} />}
|
icon={<Icon icon="print-16" iconSize={16} />}
|
||||||
text={<T id={'print'} />}
|
text={<T id={'print'} />}
|
||||||
|
disabled={isExportPdfLoading}
|
||||||
|
onClick={handlePrintBtnClick}
|
||||||
/>
|
/>
|
||||||
<Button
|
<Button
|
||||||
className={Classes.MINIMAL}
|
className={Classes.MINIMAL}
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ import {
|
|||||||
|
|
||||||
import { useCustomersListContext } from './CustomersListProvider';
|
import { useCustomersListContext } from './CustomersListProvider';
|
||||||
import { useRefreshCustomers } from '@/hooks/query/customers';
|
import { useRefreshCustomers } from '@/hooks/query/customers';
|
||||||
|
import { useResourceExportPdf } from '@/hooks/query/FinancialReports/use-export-pdf';
|
||||||
|
|
||||||
import withCustomers from './withCustomers';
|
import withCustomers from './withCustomers';
|
||||||
import withCustomersActions from './withCustomersActions';
|
import withCustomersActions from './withCustomersActions';
|
||||||
@@ -70,6 +71,10 @@ function CustomerActionsBar({
|
|||||||
// Customers refresh action.
|
// Customers refresh action.
|
||||||
const { refresh } = useRefreshCustomers();
|
const { refresh } = useRefreshCustomers();
|
||||||
|
|
||||||
|
// Exports the given resource into pdf.
|
||||||
|
const { mutateAsync: exportPdf, isLoading: isExportPdfLoading } =
|
||||||
|
useResourceExportPdf();
|
||||||
|
|
||||||
const onClickNewCustomer = () => {
|
const onClickNewCustomer = () => {
|
||||||
history.push('/customers/new');
|
history.push('/customers/new');
|
||||||
};
|
};
|
||||||
@@ -109,6 +114,10 @@ function CustomerActionsBar({
|
|||||||
const handleExportBtnClick = () => {
|
const handleExportBtnClick = () => {
|
||||||
openDialog(DialogsName.Export, { resource: 'customer' });
|
openDialog(DialogsName.Export, { resource: 'customer' });
|
||||||
};
|
};
|
||||||
|
// Handle the print button click.
|
||||||
|
const handlePrintBtnClick = () => {
|
||||||
|
exportPdf({ resource: 'Customer' });
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<DashboardActionsBar>
|
<DashboardActionsBar>
|
||||||
@@ -154,6 +163,14 @@ function CustomerActionsBar({
|
|||||||
onClick={handleBulkDelete}
|
onClick={handleBulkDelete}
|
||||||
/>
|
/>
|
||||||
</If>
|
</If>
|
||||||
|
<NavbarDivider />
|
||||||
|
<Button
|
||||||
|
className={Classes.MINIMAL}
|
||||||
|
icon={<Icon icon="print-16" iconSize={16} />}
|
||||||
|
text={<T id={'print'} />}
|
||||||
|
disabled={isExportPdfLoading}
|
||||||
|
onClick={handlePrintBtnClick}
|
||||||
|
/>
|
||||||
<Button
|
<Button
|
||||||
className={Classes.MINIMAL}
|
className={Classes.MINIMAL}
|
||||||
icon={<Icon icon="file-import-16" iconSize={16} />}
|
icon={<Icon icon="file-import-16" iconSize={16} />}
|
||||||
|
|||||||
@@ -23,8 +23,11 @@ import {
|
|||||||
} from '@/components';
|
} from '@/components';
|
||||||
|
|
||||||
import { ExpenseAction, AbilitySubject } from '@/constants/abilityOption';
|
import { ExpenseAction, AbilitySubject } from '@/constants/abilityOption';
|
||||||
|
import { DialogsName } from '@/constants/dialogs';
|
||||||
|
|
||||||
import { useRefreshExpenses } from '@/hooks/query/expenses';
|
import { useRefreshExpenses } from '@/hooks/query/expenses';
|
||||||
import { useExpensesListContext } from './ExpensesListProvider';
|
import { useExpensesListContext } from './ExpensesListProvider';
|
||||||
|
import { useResourceExportPdf } from '@/hooks/query/FinancialReports/use-export-pdf';
|
||||||
|
|
||||||
import withExpenses from './withExpenses';
|
import withExpenses from './withExpenses';
|
||||||
import withExpensesActions from './withExpensesActions';
|
import withExpensesActions from './withExpensesActions';
|
||||||
@@ -33,7 +36,6 @@ import withDialogActions from '@/containers/Dialog/withDialogActions';
|
|||||||
import withSettings from '@/containers/Settings/withSettings';
|
import withSettings from '@/containers/Settings/withSettings';
|
||||||
|
|
||||||
import { compose } from '@/utils';
|
import { compose } from '@/utils';
|
||||||
import { DialogsName } from '@/constants/dialogs';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Expenses actions bar.
|
* Expenses actions bar.
|
||||||
@@ -60,6 +62,10 @@ function ExpensesActionsBar({
|
|||||||
// Expenses list context.
|
// Expenses list context.
|
||||||
const { expensesViews, fields } = useExpensesListContext();
|
const { expensesViews, fields } = useExpensesListContext();
|
||||||
|
|
||||||
|
// Exports the given resource into pdf.
|
||||||
|
const { mutateAsync: exportPdf, isLoading: isExportPdfLoading } =
|
||||||
|
useResourceExportPdf();
|
||||||
|
|
||||||
// Expenses refresh action.
|
// Expenses refresh action.
|
||||||
const { refresh } = useRefreshExpenses();
|
const { refresh } = useRefreshExpenses();
|
||||||
|
|
||||||
@@ -92,6 +98,10 @@ function ExpensesActionsBar({
|
|||||||
const handleExportBtnClick = () => {
|
const handleExportBtnClick = () => {
|
||||||
openDialog(DialogsName.Export, { resource: 'expense' });
|
openDialog(DialogsName.Export, { resource: 'expense' });
|
||||||
};
|
};
|
||||||
|
// Handles the print button click.
|
||||||
|
const handlePrintBtnClick = () => {
|
||||||
|
exportPdf({ resource: 'Expense' });
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<DashboardActionsBar>
|
<DashboardActionsBar>
|
||||||
@@ -135,11 +145,13 @@ function ExpensesActionsBar({
|
|||||||
onClick={handleBulkDelete}
|
onClick={handleBulkDelete}
|
||||||
/>
|
/>
|
||||||
</If>
|
</If>
|
||||||
|
<NavbarDivider />
|
||||||
<Button
|
<Button
|
||||||
className={Classes.MINIMAL}
|
className={Classes.MINIMAL}
|
||||||
icon={<Icon icon="print-16" iconSize={16} />}
|
icon={<Icon icon="print-16" iconSize={16} />}
|
||||||
text={<T id={'print'} />}
|
text={<T id={'print'} />}
|
||||||
|
onClick={handlePrintBtnClick}
|
||||||
|
disabled={isExportPdfLoading}
|
||||||
/>
|
/>
|
||||||
<Button
|
<Button
|
||||||
className={Classes.MINIMAL}
|
className={Classes.MINIMAL}
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ import {
|
|||||||
import { ItemAction, AbilitySubject } from '@/constants/abilityOption';
|
import { ItemAction, AbilitySubject } from '@/constants/abilityOption';
|
||||||
import { useItemsListContext } from './ItemsListProvider';
|
import { useItemsListContext } from './ItemsListProvider';
|
||||||
import { useRefreshItems } from '@/hooks/query/items';
|
import { useRefreshItems } from '@/hooks/query/items';
|
||||||
|
import { useResourceExportPdf } from '@/hooks/query/FinancialReports/use-export-pdf';
|
||||||
|
|
||||||
import withItems from './withItems';
|
import withItems from './withItems';
|
||||||
import withItemsActions from './withItemsActions';
|
import withItemsActions from './withItemsActions';
|
||||||
@@ -60,11 +61,15 @@ function ItemsActionsBar({
|
|||||||
addSetting,
|
addSetting,
|
||||||
|
|
||||||
// #withDialogActions
|
// #withDialogActions
|
||||||
openDialog
|
openDialog,
|
||||||
}) {
|
}) {
|
||||||
// Items list context.
|
// Items list context.
|
||||||
const { itemsViews, fields } = useItemsListContext();
|
const { itemsViews, fields } = useItemsListContext();
|
||||||
|
|
||||||
|
//
|
||||||
|
const { mutateAsync: exportPdf, isLoading: isExportPdfLoading } =
|
||||||
|
useResourceExportPdf();
|
||||||
|
|
||||||
// Items refresh action.
|
// Items refresh action.
|
||||||
const { refresh } = useRefreshItems();
|
const { refresh } = useRefreshItems();
|
||||||
|
|
||||||
@@ -107,7 +112,12 @@ function ItemsActionsBar({
|
|||||||
// Handle the export button click.
|
// Handle the export button click.
|
||||||
const handleExportBtnClick = () => {
|
const handleExportBtnClick = () => {
|
||||||
openDialog(DialogsName.Export, { resource: 'item' });
|
openDialog(DialogsName.Export, { resource: 'item' });
|
||||||
}
|
};
|
||||||
|
|
||||||
|
// Handle the print button click.
|
||||||
|
const handlePrintBtnClick = () => {
|
||||||
|
exportPdf({ resource: 'Item' });
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<DashboardActionsBar>
|
<DashboardActionsBar>
|
||||||
@@ -153,7 +163,13 @@ function ItemsActionsBar({
|
|||||||
onClick={handleBulkDelete}
|
onClick={handleBulkDelete}
|
||||||
/>
|
/>
|
||||||
</If>
|
</If>
|
||||||
|
<Button
|
||||||
|
className={Classes.MINIMAL}
|
||||||
|
icon={<Icon icon={'print-16'} iconSize={'16'} />}
|
||||||
|
text={<T id={'print'} />}
|
||||||
|
disabled={isExportPdfLoading}
|
||||||
|
onClick={handlePrintBtnClick}
|
||||||
|
/>
|
||||||
<Button
|
<Button
|
||||||
className={Classes.MINIMAL}
|
className={Classes.MINIMAL}
|
||||||
icon={<Icon icon="file-import-16" iconSize={16} />}
|
icon={<Icon icon="file-import-16" iconSize={16} />}
|
||||||
@@ -204,5 +220,5 @@ export default compose(
|
|||||||
})),
|
})),
|
||||||
withItemsActions,
|
withItemsActions,
|
||||||
withAlertActions,
|
withAlertActions,
|
||||||
withDialogActions
|
withDialogActions,
|
||||||
)(ItemsActionsBar);
|
)(ItemsActionsBar);
|
||||||
|
|||||||
@@ -28,11 +28,13 @@ import withBills from './withBills';
|
|||||||
import withBillsActions from './withBillsActions';
|
import withBillsActions from './withBillsActions';
|
||||||
import withSettings from '@/containers/Settings/withSettings';
|
import withSettings from '@/containers/Settings/withSettings';
|
||||||
import withSettingsActions from '@/containers/Settings/withSettingsActions';
|
import withSettingsActions from '@/containers/Settings/withSettingsActions';
|
||||||
|
import withDialogActions from '@/containers/Dialog/withDialogActions';
|
||||||
|
|
||||||
import { useBillsListContext } from './BillsListProvider';
|
import { useBillsListContext } from './BillsListProvider';
|
||||||
import { useRefreshBills } from '@/hooks/query/bills';
|
import { useRefreshBills } from '@/hooks/query/bills';
|
||||||
|
import { useResourceExportPdf } from '@/hooks/query/FinancialReports/use-export-pdf';
|
||||||
|
|
||||||
import { compose } from '@/utils';
|
import { compose } from '@/utils';
|
||||||
import withDialogActions from '@/containers/Dialog/withDialogActions';
|
|
||||||
import { DialogsName } from '@/constants/dialogs';
|
import { DialogsName } from '@/constants/dialogs';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -62,11 +64,14 @@ function BillActionsBar({
|
|||||||
// Bills list context.
|
// Bills list context.
|
||||||
const { billsViews, fields } = useBillsListContext();
|
const { billsViews, fields } = useBillsListContext();
|
||||||
|
|
||||||
|
// Exports the given resource into pdf.
|
||||||
|
const { mutateAsync: exportPdf, isLoading: isExportPdfLoading } =
|
||||||
|
useResourceExportPdf();
|
||||||
|
|
||||||
// Handle click a new bill.
|
// Handle click a new bill.
|
||||||
const handleClickNewBill = () => {
|
const handleClickNewBill = () => {
|
||||||
history.push('/bills/new');
|
history.push('/bills/new');
|
||||||
};
|
};
|
||||||
|
|
||||||
// Handle tab change.
|
// Handle tab change.
|
||||||
const handleTabChange = (view) => {
|
const handleTabChange = (view) => {
|
||||||
setBillsTableState({
|
setBillsTableState({
|
||||||
@@ -77,21 +82,22 @@ function BillActionsBar({
|
|||||||
const handleRefreshBtnClick = () => {
|
const handleRefreshBtnClick = () => {
|
||||||
refresh();
|
refresh();
|
||||||
};
|
};
|
||||||
|
|
||||||
// Handle table row size change.
|
// Handle table row size change.
|
||||||
const handleTableRowSizeChange = (size) => {
|
const handleTableRowSizeChange = (size) => {
|
||||||
addSetting('bills', 'tableSize', size);
|
addSetting('bills', 'tableSize', size);
|
||||||
};
|
};
|
||||||
|
|
||||||
// Handle the import button click.
|
// Handle the import button click.
|
||||||
const handleImportBtnClick = () => {
|
const handleImportBtnClick = () => {
|
||||||
history.push('/bills/import');
|
history.push('/bills/import');
|
||||||
};
|
};
|
||||||
|
|
||||||
// Handle the export button click.
|
// Handle the export button click.
|
||||||
const handleExportBtnClick = () => {
|
const handleExportBtnClick = () => {
|
||||||
openDialog(DialogsName.Export, { resource: 'bill' });
|
openDialog(DialogsName.Export, { resource: 'bill' });
|
||||||
};
|
};
|
||||||
|
// Handle the print button click.
|
||||||
|
const handlePrintBtnClick = () => {
|
||||||
|
exportPdf({ resource: 'Bill' });
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<DashboardActionsBar>
|
<DashboardActionsBar>
|
||||||
@@ -133,13 +139,15 @@ function BillActionsBar({
|
|||||||
icon={<Icon icon={'trash-16'} iconSize={16} />}
|
icon={<Icon icon={'trash-16'} iconSize={16} />}
|
||||||
text={<T id={'delete'} />}
|
text={<T id={'delete'} />}
|
||||||
intent={Intent.DANGER}
|
intent={Intent.DANGER}
|
||||||
// onClick={handleBulkDelete}
|
|
||||||
/>
|
/>
|
||||||
</If>
|
</If>
|
||||||
|
<NavbarDivider />
|
||||||
<Button
|
<Button
|
||||||
className={Classes.MINIMAL}
|
className={Classes.MINIMAL}
|
||||||
icon={<Icon icon={'print-16'} iconSize={'16'} />}
|
icon={<Icon icon={'print-16'} iconSize={'16'} />}
|
||||||
text={<T id={'print'} />}
|
text={<T id={'print'} />}
|
||||||
|
disabled={isExportPdfLoading}
|
||||||
|
onClick={handlePrintBtnClick}
|
||||||
/>
|
/>
|
||||||
<Button
|
<Button
|
||||||
className={Classes.MINIMAL}
|
className={Classes.MINIMAL}
|
||||||
@@ -153,7 +161,6 @@ function BillActionsBar({
|
|||||||
text={<T id={'export'} />}
|
text={<T id={'export'} />}
|
||||||
onClick={handleExportBtnClick}
|
onClick={handleExportBtnClick}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<NavbarDivider />
|
<NavbarDivider />
|
||||||
<DashboardRowsHeightButton
|
<DashboardRowsHeightButton
|
||||||
initialValue={billsTableSize}
|
initialValue={billsTableSize}
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ import {
|
|||||||
} from '@/components';
|
} from '@/components';
|
||||||
|
|
||||||
import { useVendorsCreditNoteListContext } from './VendorsCreditNoteListProvider';
|
import { useVendorsCreditNoteListContext } from './VendorsCreditNoteListProvider';
|
||||||
|
import { useResourceExportPdf } from '@/hooks/query/FinancialReports/use-export-pdf';
|
||||||
import { VendorCreditAction, AbilitySubject } from '@/constants/abilityOption';
|
import { VendorCreditAction, AbilitySubject } from '@/constants/abilityOption';
|
||||||
|
|
||||||
import withVendorsCreditNotesActions from './withVendorsCreditNotesActions';
|
import withVendorsCreditNotesActions from './withVendorsCreditNotesActions';
|
||||||
@@ -60,35 +61,38 @@ function VendorsCreditNoteActionsBar({
|
|||||||
const { VendorCreditsViews, fields, refresh } =
|
const { VendorCreditsViews, fields, refresh } =
|
||||||
useVendorsCreditNoteListContext();
|
useVendorsCreditNoteListContext();
|
||||||
|
|
||||||
|
// Exports the given resource into pdf.
|
||||||
|
const { mutateAsync: exportPdf, isLoading: isExportPdfLoading } =
|
||||||
|
useResourceExportPdf();
|
||||||
|
|
||||||
// Handle click a new Vendor.
|
// Handle click a new Vendor.
|
||||||
const handleClickNewVendorCredit = () => {
|
const handleClickNewVendorCredit = () => {
|
||||||
history.push('/vendor-credits/new');
|
history.push('/vendor-credits/new');
|
||||||
};
|
};
|
||||||
|
|
||||||
// Handle view tab change.
|
// Handle view tab change.
|
||||||
const handleTabChange = (view) => {
|
const handleTabChange = (view) => {
|
||||||
setVendorCreditsTableState({ viewSlug: view ? view.slug : null });
|
setVendorCreditsTableState({ viewSlug: view ? view.slug : null });
|
||||||
};
|
};
|
||||||
|
|
||||||
// Handle click a refresh credit note.
|
// Handle click a refresh credit note.
|
||||||
const handleRefreshBtnClick = () => {
|
const handleRefreshBtnClick = () => {
|
||||||
refresh();
|
refresh();
|
||||||
};
|
};
|
||||||
|
|
||||||
// Handle table row size change.
|
// Handle table row size change.
|
||||||
const handleTableRowSizeChange = (size) => {
|
const handleTableRowSizeChange = (size) => {
|
||||||
addSetting('vendorCredit', 'tableSize', size);
|
addSetting('vendorCredit', 'tableSize', size);
|
||||||
};
|
};
|
||||||
|
|
||||||
// Handle import button click.
|
// Handle import button click.
|
||||||
const handleImportBtnClick = () => {
|
const handleImportBtnClick = () => {
|
||||||
history.push('/vendor-credits/import');
|
history.push('/vendor-credits/import');
|
||||||
};
|
};
|
||||||
|
|
||||||
// Handle the export button click.
|
// Handle the export button click.
|
||||||
const handleExportBtnClick = () => {
|
const handleExportBtnClick = () => {
|
||||||
openDialog(DialogsName.Export, { resource: 'vendor_credit' });
|
openDialog(DialogsName.Export, { resource: 'vendor_credit' });
|
||||||
};
|
};
|
||||||
|
// Handle the print button click.
|
||||||
|
const handlePrintBtnClick = () => {
|
||||||
|
exportPdf({ resource: 'VendorCredit' });
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<DashboardActionsBar>
|
<DashboardActionsBar>
|
||||||
@@ -127,6 +131,8 @@ function VendorsCreditNoteActionsBar({
|
|||||||
className={Classes.MINIMAL}
|
className={Classes.MINIMAL}
|
||||||
icon={<Icon icon={'print-16'} iconSize={'16'} />}
|
icon={<Icon icon={'print-16'} iconSize={'16'} />}
|
||||||
text={<T id={'print'} />}
|
text={<T id={'print'} />}
|
||||||
|
onClick={handlePrintBtnClick}
|
||||||
|
disabled={isExportPdfLoading}
|
||||||
/>
|
/>
|
||||||
<Button
|
<Button
|
||||||
className={Classes.MINIMAL}
|
className={Classes.MINIMAL}
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
// @ts-nocheck
|
// @ts-nocheck
|
||||||
import React from 'react';
|
|
||||||
import {
|
import {
|
||||||
Button,
|
Button,
|
||||||
Classes,
|
Classes,
|
||||||
@@ -22,19 +21,20 @@ import {
|
|||||||
DashboardRowsHeightButton,
|
DashboardRowsHeightButton,
|
||||||
DashboardActionsBar,
|
DashboardActionsBar,
|
||||||
} from '@/components';
|
} from '@/components';
|
||||||
|
import { PaymentMadeAction, AbilitySubject } from '@/constants/abilityOption';
|
||||||
|
|
||||||
import withPaymentMade from './withPaymentMade';
|
import withPaymentMade from './withPaymentMade';
|
||||||
import withPaymentMadeActions from './withPaymentMadeActions';
|
import withPaymentMadeActions from './withPaymentMadeActions';
|
||||||
import withSettings from '@/containers/Settings/withSettings';
|
import withSettings from '@/containers/Settings/withSettings';
|
||||||
import withSettingsActions from '@/containers/Settings/withSettingsActions';
|
import withSettingsActions from '@/containers/Settings/withSettingsActions';
|
||||||
|
import withDialogActions from '@/containers/Dialog/withDialogActions';
|
||||||
|
|
||||||
import { usePaymentMadesListContext } from './PaymentMadesListProvider';
|
import { usePaymentMadesListContext } from './PaymentMadesListProvider';
|
||||||
import { useRefreshPaymentMades } from '@/hooks/query/paymentMades';
|
import { useRefreshPaymentMades } from '@/hooks/query/paymentMades';
|
||||||
import { PaymentMadeAction, AbilitySubject } from '@/constants/abilityOption';
|
import { useResourceExportPdf } from '@/hooks/query/FinancialReports/use-export-pdf';
|
||||||
|
|
||||||
import { compose } from '@/utils';
|
|
||||||
import withDialogActions from '@/containers/Dialog/withDialogActions';
|
|
||||||
import { DialogsName } from '@/constants/dialogs';
|
import { DialogsName } from '@/constants/dialogs';
|
||||||
|
import { compose } from '@/utils';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Payment made actions bar.
|
* Payment made actions bar.
|
||||||
@@ -57,6 +57,10 @@ function PaymentMadeActionsBar({
|
|||||||
}) {
|
}) {
|
||||||
const history = useHistory();
|
const history = useHistory();
|
||||||
|
|
||||||
|
// Exports the given resource into pdf.
|
||||||
|
const { mutateAsync: exportPdf, isLoading: isExportPdfLoading } =
|
||||||
|
useResourceExportPdf();
|
||||||
|
|
||||||
// Payment receives list context.
|
// Payment receives list context.
|
||||||
const { paymentMadesViews, fields } = usePaymentMadesListContext();
|
const { paymentMadesViews, fields } = usePaymentMadesListContext();
|
||||||
|
|
||||||
@@ -67,31 +71,30 @@ function PaymentMadeActionsBar({
|
|||||||
const handleClickNewPaymentMade = () => {
|
const handleClickNewPaymentMade = () => {
|
||||||
history.push('/payment-mades/new');
|
history.push('/payment-mades/new');
|
||||||
};
|
};
|
||||||
|
|
||||||
// Handle tab changing.
|
// Handle tab changing.
|
||||||
const handleTabChange = (viewSlug) => {
|
const handleTabChange = (viewSlug) => {
|
||||||
setPaymentMadesTableState({ viewSlug });
|
setPaymentMadesTableState({ viewSlug });
|
||||||
};
|
};
|
||||||
|
|
||||||
// Handle click a refresh payment receives.
|
// Handle click a refresh payment receives.
|
||||||
const handleRefreshBtnClick = () => {
|
const handleRefreshBtnClick = () => {
|
||||||
refresh();
|
refresh();
|
||||||
};
|
};
|
||||||
|
|
||||||
// Handle table row size change.
|
// Handle table row size change.
|
||||||
const handleTableRowSizeChange = (size) => {
|
const handleTableRowSizeChange = (size) => {
|
||||||
addSetting('billPayments', 'tableSize', size);
|
addSetting('billPayments', 'tableSize', size);
|
||||||
};
|
};
|
||||||
|
|
||||||
// Handle the import button click.
|
// Handle the import button click.
|
||||||
const handleImportBtnClick = () => {
|
const handleImportBtnClick = () => {
|
||||||
history.push('/payment-mades/import');
|
history.push('/payment-mades/import');
|
||||||
};
|
};
|
||||||
|
|
||||||
// Handle the export button click.
|
// Handle the export button click.
|
||||||
const handleExportBtnClick = () => {
|
const handleExportBtnClick = () => {
|
||||||
openDialog(DialogsName.Export, { resource: 'bill_payment' });
|
openDialog(DialogsName.Export, { resource: 'bill_payment' });
|
||||||
};
|
};
|
||||||
|
// Handle the print button click.
|
||||||
|
const handlePrintBtnClick = () => {
|
||||||
|
exportPdf({ resource: 'PaymentMade' });
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<DashboardActionsBar>
|
<DashboardActionsBar>
|
||||||
@@ -138,6 +141,8 @@ function PaymentMadeActionsBar({
|
|||||||
className={Classes.MINIMAL}
|
className={Classes.MINIMAL}
|
||||||
icon={<Icon icon={'print-16'} iconSize={'16'} />}
|
icon={<Icon icon={'print-16'} iconSize={'16'} />}
|
||||||
text={<T id={'print'} />}
|
text={<T id={'print'} />}
|
||||||
|
onClick={handlePrintBtnClick}
|
||||||
|
disabled={isExportPdfLoading}
|
||||||
/>
|
/>
|
||||||
<Button
|
<Button
|
||||||
className={Classes.MINIMAL}
|
className={Classes.MINIMAL}
|
||||||
|
|||||||
@@ -20,6 +20,8 @@ import {
|
|||||||
} from '@/components';
|
} from '@/components';
|
||||||
|
|
||||||
import { useCreditNoteListContext } from './CreditNotesListProvider';
|
import { useCreditNoteListContext } from './CreditNotesListProvider';
|
||||||
|
import { useResourceExportPdf } from '@/hooks/query/FinancialReports/use-export-pdf';
|
||||||
|
|
||||||
import { CreditNoteAction, AbilitySubject } from '@/constants/abilityOption';
|
import { CreditNoteAction, AbilitySubject } from '@/constants/abilityOption';
|
||||||
import withCreditNotes from './withCreditNotes';
|
import withCreditNotes from './withCreditNotes';
|
||||||
import withCreditNotesActions from './withCreditNotesActions';
|
import withCreditNotesActions from './withCreditNotesActions';
|
||||||
@@ -27,8 +29,8 @@ import withSettings from '@/containers/Settings/withSettings';
|
|||||||
import withSettingsActions from '@/containers/Settings/withSettingsActions';
|
import withSettingsActions from '@/containers/Settings/withSettingsActions';
|
||||||
import withDialogActions from '@/containers/Dialog/withDialogActions';
|
import withDialogActions from '@/containers/Dialog/withDialogActions';
|
||||||
|
|
||||||
import { compose } from '@/utils';
|
|
||||||
import { DialogsName } from '@/constants/dialogs';
|
import { DialogsName } from '@/constants/dialogs';
|
||||||
|
import { compose } from '@/utils';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Credit note table actions bar.
|
* Credit note table actions bar.
|
||||||
@@ -54,6 +56,10 @@ function CreditNotesActionsBar({
|
|||||||
// credit note list context.
|
// credit note list context.
|
||||||
const { CreditNotesView, fields, refresh } = useCreditNoteListContext();
|
const { CreditNotesView, fields, refresh } = useCreditNoteListContext();
|
||||||
|
|
||||||
|
// Exports the given resource into pdf.
|
||||||
|
const { mutateAsync: exportPdf, isLoading: isExportPdfLoading } =
|
||||||
|
useResourceExportPdf();
|
||||||
|
|
||||||
// Handle view tab change.
|
// Handle view tab change.
|
||||||
const handleTabChange = (view) => {
|
const handleTabChange = (view) => {
|
||||||
setCreditNotesTableState({ viewSlug: view ? view.slug : null });
|
setCreditNotesTableState({ viewSlug: view ? view.slug : null });
|
||||||
@@ -68,21 +74,22 @@ function CreditNotesActionsBar({
|
|||||||
const handleRefreshBtnClick = () => {
|
const handleRefreshBtnClick = () => {
|
||||||
refresh();
|
refresh();
|
||||||
};
|
};
|
||||||
|
|
||||||
// Handle table row size change.
|
// Handle table row size change.
|
||||||
const handleTableRowSizeChange = (size) => {
|
const handleTableRowSizeChange = (size) => {
|
||||||
addSetting('creditNote', 'tableSize', size);
|
addSetting('creditNote', 'tableSize', size);
|
||||||
};
|
};
|
||||||
|
|
||||||
// Handle import button click.
|
// Handle import button click.
|
||||||
const handleImportBtnClick = () => {
|
const handleImportBtnClick = () => {
|
||||||
history.push('/credit-notes/import');
|
history.push('/credit-notes/import');
|
||||||
};
|
};
|
||||||
|
|
||||||
// Handle the export button click.
|
// Handle the export button click.
|
||||||
const handleExportBtnClick = () => {
|
const handleExportBtnClick = () => {
|
||||||
openDialog(DialogsName.Export, { resource: 'credit_note' });
|
openDialog(DialogsName.Export, { resource: 'credit_note' });
|
||||||
};
|
};
|
||||||
|
// Handle print button click.
|
||||||
|
const handlePrintBtnClick = () => {
|
||||||
|
exportPdf({ resource: 'CreditNote' });
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<DashboardActionsBar>
|
<DashboardActionsBar>
|
||||||
@@ -121,6 +128,7 @@ function CreditNotesActionsBar({
|
|||||||
className={Classes.MINIMAL}
|
className={Classes.MINIMAL}
|
||||||
icon={<Icon icon={'print-16'} iconSize={'16'} />}
|
icon={<Icon icon={'print-16'} iconSize={'16'} />}
|
||||||
text={<T id={'print'} />}
|
text={<T id={'print'} />}
|
||||||
|
onClick={handlePrintBtnClick}
|
||||||
/>
|
/>
|
||||||
<Button
|
<Button
|
||||||
className={Classes.MINIMAL}
|
className={Classes.MINIMAL}
|
||||||
@@ -133,6 +141,7 @@ function CreditNotesActionsBar({
|
|||||||
icon={<Icon icon={'file-export-16'} iconSize={'16'} />}
|
icon={<Icon icon={'file-export-16'} iconSize={'16'} />}
|
||||||
text={<T id={'export'} />}
|
text={<T id={'export'} />}
|
||||||
onClick={handleExportBtnClick}
|
onClick={handleExportBtnClick}
|
||||||
|
disabled={isExportPdfLoading}
|
||||||
/>
|
/>
|
||||||
<NavbarDivider />
|
<NavbarDivider />
|
||||||
<DashboardRowsHeightButton
|
<DashboardRowsHeightButton
|
||||||
|
|||||||
@@ -26,12 +26,14 @@ import withEstimates from './withEstimates';
|
|||||||
import withEstimatesActions from './withEstimatesActions';
|
import withEstimatesActions from './withEstimatesActions';
|
||||||
import withSettings from '@/containers/Settings/withSettings';
|
import withSettings from '@/containers/Settings/withSettings';
|
||||||
import withSettingsActions from '@/containers/Settings/withSettingsActions';
|
import withSettingsActions from '@/containers/Settings/withSettingsActions';
|
||||||
|
import withDialogActions from '@/containers/Dialog/withDialogActions';
|
||||||
|
|
||||||
import { useEstimatesListContext } from './EstimatesListProvider';
|
import { useEstimatesListContext } from './EstimatesListProvider';
|
||||||
import { useRefreshEstimates } from '@/hooks/query/estimates';
|
import { useRefreshEstimates } from '@/hooks/query/estimates';
|
||||||
|
import { useResourceExportPdf } from '@/hooks/query/FinancialReports/use-export-pdf';
|
||||||
|
|
||||||
import { SaleEstimateAction, AbilitySubject } from '@/constants/abilityOption';
|
import { SaleEstimateAction, AbilitySubject } from '@/constants/abilityOption';
|
||||||
import { compose } from '@/utils';
|
import { compose } from '@/utils';
|
||||||
import withDialogActions from '@/containers/Dialog/withDialogActions';
|
|
||||||
import { DialogsName } from '@/constants/dialogs';
|
import { DialogsName } from '@/constants/dialogs';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -58,6 +60,10 @@ function EstimateActionsBar({
|
|||||||
// Estimates list context.
|
// Estimates list context.
|
||||||
const { estimatesViews, fields } = useEstimatesListContext();
|
const { estimatesViews, fields } = useEstimatesListContext();
|
||||||
|
|
||||||
|
// Exports the given resource into pdf.
|
||||||
|
const { mutateAsync: exportPdf, isLoading: isExportPdfLoading } =
|
||||||
|
useResourceExportPdf();
|
||||||
|
|
||||||
// Handle click a new sale estimate.
|
// Handle click a new sale estimate.
|
||||||
const onClickNewEstimate = () => {
|
const onClickNewEstimate = () => {
|
||||||
history.push('/estimates/new');
|
history.push('/estimates/new');
|
||||||
@@ -71,17 +77,14 @@ function EstimateActionsBar({
|
|||||||
viewSlug: view ? view.slug : null,
|
viewSlug: view ? view.slug : null,
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
// Handle click a refresh sale estimates
|
// Handle click a refresh sale estimates
|
||||||
const handleRefreshBtnClick = () => {
|
const handleRefreshBtnClick = () => {
|
||||||
refresh();
|
refresh();
|
||||||
};
|
};
|
||||||
|
|
||||||
// Handle table row size change.
|
// Handle table row size change.
|
||||||
const handleTableRowSizeChange = (size) => {
|
const handleTableRowSizeChange = (size) => {
|
||||||
addSetting('salesEstimates', 'tableSize', size);
|
addSetting('salesEstimates', 'tableSize', size);
|
||||||
};
|
};
|
||||||
|
|
||||||
// Handle the import button click.
|
// Handle the import button click.
|
||||||
const handleImportBtnClick = () => {
|
const handleImportBtnClick = () => {
|
||||||
history.push('/estimates/import');
|
history.push('/estimates/import');
|
||||||
@@ -90,6 +93,10 @@ function EstimateActionsBar({
|
|||||||
const handleExportBtnClick = () => {
|
const handleExportBtnClick = () => {
|
||||||
openDialog(DialogsName.Export, { resource: 'sale_estimate' });
|
openDialog(DialogsName.Export, { resource: 'sale_estimate' });
|
||||||
};
|
};
|
||||||
|
// Handles the print button click.
|
||||||
|
const handlePrintBtnClick = () => {
|
||||||
|
exportPdf({ resource: 'SaleEstimate' });
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<DashboardActionsBar>
|
<DashboardActionsBar>
|
||||||
@@ -138,8 +145,9 @@ function EstimateActionsBar({
|
|||||||
className={Classes.MINIMAL}
|
className={Classes.MINIMAL}
|
||||||
icon={<Icon icon={'print-16'} iconSize={'16'} />}
|
icon={<Icon icon={'print-16'} iconSize={'16'} />}
|
||||||
text={<T id={'print'} />}
|
text={<T id={'print'} />}
|
||||||
|
onClick={handlePrintBtnClick}
|
||||||
|
disabled={isExportPdfLoading}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
className={Classes.MINIMAL}
|
className={Classes.MINIMAL}
|
||||||
icon={<Icon icon={'file-import-16'} />}
|
icon={<Icon icon={'file-import-16'} />}
|
||||||
@@ -180,5 +188,5 @@ export default compose(
|
|||||||
withSettings(({ estimatesSettings }) => ({
|
withSettings(({ estimatesSettings }) => ({
|
||||||
estimatesTableSize: estimatesSettings?.tableSize,
|
estimatesTableSize: estimatesSettings?.tableSize,
|
||||||
})),
|
})),
|
||||||
withDialogActions
|
withDialogActions,
|
||||||
)(EstimateActionsBar);
|
)(EstimateActionsBar);
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ import { SaleInvoiceAction, AbilitySubject } from '@/constants/abilityOption';
|
|||||||
|
|
||||||
import { useRefreshInvoices } from '@/hooks/query/invoices';
|
import { useRefreshInvoices } from '@/hooks/query/invoices';
|
||||||
import { useInvoicesListContext } from './InvoicesListProvider';
|
import { useInvoicesListContext } from './InvoicesListProvider';
|
||||||
|
import { useResourceExportPdf } from '@/hooks/query/FinancialReports/use-export-pdf';
|
||||||
|
|
||||||
import withInvoices from './withInvoices';
|
import withInvoices from './withInvoices';
|
||||||
import withInvoiceActions from './withInvoiceActions';
|
import withInvoiceActions from './withInvoiceActions';
|
||||||
@@ -49,13 +50,17 @@ function InvoiceActionsBar({
|
|||||||
addSetting,
|
addSetting,
|
||||||
|
|
||||||
// #withDialogsActions
|
// #withDialogsActions
|
||||||
openDialog
|
openDialog,
|
||||||
}) {
|
}) {
|
||||||
const history = useHistory();
|
const history = useHistory();
|
||||||
|
|
||||||
// Sale invoices list context.
|
// Sale invoices list context.
|
||||||
const { invoicesViews, invoicesFields } = useInvoicesListContext();
|
const { invoicesViews, invoicesFields } = useInvoicesListContext();
|
||||||
|
|
||||||
|
// Exports the given resource into pdf.
|
||||||
|
const { mutateAsync: exportPdf, isLoading: isExportPdfLoading } =
|
||||||
|
useResourceExportPdf();
|
||||||
|
|
||||||
// Handle new invoice button click.
|
// Handle new invoice button click.
|
||||||
const handleClickNewInvoice = () => {
|
const handleClickNewInvoice = () => {
|
||||||
history.push('/invoices/new');
|
history.push('/invoices/new');
|
||||||
@@ -88,6 +93,10 @@ function InvoiceActionsBar({
|
|||||||
const handleExportBtnClick = () => {
|
const handleExportBtnClick = () => {
|
||||||
openDialog(DialogsName.Export, { resource: 'sale_invoice' });
|
openDialog(DialogsName.Export, { resource: 'sale_invoice' });
|
||||||
};
|
};
|
||||||
|
// Handles the print button click.
|
||||||
|
const handlePrintBtnClick = () => {
|
||||||
|
exportPdf({ resource: 'SaleInvoice' });
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<DashboardActionsBar>
|
<DashboardActionsBar>
|
||||||
@@ -134,6 +143,8 @@ function InvoiceActionsBar({
|
|||||||
className={Classes.MINIMAL}
|
className={Classes.MINIMAL}
|
||||||
icon={<Icon icon={'print-16'} iconSize={'16'} />}
|
icon={<Icon icon={'print-16'} iconSize={'16'} />}
|
||||||
text={<T id={'print'} />}
|
text={<T id={'print'} />}
|
||||||
|
onClick={handlePrintBtnClick}
|
||||||
|
disabled={isExportPdfLoading}
|
||||||
/>
|
/>
|
||||||
<Button
|
<Button
|
||||||
className={Classes.MINIMAL}
|
className={Classes.MINIMAL}
|
||||||
|
|||||||
@@ -35,6 +35,7 @@ import { usePaymentReceivesListContext } from './PaymentReceiptsListProvider';
|
|||||||
import { useRefreshPaymentReceive } from '@/hooks/query/paymentReceives';
|
import { useRefreshPaymentReceive } from '@/hooks/query/paymentReceives';
|
||||||
import { compose } from '@/utils';
|
import { compose } from '@/utils';
|
||||||
import { DialogsName } from '@/constants/dialogs';
|
import { DialogsName } from '@/constants/dialogs';
|
||||||
|
import { useResourceExportPdf } from '@/hooks/query/FinancialReports/use-export-pdf';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Payment receives actions bar.
|
* Payment receives actions bar.
|
||||||
@@ -61,6 +62,10 @@ function PaymentReceiveActionsBar({
|
|||||||
// Payment receives list context.
|
// Payment receives list context.
|
||||||
const { paymentReceivesViews, fields } = usePaymentReceivesListContext();
|
const { paymentReceivesViews, fields } = usePaymentReceivesListContext();
|
||||||
|
|
||||||
|
// Exports the given resource into pdf.
|
||||||
|
const { mutateAsync: exportPdf, isLoading: isExportPdfLoading } =
|
||||||
|
useResourceExportPdf();
|
||||||
|
|
||||||
// Handle new payment button click.
|
// Handle new payment button click.
|
||||||
const handleClickNewPaymentReceive = () => {
|
const handleClickNewPaymentReceive = () => {
|
||||||
history.push('/payment-receives/new');
|
history.push('/payment-receives/new');
|
||||||
@@ -91,6 +96,10 @@ function PaymentReceiveActionsBar({
|
|||||||
const handleExportBtnClick = () => {
|
const handleExportBtnClick = () => {
|
||||||
openDialog(DialogsName.Export, { resource: 'payment_receive' });
|
openDialog(DialogsName.Export, { resource: 'payment_receive' });
|
||||||
};
|
};
|
||||||
|
// Handles the print button click.
|
||||||
|
const handlePrintBtnClick = () => {
|
||||||
|
exportPdf({ resource: 'PaymentReceive' });
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<DashboardActionsBar>
|
<DashboardActionsBar>
|
||||||
@@ -137,6 +146,8 @@ function PaymentReceiveActionsBar({
|
|||||||
className={Classes.MINIMAL}
|
className={Classes.MINIMAL}
|
||||||
icon={<Icon icon={'print-16'} iconSize={'16'} />}
|
icon={<Icon icon={'print-16'} iconSize={'16'} />}
|
||||||
text={<T id={'print'} />}
|
text={<T id={'print'} />}
|
||||||
|
onClick={handlePrintBtnClick}
|
||||||
|
disabled={isExportPdfLoading}
|
||||||
/>
|
/>
|
||||||
<Button
|
<Button
|
||||||
className={Classes.MINIMAL}
|
className={Classes.MINIMAL}
|
||||||
|
|||||||
@@ -29,14 +29,15 @@ import withReceipts from './withReceipts';
|
|||||||
import withReceiptsActions from './withReceiptsActions';
|
import withReceiptsActions from './withReceiptsActions';
|
||||||
import withSettings from '@/containers/Settings/withSettings';
|
import withSettings from '@/containers/Settings/withSettings';
|
||||||
import withSettingsActions from '@/containers/Settings/withSettingsActions';
|
import withSettingsActions from '@/containers/Settings/withSettingsActions';
|
||||||
|
import withDialogActions from '@/containers/Dialog/withDialogActions';
|
||||||
|
|
||||||
import { useReceiptsListContext } from './ReceiptsListProvider';
|
import { useReceiptsListContext } from './ReceiptsListProvider';
|
||||||
import { useRefreshReceipts } from '@/hooks/query/receipts';
|
import { useRefreshReceipts } from '@/hooks/query/receipts';
|
||||||
|
import { useResourceExportPdf } from '@/hooks/query/FinancialReports/use-export-pdf';
|
||||||
import { SaleReceiptAction, AbilitySubject } from '@/constants/abilityOption';
|
import { SaleReceiptAction, AbilitySubject } from '@/constants/abilityOption';
|
||||||
|
|
||||||
import { compose } from '@/utils';
|
|
||||||
import withDialogActions from '@/containers/Dialog/withDialogActions';
|
|
||||||
import { DialogsName } from '@/constants/dialogs';
|
import { DialogsName } from '@/constants/dialogs';
|
||||||
|
import { compose } from '@/utils';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Receipts actions bar.
|
* Receipts actions bar.
|
||||||
@@ -62,6 +63,9 @@ function ReceiptActionsBar({
|
|||||||
// Sale receipts list context.
|
// Sale receipts list context.
|
||||||
const { receiptsViews, fields } = useReceiptsListContext();
|
const { receiptsViews, fields } = useReceiptsListContext();
|
||||||
|
|
||||||
|
const { mutateAsync: exportPdf, isLoading: isExportPdfLoading } =
|
||||||
|
useResourceExportPdf();
|
||||||
|
|
||||||
// Handle new receipt button click.
|
// Handle new receipt button click.
|
||||||
const onClickNewReceipt = () => {
|
const onClickNewReceipt = () => {
|
||||||
history.push('/receipts/new');
|
history.push('/receipts/new');
|
||||||
@@ -95,6 +99,10 @@ function ReceiptActionsBar({
|
|||||||
const handleExportBtnClick = () => {
|
const handleExportBtnClick = () => {
|
||||||
openDialog(DialogsName.Export, { resource: 'sale_receipt' });
|
openDialog(DialogsName.Export, { resource: 'sale_receipt' });
|
||||||
};
|
};
|
||||||
|
// Handle print button click.
|
||||||
|
const handlePrintButtonClick = () => {
|
||||||
|
exportPdf({ resource: 'SaleReceipt' });
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<DashboardActionsBar>
|
<DashboardActionsBar>
|
||||||
@@ -143,8 +151,9 @@ function ReceiptActionsBar({
|
|||||||
className={Classes.MINIMAL}
|
className={Classes.MINIMAL}
|
||||||
icon={<Icon icon={'print-16'} iconSize={'16'} />}
|
icon={<Icon icon={'print-16'} iconSize={'16'} />}
|
||||||
text={<T id={'print'} />}
|
text={<T id={'print'} />}
|
||||||
|
onClick={handlePrintButtonClick}
|
||||||
|
disabled={isExportPdfLoading}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
className={Classes.MINIMAL}
|
className={Classes.MINIMAL}
|
||||||
icon={<Icon icon={'file-import-16'} />}
|
icon={<Icon icon={'file-import-16'} />}
|
||||||
|
|||||||
@@ -35,6 +35,7 @@ import withDialogActions from '@/containers/Dialog/withDialogActions';
|
|||||||
|
|
||||||
import { compose } from '@/utils';
|
import { compose } from '@/utils';
|
||||||
import { DialogsName } from '@/constants/dialogs';
|
import { DialogsName } from '@/constants/dialogs';
|
||||||
|
import { useResourceExportPdf } from '@/hooks/query/FinancialReports/use-export-pdf';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Vendors actions bar.
|
* Vendors actions bar.
|
||||||
@@ -61,11 +62,14 @@ function VendorActionsBar({
|
|||||||
// Vendors list context.
|
// Vendors list context.
|
||||||
const { vendorsViews, fields } = useVendorsListContext();
|
const { vendorsViews, fields } = useVendorsListContext();
|
||||||
|
|
||||||
|
// Exports the given resource into pdf.
|
||||||
|
const { mutateAsync: exportPdf, isLoading: isExportPdfLoading } =
|
||||||
|
useResourceExportPdf();
|
||||||
|
|
||||||
// Handles new vendor button click.
|
// Handles new vendor button click.
|
||||||
const onClickNewVendor = () => {
|
const onClickNewVendor = () => {
|
||||||
history.push('/vendors/new');
|
history.push('/vendors/new');
|
||||||
};
|
};
|
||||||
|
|
||||||
// Vendors refresh action.
|
// Vendors refresh action.
|
||||||
const { refresh } = useRefreshVendors();
|
const { refresh } = useRefreshVendors();
|
||||||
|
|
||||||
@@ -73,31 +77,30 @@ function VendorActionsBar({
|
|||||||
const handleTabChange = (viewSlug) => {
|
const handleTabChange = (viewSlug) => {
|
||||||
setVendorsTableState({ viewSlug });
|
setVendorsTableState({ viewSlug });
|
||||||
};
|
};
|
||||||
|
|
||||||
// Handle inactive switch changing.
|
// Handle inactive switch changing.
|
||||||
const handleInactiveSwitchChange = (event) => {
|
const handleInactiveSwitchChange = (event) => {
|
||||||
const checked = event.target.checked;
|
const checked = event.target.checked;
|
||||||
setVendorsTableState({ inactiveMode: checked });
|
setVendorsTableState({ inactiveMode: checked });
|
||||||
};
|
};
|
||||||
|
|
||||||
// Handle click a refresh sale estimates
|
// Handle click a refresh sale estimates
|
||||||
const handleRefreshBtnClick = () => {
|
const handleRefreshBtnClick = () => {
|
||||||
refresh();
|
refresh();
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleTableRowSizeChange = (size) => {
|
const handleTableRowSizeChange = (size) => {
|
||||||
addSetting('vendors', 'tableSize', size);
|
addSetting('vendors', 'tableSize', size);
|
||||||
};
|
};
|
||||||
|
|
||||||
// Handle import button success.
|
// Handle import button success.
|
||||||
const handleImportBtnSuccess = () => {
|
const handleImportBtnSuccess = () => {
|
||||||
history.push('/vendors/import');
|
history.push('/vendors/import');
|
||||||
};
|
};
|
||||||
|
|
||||||
// Handle the export button click.
|
// Handle the export button click.
|
||||||
const handleExportBtnClick = () => {
|
const handleExportBtnClick = () => {
|
||||||
openDialog(DialogsName.Export, { resource: 'vendor' });
|
openDialog(DialogsName.Export, { resource: 'vendor' });
|
||||||
};
|
};
|
||||||
|
// Handle the print button click.
|
||||||
|
const handlePrintBtnClick = () => {
|
||||||
|
exportPdf({ resource: 'Vendor' });
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<DashboardActionsBar>
|
<DashboardActionsBar>
|
||||||
@@ -140,6 +143,14 @@ function VendorActionsBar({
|
|||||||
intent={Intent.DANGER}
|
intent={Intent.DANGER}
|
||||||
/>
|
/>
|
||||||
</If>
|
</If>
|
||||||
|
<NavbarDivider />
|
||||||
|
<Button
|
||||||
|
className={Classes.MINIMAL}
|
||||||
|
icon={<Icon icon="print-16" iconSize={16} />}
|
||||||
|
text={<T id={'print'} />}
|
||||||
|
disabled={isExportPdfLoading}
|
||||||
|
onClick={handlePrintBtnClick}
|
||||||
|
/>
|
||||||
<Button
|
<Button
|
||||||
className={Classes.MINIMAL}
|
className={Classes.MINIMAL}
|
||||||
icon={<Icon icon="file-import-16" iconSize={16} />}
|
icon={<Icon icon="file-import-16" iconSize={16} />}
|
||||||
|
|||||||
@@ -0,0 +1,36 @@
|
|||||||
|
// @ts-nocheck
|
||||||
|
import { downloadFile } from '@/hooks/useDownloadFile';
|
||||||
|
import useApiRequest from '@/hooks/useRequest';
|
||||||
|
import { AxiosError } from 'axios';
|
||||||
|
import { useMutation } from 'react-query';
|
||||||
|
|
||||||
|
interface ResourceExportValues {
|
||||||
|
resource: string;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Initiates a download of the balance sheet in XLSX format.
|
||||||
|
* @param {Object} query - The query parameters for the request.
|
||||||
|
* @param {Object} args - Additional configurations for the download.
|
||||||
|
* @returns {Function} A function to trigger the file download.
|
||||||
|
*/
|
||||||
|
export const useResourceExportPdf = () => {
|
||||||
|
const apiRequest = useApiRequest();
|
||||||
|
|
||||||
|
return useMutation<void, AxiosError, any>((data: ResourceExportValues) => {
|
||||||
|
return apiRequest
|
||||||
|
.get('/export', {
|
||||||
|
responseType: 'blob',
|
||||||
|
headers: {
|
||||||
|
accept: 'application/pdf',
|
||||||
|
},
|
||||||
|
params: {
|
||||||
|
resource: data.resource,
|
||||||
|
format: data.format,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
.then((res) => {
|
||||||
|
downloadFile(res.data, `${data.resource}.pdf`);
|
||||||
|
return res;
|
||||||
|
});
|
||||||
|
});
|
||||||
|
};
|
||||||
@@ -190,7 +190,10 @@ $dashboard-views-bar-height: 44px;
|
|||||||
background: #a7b6c21f;
|
background: #a7b6c21f;
|
||||||
color: #32304a;
|
color: #32304a;
|
||||||
}
|
}
|
||||||
|
&.bp4-disabled{
|
||||||
|
background: transparent;
|
||||||
|
color: rgba(50, 48, 74, 0.4);
|
||||||
|
}
|
||||||
&.has-active-filters {
|
&.has-active-filters {
|
||||||
|
|
||||||
&,
|
&,
|
||||||
|
|||||||
Reference in New Issue
Block a user