mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-17 05:10:31 +00:00
feat: export dialog on resource table
This commit is contained in:
@@ -20,6 +20,8 @@ export class AccountsExportable extends Exportable {
|
|||||||
inactiveMode: false,
|
inactiveMode: false,
|
||||||
...query,
|
...query,
|
||||||
structure: IAccountsStructureType.Flat,
|
structure: IAccountsStructureType.Flat,
|
||||||
|
pageSize: 12000,
|
||||||
|
page: 1,
|
||||||
} as IAccountsFilter;
|
} as IAccountsFilter;
|
||||||
|
|
||||||
return this.accountsApplication
|
return this.accountsApplication
|
||||||
|
|||||||
@@ -51,6 +51,7 @@ import EstimateMailDialog from '@/containers/Sales/Estimates/EstimateMailDialog/
|
|||||||
import ReceiptMailDialog from '@/containers/Sales/Receipts/ReceiptMailDialog/ReceiptMailDialog';
|
import ReceiptMailDialog from '@/containers/Sales/Receipts/ReceiptMailDialog/ReceiptMailDialog';
|
||||||
import PaymentMailDialog from '@/containers/Sales/PaymentReceives/PaymentMailDialog/PaymentMailDialog';
|
import PaymentMailDialog from '@/containers/Sales/PaymentReceives/PaymentMailDialog/PaymentMailDialog';
|
||||||
import { ConnectBankDialog } from '@/containers/CashFlow/ConnectBankDialog';
|
import { ConnectBankDialog } from '@/containers/CashFlow/ConnectBankDialog';
|
||||||
|
import { ExportDialog } from '@/containers/Dialogs/ExportDialog';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Dialogs container.
|
* Dialogs container.
|
||||||
@@ -148,6 +149,8 @@ export default function DialogsContainer() {
|
|||||||
<ReceiptMailDialog dialogName={DialogsName.ReceiptMail} />
|
<ReceiptMailDialog dialogName={DialogsName.ReceiptMail} />
|
||||||
<PaymentMailDialog dialogName={DialogsName.PaymentMail} />
|
<PaymentMailDialog dialogName={DialogsName.PaymentMail} />
|
||||||
<ConnectBankDialog dialogName={DialogsName.ConnectBankCreditCard} />
|
<ConnectBankDialog dialogName={DialogsName.ConnectBankCreditCard} />
|
||||||
|
|
||||||
|
<ExportDialog dialogName={DialogsName.Export} />
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -73,5 +73,6 @@ export enum DialogsName {
|
|||||||
CustomerTransactionsPdfPreview = 'CustomerTransactionsPdfPreview',
|
CustomerTransactionsPdfPreview = 'CustomerTransactionsPdfPreview',
|
||||||
VendorTransactionsPdfPreview = 'VendorTransactionsPdfPreview',
|
VendorTransactionsPdfPreview = 'VendorTransactionsPdfPreview',
|
||||||
GeneralLedgerPdfPreview = 'GeneralLedgerPdfPreview',
|
GeneralLedgerPdfPreview = 'GeneralLedgerPdfPreview',
|
||||||
SalesTaxLiabilitySummaryPdfPreview = 'SalesTaxLiabilitySummaryPdfPreview'
|
SalesTaxLiabilitySummaryPdfPreview = 'SalesTaxLiabilitySummaryPdfPreview',
|
||||||
|
Export = 'Export',
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ import {
|
|||||||
Can,
|
Can,
|
||||||
If,
|
If,
|
||||||
DashboardActionViewsList,
|
DashboardActionViewsList,
|
||||||
DashboardActionsBar
|
DashboardActionsBar,
|
||||||
} from '@/components';
|
} from '@/components';
|
||||||
import { useRefreshJournals } from '@/hooks/query/manualJournals';
|
import { useRefreshJournals } from '@/hooks/query/manualJournals';
|
||||||
import { useManualJournalsContext } from './ManualJournalsListProvider';
|
import { useManualJournalsContext } from './ManualJournalsListProvider';
|
||||||
@@ -31,6 +31,7 @@ import withSettingsActions from '@/containers/Settings/withSettingsActions';
|
|||||||
import withDialogActions from '@/containers/Dialog/withDialogActions';
|
import withDialogActions from '@/containers/Dialog/withDialogActions';
|
||||||
|
|
||||||
import { compose } from '@/utils';
|
import { compose } from '@/utils';
|
||||||
|
import { DialogsName } from '@/constants/dialogs';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Manual journal actions bar.
|
* Manual journal actions bar.
|
||||||
@@ -47,6 +48,9 @@ function ManualJournalActionsBar({
|
|||||||
|
|
||||||
// #withSettingsActions
|
// #withSettingsActions
|
||||||
addSetting,
|
addSetting,
|
||||||
|
|
||||||
|
// #withDialogActions
|
||||||
|
openDialog
|
||||||
}) {
|
}) {
|
||||||
// History context.
|
// History context.
|
||||||
const history = useHistory();
|
const history = useHistory();
|
||||||
@@ -75,13 +79,18 @@ function ManualJournalActionsBar({
|
|||||||
// Handle import button click.
|
// Handle import button click.
|
||||||
const handleImportBtnClick = () => {
|
const handleImportBtnClick = () => {
|
||||||
history.push('/manual-journals/import');
|
history.push('/manual-journals/import');
|
||||||
}
|
};
|
||||||
|
|
||||||
// Handle table row size change.
|
// Handle table row size change.
|
||||||
const handleTableRowSizeChange = (size) => {
|
const handleTableRowSizeChange = (size) => {
|
||||||
addSetting('manualJournals', 'tableSize', size);
|
addSetting('manualJournals', 'tableSize', size);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Handle the export button click.
|
||||||
|
const handleExportBtnClick = () => {
|
||||||
|
openDialog(DialogsName.Export, { resource: 'manual_journal' });
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<DashboardActionsBar>
|
<DashboardActionsBar>
|
||||||
<NavbarGroup>
|
<NavbarGroup>
|
||||||
@@ -140,6 +149,7 @@ function ManualJournalActionsBar({
|
|||||||
className={Classes.MINIMAL}
|
className={Classes.MINIMAL}
|
||||||
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}
|
||||||
/>
|
/>
|
||||||
<NavbarDivider />
|
<NavbarDivider />
|
||||||
<DashboardRowsHeightButton
|
<DashboardRowsHeightButton
|
||||||
|
|||||||
@@ -118,6 +118,10 @@ function AccountsActionsBar({
|
|||||||
const handleImportBtnClick = () => {
|
const handleImportBtnClick = () => {
|
||||||
history.push('/accounts/import');
|
history.push('/accounts/import');
|
||||||
};
|
};
|
||||||
|
// Handle the export button click.
|
||||||
|
const handleExportBtnClick = () => {
|
||||||
|
openDialog(DialogsName.Export, { resource: 'account' });
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<DashboardActionsBar>
|
<DashboardActionsBar>
|
||||||
@@ -186,6 +190,7 @@ function AccountsActionsBar({
|
|||||||
className={Classes.MINIMAL}
|
className={Classes.MINIMAL}
|
||||||
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}
|
||||||
/>
|
/>
|
||||||
<Button
|
<Button
|
||||||
className={Classes.MINIMAL}
|
className={Classes.MINIMAL}
|
||||||
|
|||||||
@@ -31,9 +31,11 @@ import withCustomersActions from './withCustomersActions';
|
|||||||
import withAlertActions from '@/containers/Alert/withAlertActions';
|
import withAlertActions from '@/containers/Alert/withAlertActions';
|
||||||
import withSettingsActions from '@/containers/Settings/withSettingsActions';
|
import withSettingsActions from '@/containers/Settings/withSettingsActions';
|
||||||
import withSettings from '@/containers/Settings/withSettings';
|
import withSettings from '@/containers/Settings/withSettings';
|
||||||
import { CustomerAction, AbilitySubject } from '@/constants/abilityOption';
|
import withDialogActions from '@/containers/Dialog/withDialogActions';
|
||||||
|
|
||||||
|
import { CustomerAction, AbilitySubject } from '@/constants/abilityOption';
|
||||||
import { compose } from '@/utils';
|
import { compose } from '@/utils';
|
||||||
|
import { DialogsName } from '@/constants/dialogs';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Customers actions bar.
|
* Customers actions bar.
|
||||||
@@ -55,6 +57,9 @@ function CustomerActionsBar({
|
|||||||
|
|
||||||
// #withSettingsActions
|
// #withSettingsActions
|
||||||
addSetting,
|
addSetting,
|
||||||
|
|
||||||
|
// #withDialogActions
|
||||||
|
openDialog,
|
||||||
}) {
|
}) {
|
||||||
// History context.
|
// History context.
|
||||||
const history = useHistory();
|
const history = useHistory();
|
||||||
@@ -100,6 +105,11 @@ function CustomerActionsBar({
|
|||||||
history.push('/customers/import');
|
history.push('/customers/import');
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Handle the export button click.
|
||||||
|
const handleExportBtnClick = () => {
|
||||||
|
openDialog(DialogsName.Export, { resource: 'customer' });
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<DashboardActionsBar>
|
<DashboardActionsBar>
|
||||||
<NavbarGroup>
|
<NavbarGroup>
|
||||||
@@ -154,6 +164,7 @@ function CustomerActionsBar({
|
|||||||
className={Classes.MINIMAL}
|
className={Classes.MINIMAL}
|
||||||
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}
|
||||||
/>
|
/>
|
||||||
<NavbarDivider />
|
<NavbarDivider />
|
||||||
<DashboardRowsHeightButton
|
<DashboardRowsHeightButton
|
||||||
@@ -192,4 +203,5 @@ export default compose(
|
|||||||
customersTableSize: customersSettings?.tableSize,
|
customersTableSize: customersSettings?.tableSize,
|
||||||
})),
|
})),
|
||||||
withAlertActions,
|
withAlertActions,
|
||||||
|
withDialogActions,
|
||||||
)(CustomerActionsBar);
|
)(CustomerActionsBar);
|
||||||
|
|||||||
@@ -0,0 +1,17 @@
|
|||||||
|
// @ts-nocheck
|
||||||
|
|
||||||
|
import { ExportDialogForm } from './ExportDialogForm';
|
||||||
|
import { ExportFormInitialValues } from './type';
|
||||||
|
|
||||||
|
interface ExportDialogContentProps {
|
||||||
|
initialValues?: ExportFormInitialValues;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Account dialog content.
|
||||||
|
*/
|
||||||
|
export default function ExportDialogContent({
|
||||||
|
initialValues,
|
||||||
|
}: ExportDialogContentProps) {
|
||||||
|
return <ExportDialogForm initialValues={initialValues} />;
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
// @ts-nocheck
|
||||||
|
import * as Yup from 'yup';
|
||||||
|
|
||||||
|
const Schema = Yup.object().shape({
|
||||||
|
resource: Yup.string().required().label('Resource'),
|
||||||
|
format: Yup.string().required().label('Format'),
|
||||||
|
});
|
||||||
|
|
||||||
|
export const ExportDialogFormSchema = Schema;
|
||||||
@@ -0,0 +1,70 @@
|
|||||||
|
// @ts-nocheck
|
||||||
|
import { Formik } from 'formik';
|
||||||
|
|
||||||
|
import withDialogActions from '@/containers/Dialog/withDialogActions';
|
||||||
|
import { compose, transformToForm } from '@/utils';
|
||||||
|
|
||||||
|
import { ExportDialogFormSchema } from './ExportDialogForm.schema';
|
||||||
|
import { ExportDialogFormContent } from './ExportDialogFormContent';
|
||||||
|
import { useResourceExport } from '@/hooks/query/FinancialReports/use-export';
|
||||||
|
import { ExportFormInitialValues } from './type';
|
||||||
|
|
||||||
|
// Default initial form values.
|
||||||
|
const defaultInitialValues = {
|
||||||
|
resource: '',
|
||||||
|
format: 'csv',
|
||||||
|
};
|
||||||
|
|
||||||
|
interface ExportDialogFormProps {
|
||||||
|
initialValues?: ExportFormInitialValues;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Account form dialog content.
|
||||||
|
*/
|
||||||
|
function ExportDialogFormRoot({
|
||||||
|
// #ownProps
|
||||||
|
initialValues,
|
||||||
|
|
||||||
|
// #withDialogActions
|
||||||
|
closeDialog,
|
||||||
|
}: ExportDialogFormProps) {
|
||||||
|
const { mutateAsync: mutateExport } = useResourceExport();
|
||||||
|
|
||||||
|
// Callbacks handles form submit.
|
||||||
|
const handleFormSubmit = (values, { setSubmitting, setErrors }) => {
|
||||||
|
setSubmitting(true);
|
||||||
|
const { resource, format } = values;
|
||||||
|
|
||||||
|
mutateExport({ resource, format })
|
||||||
|
.then(() => {
|
||||||
|
setSubmitting(false);
|
||||||
|
})
|
||||||
|
.catch(() => {
|
||||||
|
setSubmitting(false);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
// Form initial values in create and edit mode.
|
||||||
|
const initialFormValues = {
|
||||||
|
...defaultInitialValues,
|
||||||
|
/**
|
||||||
|
* We only care about the fields in the form. Previously unfilled optional
|
||||||
|
* values such as `notes` come back from the API as null, so remove those
|
||||||
|
* as well.
|
||||||
|
*/
|
||||||
|
...transformToForm(initialValues, defaultInitialValues),
|
||||||
|
};
|
||||||
|
return (
|
||||||
|
<Formik
|
||||||
|
validationSchema={ExportDialogFormSchema}
|
||||||
|
initialValues={initialFormValues}
|
||||||
|
onSubmit={handleFormSubmit}
|
||||||
|
>
|
||||||
|
<ExportDialogFormContent />
|
||||||
|
</Formik>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export const ExportDialogForm =
|
||||||
|
compose(withDialogActions)(ExportDialogFormRoot);
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
import { FFormGroup, FRadioGroup, FSelect } from '@/components';
|
||||||
|
import { Button, Callout, Intent, Radio } from '@blueprintjs/core';
|
||||||
|
import { Form } from 'formik';
|
||||||
|
import { ExportResources } from './constants';
|
||||||
|
|
||||||
|
export function ExportDialogFormContent() {
|
||||||
|
return (
|
||||||
|
<Form>
|
||||||
|
<Callout>
|
||||||
|
You can export data from Bigcapital in CSV or XLSX format
|
||||||
|
</Callout>
|
||||||
|
|
||||||
|
<FFormGroup name={'resource'} label={'Select Resource'}>
|
||||||
|
<FSelect name={'resource'} items={ExportResources} />
|
||||||
|
</FFormGroup>
|
||||||
|
|
||||||
|
<FRadioGroup label={'Export As'} name={'format'}>
|
||||||
|
<Radio value={'xlsx'}>XLSX (Microsoft Excel)</Radio>
|
||||||
|
<Radio value={'csv'}>CSV (Comma Seperated Value)</Radio>
|
||||||
|
</FRadioGroup>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<Button type={'submit'} intent={Intent.PRIMARY}>
|
||||||
|
Export
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
</Form>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
export const ExportResources = [
|
||||||
|
{ value: 'account', text: 'Accounts' },
|
||||||
|
{ value: 'item', text: 'Items' },
|
||||||
|
{ value: 'item_category', text: 'Item Categories' },
|
||||||
|
{ value: 'customer', text: 'Customers' },
|
||||||
|
{ value: 'vendor', text: 'Vendors' },
|
||||||
|
{ value: 'manual_journal', text: 'Manual Journal' },
|
||||||
|
{ value: 'expense', text: 'Expenses' },
|
||||||
|
{ value: 'sale_invoice', text: 'Invoices' },
|
||||||
|
{ value: 'sale_estimate', text: ' Estimates' },
|
||||||
|
{ value: 'sale_receipt', text: 'Receipts' },
|
||||||
|
{ value: 'payment_receive', text: 'Payments Received' },
|
||||||
|
{ value: 'credit_note', text: 'Credit Notes' },
|
||||||
|
{ value: 'bill', text: 'Bills' },
|
||||||
|
{ value: 'bill_payment', text: 'Bill Payments' },
|
||||||
|
{ value: 'vendor_credit', text: 'Vendor Credits' },
|
||||||
|
];
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
// @ts-nocheck
|
||||||
|
import React, { lazy } from 'react';
|
||||||
|
import { Dialog, DialogSuspense, FormattedMessage as T } from '@/components';
|
||||||
|
import withDialogRedux from '@/components/DialogReduxConnect';
|
||||||
|
import { compose } from '@/utils';
|
||||||
|
|
||||||
|
const ExportDialogContent = lazy(() => import('./ExportDialogContent'));
|
||||||
|
|
||||||
|
// User form dialog.
|
||||||
|
function ExportDialogRoot({ dialogName, payload, isOpen }) {
|
||||||
|
const { resource = null, format = null } = payload;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Dialog
|
||||||
|
name={dialogName}
|
||||||
|
title={'Export Data'}
|
||||||
|
autoFocus={true}
|
||||||
|
canEscapeKeyClose={true}
|
||||||
|
isOpen={isOpen}
|
||||||
|
>
|
||||||
|
<DialogSuspense>
|
||||||
|
<ExportDialogContent
|
||||||
|
dialogName={dialogName}
|
||||||
|
initialValues={{ resource, format }}
|
||||||
|
/>
|
||||||
|
</DialogSuspense>
|
||||||
|
</Dialog>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export const ExportDialog = compose(withDialogRedux())(ExportDialogRoot);
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
|
||||||
|
|
||||||
|
export interface ExportFormInitialValues {
|
||||||
|
resource?: string;
|
||||||
|
format?: string;
|
||||||
|
}
|
||||||
@@ -33,6 +33,7 @@ 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.
|
||||||
@@ -49,6 +50,9 @@ function ExpensesActionsBar({
|
|||||||
|
|
||||||
// #withSettingsActions
|
// #withSettingsActions
|
||||||
addSetting,
|
addSetting,
|
||||||
|
|
||||||
|
// #withDialogActions
|
||||||
|
openDialog,
|
||||||
}) {
|
}) {
|
||||||
// History context.
|
// History context.
|
||||||
const history = useHistory();
|
const history = useHistory();
|
||||||
@@ -63,7 +67,6 @@ function ExpensesActionsBar({
|
|||||||
const onClickNewExpense = () => {
|
const onClickNewExpense = () => {
|
||||||
history.push('/expenses/new');
|
history.push('/expenses/new');
|
||||||
};
|
};
|
||||||
|
|
||||||
// Handle delete button click.
|
// Handle delete button click.
|
||||||
const handleBulkDelete = () => {};
|
const handleBulkDelete = () => {};
|
||||||
|
|
||||||
@@ -73,21 +76,23 @@ function ExpensesActionsBar({
|
|||||||
viewSlug: view ? view.slug : null,
|
viewSlug: view ? view.slug : null,
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
// Handle click a refresh
|
// Handle click a refresh
|
||||||
const handleRefreshBtnClick = () => {
|
const handleRefreshBtnClick = () => {
|
||||||
refresh();
|
refresh();
|
||||||
};
|
};
|
||||||
|
|
||||||
// Handle the import button click.
|
// Handle the import button click.
|
||||||
const handleImportBtnClick = () => {
|
const handleImportBtnClick = () => {
|
||||||
history.push('/expenses/import');
|
history.push('/expenses/import');
|
||||||
}
|
};
|
||||||
|
|
||||||
// Handle table row size change.
|
// Handle table row size change.
|
||||||
const handleTableRowSizeChange = (size) => {
|
const handleTableRowSizeChange = (size) => {
|
||||||
addSetting('expenses', 'tableSize', size);
|
addSetting('expenses', 'tableSize', size);
|
||||||
};
|
};
|
||||||
|
// Handle the export button click.
|
||||||
|
const handleExportBtnClick = () => {
|
||||||
|
openDialog(DialogsName.Export, { resource: 'expense' });
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<DashboardActionsBar>
|
<DashboardActionsBar>
|
||||||
<NavbarGroup>
|
<NavbarGroup>
|
||||||
@@ -146,6 +151,7 @@ function ExpensesActionsBar({
|
|||||||
className={Classes.MINIMAL}
|
className={Classes.MINIMAL}
|
||||||
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}
|
||||||
/>
|
/>
|
||||||
<NavbarDivider />
|
<NavbarDivider />
|
||||||
<DashboardRowsHeightButton
|
<DashboardRowsHeightButton
|
||||||
|
|||||||
@@ -33,7 +33,9 @@ import withItemsActions from './withItemsActions';
|
|||||||
import withAlertActions from '@/containers/Alert/withAlertActions';
|
import withAlertActions from '@/containers/Alert/withAlertActions';
|
||||||
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 '../Dialog/withDialogActions';
|
||||||
|
|
||||||
|
import { DialogsName } from '@/constants/dialogs';
|
||||||
import { compose } from '@/utils';
|
import { compose } from '@/utils';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -56,6 +58,9 @@ function ItemsActionsBar({
|
|||||||
|
|
||||||
// #withSettingsActions
|
// #withSettingsActions
|
||||||
addSetting,
|
addSetting,
|
||||||
|
|
||||||
|
// #withDialogActions
|
||||||
|
openDialog
|
||||||
}) {
|
}) {
|
||||||
// Items list context.
|
// Items list context.
|
||||||
const { itemsViews, fields } = useItemsListContext();
|
const { itemsViews, fields } = useItemsListContext();
|
||||||
@@ -99,6 +104,11 @@ function ItemsActionsBar({
|
|||||||
history.push('/items/import');
|
history.push('/items/import');
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Handle the export button click.
|
||||||
|
const handleExportBtnClick = () => {
|
||||||
|
openDialog(DialogsName.Export, { resource: 'item' });
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<DashboardActionsBar>
|
<DashboardActionsBar>
|
||||||
<NavbarGroup>
|
<NavbarGroup>
|
||||||
@@ -154,6 +164,7 @@ function ItemsActionsBar({
|
|||||||
className={Classes.MINIMAL}
|
className={Classes.MINIMAL}
|
||||||
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}
|
||||||
/>
|
/>
|
||||||
<NavbarDivider />
|
<NavbarDivider />
|
||||||
<DashboardRowsHeightButton
|
<DashboardRowsHeightButton
|
||||||
@@ -193,4 +204,5 @@ export default compose(
|
|||||||
})),
|
})),
|
||||||
withItemsActions,
|
withItemsActions,
|
||||||
withAlertActions,
|
withAlertActions,
|
||||||
|
withDialogActions
|
||||||
)(ItemsActionsBar);
|
)(ItemsActionsBar);
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ import withAlertActions from '@/containers/Alert/withAlertActions';
|
|||||||
import { compose } from '@/utils';
|
import { compose } from '@/utils';
|
||||||
import { useItemsCategoriesContext } from './ItemsCategoriesProvider';
|
import { useItemsCategoriesContext } from './ItemsCategoriesProvider';
|
||||||
import { useHistory } from 'react-router-dom';
|
import { useHistory } from 'react-router-dom';
|
||||||
|
import { DialogsName } from '@/constants/dialogs';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Items categories actions bar.
|
* Items categories actions bar.
|
||||||
@@ -58,6 +59,10 @@ function ItemsCategoryActionsBar({
|
|||||||
itemCategoriesIds: itemCategoriesSelectedRows,
|
itemCategoriesIds: itemCategoriesSelectedRows,
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
// Handle the export button click.
|
||||||
|
const handleExportBtnClick = () => {
|
||||||
|
openDialog(DialogsName.Export, { resource: 'item_category' });
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<DashboardActionsBar>
|
<DashboardActionsBar>
|
||||||
@@ -105,6 +110,7 @@ function ItemsCategoryActionsBar({
|
|||||||
className={Classes.MINIMAL}
|
className={Classes.MINIMAL}
|
||||||
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}
|
||||||
/>
|
/>
|
||||||
</NavbarGroup>
|
</NavbarGroup>
|
||||||
</DashboardActionsBar>
|
</DashboardActionsBar>
|
||||||
|
|||||||
@@ -32,6 +32,8 @@ import withSettingsActions from '@/containers/Settings/withSettingsActions';
|
|||||||
import { useBillsListContext } from './BillsListProvider';
|
import { useBillsListContext } from './BillsListProvider';
|
||||||
import { useRefreshBills } from '@/hooks/query/bills';
|
import { useRefreshBills } from '@/hooks/query/bills';
|
||||||
import { compose } from '@/utils';
|
import { compose } from '@/utils';
|
||||||
|
import withDialogActions from '@/containers/Dialog/withDialogActions';
|
||||||
|
import { DialogsName } from '@/constants/dialogs';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Bills actions bar.
|
* Bills actions bar.
|
||||||
@@ -48,6 +50,9 @@ function BillActionsBar({
|
|||||||
|
|
||||||
// #withSettingsActions
|
// #withSettingsActions
|
||||||
addSetting,
|
addSetting,
|
||||||
|
|
||||||
|
// #withDialogActions
|
||||||
|
openDialog,
|
||||||
}) {
|
}) {
|
||||||
const history = useHistory();
|
const history = useHistory();
|
||||||
|
|
||||||
@@ -81,7 +86,12 @@ function BillActionsBar({
|
|||||||
// 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.
|
||||||
|
const handleExportBtnClick = () => {
|
||||||
|
openDialog(DialogsName.Export, { resource: 'bill' });
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<DashboardActionsBar>
|
<DashboardActionsBar>
|
||||||
@@ -141,6 +151,7 @@ function BillActionsBar({
|
|||||||
className={Classes.MINIMAL}
|
className={Classes.MINIMAL}
|
||||||
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}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<NavbarDivider />
|
<NavbarDivider />
|
||||||
@@ -170,4 +181,5 @@ export default compose(
|
|||||||
withSettings(({ billsettings }) => ({
|
withSettings(({ billsettings }) => ({
|
||||||
billsTableSize: billsettings?.tableSize,
|
billsTableSize: billsettings?.tableSize,
|
||||||
})),
|
})),
|
||||||
|
withDialogActions,
|
||||||
)(BillActionsBar);
|
)(BillActionsBar);
|
||||||
|
|||||||
@@ -22,14 +22,16 @@ import {
|
|||||||
|
|
||||||
import { useVendorsCreditNoteListContext } from './VendorsCreditNoteListProvider';
|
import { useVendorsCreditNoteListContext } from './VendorsCreditNoteListProvider';
|
||||||
import { VendorCreditAction, AbilitySubject } from '@/constants/abilityOption';
|
import { VendorCreditAction, AbilitySubject } from '@/constants/abilityOption';
|
||||||
|
|
||||||
|
import withVendorsCreditNotesActions from './withVendorsCreditNotesActions';
|
||||||
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 withVendorsCreditNotes from './withVendorsCreditNotes';
|
import withVendorsCreditNotes from './withVendorsCreditNotes';
|
||||||
import withVendorsCreditNotesActions from './withVendorsCreditNotesActions';
|
import withDialogActions from '@/containers/Dialog/withDialogActions';
|
||||||
|
|
||||||
import withVendorActions from './withVendorActions';
|
import withVendorActions from './withVendorActions';
|
||||||
|
|
||||||
import { compose } from '@/utils';
|
import { compose } from '@/utils';
|
||||||
|
import { DialogsName } from '@/constants/dialogs';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Vendors Credit note table actions bar.
|
* Vendors Credit note table actions bar.
|
||||||
@@ -48,6 +50,9 @@ function VendorsCreditNoteActionsBar({
|
|||||||
|
|
||||||
// #withSettingsActions
|
// #withSettingsActions
|
||||||
addSetting,
|
addSetting,
|
||||||
|
|
||||||
|
// #withDialogActions
|
||||||
|
openDialog,
|
||||||
}) {
|
}) {
|
||||||
const history = useHistory();
|
const history = useHistory();
|
||||||
|
|
||||||
@@ -77,8 +82,13 @@ function VendorsCreditNoteActionsBar({
|
|||||||
|
|
||||||
// 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.
|
||||||
|
const handleExportBtnClick = () => {
|
||||||
|
openDialog(DialogsName.Export, { resource: 'vendor_credit' });
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<DashboardActionsBar>
|
<DashboardActionsBar>
|
||||||
@@ -128,6 +138,7 @@ function VendorsCreditNoteActionsBar({
|
|||||||
className={Classes.MINIMAL}
|
className={Classes.MINIMAL}
|
||||||
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}
|
||||||
/>
|
/>
|
||||||
<NavbarDivider />
|
<NavbarDivider />
|
||||||
<DashboardRowsHeightButton
|
<DashboardRowsHeightButton
|
||||||
@@ -157,4 +168,5 @@ export default compose(
|
|||||||
withSettings(({ vendorsCreditNoteSetting }) => ({
|
withSettings(({ vendorsCreditNoteSetting }) => ({
|
||||||
creditNoteTableSize: vendorsCreditNoteSetting?.tableSize,
|
creditNoteTableSize: vendorsCreditNoteSetting?.tableSize,
|
||||||
})),
|
})),
|
||||||
|
withDialogActions,
|
||||||
)(VendorsCreditNoteActionsBar);
|
)(VendorsCreditNoteActionsBar);
|
||||||
|
|||||||
@@ -33,6 +33,8 @@ import { useRefreshPaymentMades } from '@/hooks/query/paymentMades';
|
|||||||
import { PaymentMadeAction, AbilitySubject } from '@/constants/abilityOption';
|
import { PaymentMadeAction, AbilitySubject } from '@/constants/abilityOption';
|
||||||
|
|
||||||
import { compose } from '@/utils';
|
import { compose } from '@/utils';
|
||||||
|
import withDialogActions from '@/containers/Dialog/withDialogActions';
|
||||||
|
import { DialogsName } from '@/constants/dialogs';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Payment made actions bar.
|
* Payment made actions bar.
|
||||||
@@ -47,6 +49,9 @@ function PaymentMadeActionsBar({
|
|||||||
// #withSettings
|
// #withSettings
|
||||||
paymentMadesTableSize,
|
paymentMadesTableSize,
|
||||||
|
|
||||||
|
// #withDialogActions
|
||||||
|
openDialog,
|
||||||
|
|
||||||
// #withSettingsActions
|
// #withSettingsActions
|
||||||
addSetting,
|
addSetting,
|
||||||
}) {
|
}) {
|
||||||
@@ -81,7 +86,12 @@ function PaymentMadeActionsBar({
|
|||||||
// 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.
|
||||||
|
const handleExportBtnClick = () => {
|
||||||
|
openDialog(DialogsName.Export, { resource: 'bill_payment' });
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<DashboardActionsBar>
|
<DashboardActionsBar>
|
||||||
@@ -139,6 +149,7 @@ function PaymentMadeActionsBar({
|
|||||||
className={Classes.MINIMAL}
|
className={Classes.MINIMAL}
|
||||||
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}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<NavbarDivider />
|
<NavbarDivider />
|
||||||
@@ -168,4 +179,5 @@ export default compose(
|
|||||||
withSettings(({ billPaymentSettings }) => ({
|
withSettings(({ billPaymentSettings }) => ({
|
||||||
paymentMadesTableSize: billPaymentSettings?.tableSize,
|
paymentMadesTableSize: billPaymentSettings?.tableSize,
|
||||||
})),
|
})),
|
||||||
|
withDialogActions,
|
||||||
)(PaymentMadeActionsBar);
|
)(PaymentMadeActionsBar);
|
||||||
|
|||||||
@@ -25,8 +25,10 @@ import withCreditNotes from './withCreditNotes';
|
|||||||
import withCreditNotesActions from './withCreditNotesActions';
|
import withCreditNotesActions from './withCreditNotesActions';
|
||||||
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 { compose } from '@/utils';
|
import { compose } from '@/utils';
|
||||||
|
import { DialogsName } from '@/constants/dialogs';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Credit note table actions bar.
|
* Credit note table actions bar.
|
||||||
@@ -43,6 +45,9 @@ function CreditNotesActionsBar({
|
|||||||
|
|
||||||
// #withSettingsActions
|
// #withSettingsActions
|
||||||
addSetting,
|
addSetting,
|
||||||
|
|
||||||
|
// #withDialogActions
|
||||||
|
openDialog,
|
||||||
}) {
|
}) {
|
||||||
const history = useHistory();
|
const history = useHistory();
|
||||||
|
|
||||||
@@ -74,6 +79,11 @@ function CreditNotesActionsBar({
|
|||||||
history.push('/credit-notes/import');
|
history.push('/credit-notes/import');
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Handle the export button click.
|
||||||
|
const handleExportBtnClick = () => {
|
||||||
|
openDialog(DialogsName.Export, { resource: 'credit_note' });
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<DashboardActionsBar>
|
<DashboardActionsBar>
|
||||||
<NavbarGroup>
|
<NavbarGroup>
|
||||||
@@ -122,6 +132,7 @@ function CreditNotesActionsBar({
|
|||||||
className={Classes.MINIMAL}
|
className={Classes.MINIMAL}
|
||||||
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}
|
||||||
/>
|
/>
|
||||||
<NavbarDivider />
|
<NavbarDivider />
|
||||||
<DashboardRowsHeightButton
|
<DashboardRowsHeightButton
|
||||||
@@ -150,4 +161,5 @@ export default compose(
|
|||||||
withSettings(({ creditNoteSettings }) => ({
|
withSettings(({ creditNoteSettings }) => ({
|
||||||
creditNoteTableSize: creditNoteSettings?.tableSize,
|
creditNoteTableSize: creditNoteSettings?.tableSize,
|
||||||
})),
|
})),
|
||||||
|
withDialogActions,
|
||||||
)(CreditNotesActionsBar);
|
)(CreditNotesActionsBar);
|
||||||
|
|||||||
@@ -31,6 +31,8 @@ import { useEstimatesListContext } from './EstimatesListProvider';
|
|||||||
import { useRefreshEstimates } from '@/hooks/query/estimates';
|
import { useRefreshEstimates } from '@/hooks/query/estimates';
|
||||||
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';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Estimates list actions bar.
|
* Estimates list actions bar.
|
||||||
@@ -45,6 +47,9 @@ function EstimateActionsBar({
|
|||||||
// #withSettings
|
// #withSettings
|
||||||
estimatesTableSize,
|
estimatesTableSize,
|
||||||
|
|
||||||
|
// #withDialogActions
|
||||||
|
openDialog,
|
||||||
|
|
||||||
// #withSettingsActions
|
// #withSettingsActions
|
||||||
addSetting,
|
addSetting,
|
||||||
}) {
|
}) {
|
||||||
@@ -80,7 +85,11 @@ function EstimateActionsBar({
|
|||||||
// Handle the import button click.
|
// Handle the import button click.
|
||||||
const handleImportBtnClick = () => {
|
const handleImportBtnClick = () => {
|
||||||
history.push('/estimates/import');
|
history.push('/estimates/import');
|
||||||
}
|
};
|
||||||
|
// Handle the export button click.
|
||||||
|
const handleExportBtnClick = () => {
|
||||||
|
openDialog(DialogsName.Export, { resource: 'sale_estimate' });
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<DashboardActionsBar>
|
<DashboardActionsBar>
|
||||||
@@ -141,6 +150,7 @@ function EstimateActionsBar({
|
|||||||
className={Classes.MINIMAL}
|
className={Classes.MINIMAL}
|
||||||
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}
|
||||||
/>
|
/>
|
||||||
<NavbarDivider />
|
<NavbarDivider />
|
||||||
<DashboardRowsHeightButton
|
<DashboardRowsHeightButton
|
||||||
@@ -170,4 +180,5 @@ export default compose(
|
|||||||
withSettings(({ estimatesSettings }) => ({
|
withSettings(({ estimatesSettings }) => ({
|
||||||
estimatesTableSize: estimatesSettings?.tableSize,
|
estimatesTableSize: estimatesSettings?.tableSize,
|
||||||
})),
|
})),
|
||||||
|
withDialogActions
|
||||||
)(EstimateActionsBar);
|
)(EstimateActionsBar);
|
||||||
|
|||||||
@@ -29,6 +29,8 @@ import withInvoiceActions from './withInvoiceActions';
|
|||||||
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 { compose } from '@/utils';
|
import { compose } from '@/utils';
|
||||||
|
import withDialogActions from '@/containers/Dialog/withDialogActions';
|
||||||
|
import { DialogsName } from '@/constants/dialogs';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Invoices table actions bar.
|
* Invoices table actions bar.
|
||||||
@@ -45,6 +47,9 @@ function InvoiceActionsBar({
|
|||||||
|
|
||||||
// #withSettingsActions
|
// #withSettingsActions
|
||||||
addSetting,
|
addSetting,
|
||||||
|
|
||||||
|
// #withDialogsActions
|
||||||
|
openDialog
|
||||||
}) {
|
}) {
|
||||||
const history = useHistory();
|
const history = useHistory();
|
||||||
|
|
||||||
@@ -79,6 +84,11 @@ function InvoiceActionsBar({
|
|||||||
history.push('/invoices/import');
|
history.push('/invoices/import');
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Handle the export button click.
|
||||||
|
const handleExportBtnClick = () => {
|
||||||
|
openDialog(DialogsName.Export, { resource: 'sale_invoice' });
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<DashboardActionsBar>
|
<DashboardActionsBar>
|
||||||
<NavbarGroup>
|
<NavbarGroup>
|
||||||
@@ -135,6 +145,7 @@ function InvoiceActionsBar({
|
|||||||
className={Classes.MINIMAL}
|
className={Classes.MINIMAL}
|
||||||
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}
|
||||||
/>
|
/>
|
||||||
<NavbarDivider />
|
<NavbarDivider />
|
||||||
<DashboardRowsHeightButton
|
<DashboardRowsHeightButton
|
||||||
@@ -163,4 +174,5 @@ export default compose(
|
|||||||
withSettings(({ invoiceSettings }) => ({
|
withSettings(({ invoiceSettings }) => ({
|
||||||
invoicesTableSize: invoiceSettings?.tableSize,
|
invoicesTableSize: invoiceSettings?.tableSize,
|
||||||
})),
|
})),
|
||||||
|
withDialogActions,
|
||||||
)(InvoiceActionsBar);
|
)(InvoiceActionsBar);
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ import withPaymentReceives from './withPaymentReceives';
|
|||||||
import withPaymentReceivesActions from './withPaymentReceivesActions';
|
import withPaymentReceivesActions from './withPaymentReceivesActions';
|
||||||
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 {
|
import {
|
||||||
PaymentReceiveAction,
|
PaymentReceiveAction,
|
||||||
AbilitySubject,
|
AbilitySubject,
|
||||||
@@ -33,6 +34,7 @@ import {
|
|||||||
import { usePaymentReceivesListContext } from './PaymentReceiptsListProvider';
|
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';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Payment receives actions bar.
|
* Payment receives actions bar.
|
||||||
@@ -49,6 +51,9 @@ function PaymentReceiveActionsBar({
|
|||||||
|
|
||||||
// #withSettingsActions
|
// #withSettingsActions
|
||||||
addSetting,
|
addSetting,
|
||||||
|
|
||||||
|
// #withDialogActions
|
||||||
|
openDialog,
|
||||||
}) {
|
}) {
|
||||||
// History context.
|
// History context.
|
||||||
const history = useHistory();
|
const history = useHistory();
|
||||||
@@ -82,6 +87,10 @@ function PaymentReceiveActionsBar({
|
|||||||
const handleImportBtnClick = () => {
|
const handleImportBtnClick = () => {
|
||||||
history.push('/payment-receives/import');
|
history.push('/payment-receives/import');
|
||||||
};
|
};
|
||||||
|
// Handle the export button click.
|
||||||
|
const handleExportBtnClick = () => {
|
||||||
|
openDialog(DialogsName.Export, { resource: 'payment_receive' });
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<DashboardActionsBar>
|
<DashboardActionsBar>
|
||||||
@@ -139,6 +148,7 @@ function PaymentReceiveActionsBar({
|
|||||||
className={Classes.MINIMAL}
|
className={Classes.MINIMAL}
|
||||||
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}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<NavbarDivider />
|
<NavbarDivider />
|
||||||
@@ -169,4 +179,5 @@ export default compose(
|
|||||||
withSettings(({ paymentReceiveSettings }) => ({
|
withSettings(({ paymentReceiveSettings }) => ({
|
||||||
paymentReceivesTableSize: paymentReceiveSettings?.tableSize,
|
paymentReceivesTableSize: paymentReceiveSettings?.tableSize,
|
||||||
})),
|
})),
|
||||||
|
withDialogActions,
|
||||||
)(PaymentReceiveActionsBar);
|
)(PaymentReceiveActionsBar);
|
||||||
|
|||||||
@@ -35,6 +35,8 @@ import { useRefreshReceipts } from '@/hooks/query/receipts';
|
|||||||
import { SaleReceiptAction, AbilitySubject } from '@/constants/abilityOption';
|
import { SaleReceiptAction, AbilitySubject } from '@/constants/abilityOption';
|
||||||
|
|
||||||
import { compose } from '@/utils';
|
import { compose } from '@/utils';
|
||||||
|
import withDialogActions from '@/containers/Dialog/withDialogActions';
|
||||||
|
import { DialogsName } from '@/constants/dialogs';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Receipts actions bar.
|
* Receipts actions bar.
|
||||||
@@ -49,6 +51,9 @@ function ReceiptActionsBar({
|
|||||||
// #withSettings
|
// #withSettings
|
||||||
receiptsTableSize,
|
receiptsTableSize,
|
||||||
|
|
||||||
|
// #withDialogActions
|
||||||
|
openDialog,
|
||||||
|
|
||||||
// #withSettingsActions
|
// #withSettingsActions
|
||||||
addSetting,
|
addSetting,
|
||||||
}) {
|
}) {
|
||||||
@@ -86,6 +91,11 @@ function ReceiptActionsBar({
|
|||||||
history.push('/receipts/import');
|
history.push('/receipts/import');
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Handle the export button click.
|
||||||
|
const handleExportBtnClick = () => {
|
||||||
|
openDialog(DialogsName.Export, { resource: 'sale_receipt' });
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<DashboardActionsBar>
|
<DashboardActionsBar>
|
||||||
<NavbarGroup>
|
<NavbarGroup>
|
||||||
@@ -145,6 +155,7 @@ function ReceiptActionsBar({
|
|||||||
className={Classes.MINIMAL}
|
className={Classes.MINIMAL}
|
||||||
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}
|
||||||
/>
|
/>
|
||||||
<NavbarDivider />
|
<NavbarDivider />
|
||||||
<DashboardRowsHeightButton
|
<DashboardRowsHeightButton
|
||||||
@@ -173,4 +184,5 @@ export default compose(
|
|||||||
withSettings(({ receiptSettings }) => ({
|
withSettings(({ receiptSettings }) => ({
|
||||||
receiptsTableSize: receiptSettings?.tableSize,
|
receiptsTableSize: receiptSettings?.tableSize,
|
||||||
})),
|
})),
|
||||||
|
withDialogActions,
|
||||||
)(ReceiptActionsBar);
|
)(ReceiptActionsBar);
|
||||||
|
|||||||
@@ -31,8 +31,10 @@ import withVendors from './withVendors';
|
|||||||
import withVendorsActions from './withVendorsActions';
|
import withVendorsActions from './withVendorsActions';
|
||||||
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 { compose } from '@/utils';
|
import { compose } from '@/utils';
|
||||||
|
import { DialogsName } from '@/constants/dialogs';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Vendors actions bar.
|
* Vendors actions bar.
|
||||||
@@ -50,6 +52,9 @@ function VendorActionsBar({
|
|||||||
|
|
||||||
// #withSettingsActions
|
// #withSettingsActions
|
||||||
addSetting,
|
addSetting,
|
||||||
|
|
||||||
|
// #withDialogActions
|
||||||
|
openDialog,
|
||||||
}) {
|
}) {
|
||||||
const history = useHistory();
|
const history = useHistory();
|
||||||
|
|
||||||
@@ -83,10 +88,17 @@ function VendorActionsBar({
|
|||||||
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.
|
||||||
|
const handleExportBtnClick = () => {
|
||||||
|
openDialog(DialogsName.Export, { resource: 'vendor' });
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<DashboardActionsBar>
|
<DashboardActionsBar>
|
||||||
<NavbarGroup>
|
<NavbarGroup>
|
||||||
@@ -138,6 +150,7 @@ function VendorActionsBar({
|
|||||||
className={Classes.MINIMAL}
|
className={Classes.MINIMAL}
|
||||||
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}
|
||||||
/>
|
/>
|
||||||
<NavbarDivider />
|
<NavbarDivider />
|
||||||
<DashboardRowsHeightButton
|
<DashboardRowsHeightButton
|
||||||
@@ -175,4 +188,5 @@ export default compose(
|
|||||||
withSettings(({ vendorsSettings }) => ({
|
withSettings(({ vendorsSettings }) => ({
|
||||||
vendorsTableSize: vendorsSettings?.tableSize,
|
vendorsTableSize: vendorsSettings?.tableSize,
|
||||||
})),
|
})),
|
||||||
|
withDialogActions,
|
||||||
)(VendorActionsBar);
|
)(VendorActionsBar);
|
||||||
|
|||||||
@@ -0,0 +1,38 @@
|
|||||||
|
// @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;
|
||||||
|
format: 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 useResourceExport = () => {
|
||||||
|
const apiRequest = useApiRequest();
|
||||||
|
|
||||||
|
return useMutation<void, AxiosError, any>((data: ResourceExportValues) => {
|
||||||
|
return apiRequest
|
||||||
|
.get('/export', {
|
||||||
|
responseType: 'blob',
|
||||||
|
headers: {
|
||||||
|
accept:
|
||||||
|
data.format === 'xlsx' ? 'application/xlsx' : 'application/csv',
|
||||||
|
},
|
||||||
|
params: {
|
||||||
|
resource: data.resource,
|
||||||
|
format: data.format,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
.then((res) => {
|
||||||
|
downloadFile(res.data, `${data.resource}.${data.format}`);
|
||||||
|
return res;
|
||||||
|
});
|
||||||
|
});
|
||||||
|
};
|
||||||
Reference in New Issue
Block a user