feat: improve UI experience of resource priting

This commit is contained in:
Ahmed Bouhuolia
2024-05-31 15:30:49 +02:00
parent ba77351e44
commit 958f78e7a4
18 changed files with 184 additions and 101 deletions

View File

@@ -20,7 +20,7 @@ import {
} from '@/components';
import { useCreditNoteListContext } from './CreditNotesListProvider';
import { useResourceExportPdf } from '@/hooks/query/FinancialReports/use-export-pdf';
import { useDownloadExportPdf } from '@/hooks/query/FinancialReports/use-export-pdf';
import { CreditNoteAction, AbilitySubject } from '@/constants/abilityOption';
import withCreditNotes from './withCreditNotes';
@@ -56,9 +56,8 @@ function CreditNotesActionsBar({
// credit note list context.
const { CreditNotesView, fields, refresh } = useCreditNoteListContext();
// Exports the given resource into pdf.
const { mutateAsync: exportPdf, isLoading: isExportPdfLoading } =
useResourceExportPdf();
// Exports pdf document.
const { downloadAsync: downloadExportPdf } = useDownloadExportPdf();
// Handle view tab change.
const handleTabChange = (view) => {
@@ -88,7 +87,7 @@ function CreditNotesActionsBar({
};
// Handle print button click.
const handlePrintBtnClick = () => {
exportPdf({ resource: 'CreditNote' });
downloadExportPdf({ resource: 'CreditNote' });
};
return (
@@ -141,7 +140,6 @@ function CreditNotesActionsBar({
icon={<Icon icon={'file-export-16'} iconSize={'16'} />}
text={<T id={'export'} />}
onClick={handleExportBtnClick}
disabled={isExportPdfLoading}
/>
<NavbarDivider />
<DashboardRowsHeightButton

View File

@@ -30,7 +30,7 @@ import withDialogActions from '@/containers/Dialog/withDialogActions';
import { useEstimatesListContext } from './EstimatesListProvider';
import { useRefreshEstimates } from '@/hooks/query/estimates';
import { useResourceExportPdf } from '@/hooks/query/FinancialReports/use-export-pdf';
import { useDownloadExportPdf } from '@/hooks/query/FinancialReports/use-export-pdf';
import { SaleEstimateAction, AbilitySubject } from '@/constants/abilityOption';
import { compose } from '@/utils';
@@ -60,9 +60,8 @@ function EstimateActionsBar({
// Estimates list context.
const { estimatesViews, fields } = useEstimatesListContext();
// Exports the given resource into pdf.
const { mutateAsync: exportPdf, isLoading: isExportPdfLoading } =
useResourceExportPdf();
// Exports pdf document.
const { downloadAsync: downloadExportPdf } = useDownloadExportPdf();
// Handle click a new sale estimate.
const onClickNewEstimate = () => {
@@ -95,7 +94,7 @@ function EstimateActionsBar({
};
// Handles the print button click.
const handlePrintBtnClick = () => {
exportPdf({ resource: 'SaleEstimate' });
downloadExportPdf({ resource: 'SaleEstimate' });
};
return (
@@ -146,7 +145,6 @@ function EstimateActionsBar({
icon={<Icon icon={'print-16'} iconSize={'16'} />}
text={<T id={'print'} />}
onClick={handlePrintBtnClick}
disabled={isExportPdfLoading}
/>
<Button
className={Classes.MINIMAL}

View File

@@ -23,7 +23,7 @@ import { SaleInvoiceAction, AbilitySubject } from '@/constants/abilityOption';
import { useRefreshInvoices } from '@/hooks/query/invoices';
import { useInvoicesListContext } from './InvoicesListProvider';
import { useResourceExportPdf } from '@/hooks/query/FinancialReports/use-export-pdf';
import { useDownloadExportPdf } from '@/hooks/query/FinancialReports/use-export-pdf';
import withInvoices from './withInvoices';
import withInvoiceActions from './withInvoiceActions';
@@ -57,9 +57,8 @@ function InvoiceActionsBar({
// Sale invoices list context.
const { invoicesViews, invoicesFields } = useInvoicesListContext();
// Exports the given resource into pdf.
const { mutateAsync: exportPdf, isLoading: isExportPdfLoading } =
useResourceExportPdf();
// Exports pdf document.
const { downloadAsync: downloadExportPdf } = useDownloadExportPdf();
// Handle new invoice button click.
const handleClickNewInvoice = () => {
@@ -95,7 +94,7 @@ function InvoiceActionsBar({
};
// Handles the print button click.
const handlePrintBtnClick = () => {
exportPdf({ resource: 'SaleInvoice' });
downloadExportPdf({ resource: 'SaleInvoice' });
};
return (
@@ -144,7 +143,6 @@ function InvoiceActionsBar({
icon={<Icon icon={'print-16'} iconSize={'16'} />}
text={<T id={'print'} />}
onClick={handlePrintBtnClick}
disabled={isExportPdfLoading}
/>
<Button
className={Classes.MINIMAL}

View File

@@ -31,11 +31,13 @@ import {
PaymentReceiveAction,
AbilitySubject,
} from '@/constants/abilityOption';
import { usePaymentReceivesListContext } from './PaymentReceiptsListProvider';
import { useRefreshPaymentReceive } from '@/hooks/query/paymentReceives';
import { useDownloadExportPdf } from '@/hooks/query/FinancialReports/use-export-pdf';
import { compose } from '@/utils';
import { DialogsName } from '@/constants/dialogs';
import { useResourceExportPdf } from '@/hooks/query/FinancialReports/use-export-pdf';
/**
* Payment receives actions bar.
@@ -62,9 +64,8 @@ function PaymentReceiveActionsBar({
// Payment receives list context.
const { paymentReceivesViews, fields } = usePaymentReceivesListContext();
// Exports the given resource into pdf.
const { mutateAsync: exportPdf, isLoading: isExportPdfLoading } =
useResourceExportPdf();
// Exports pdf document.
const { downloadAsync: downloadExportPdf } = useDownloadExportPdf();
// Handle new payment button click.
const handleClickNewPaymentReceive = () => {
@@ -98,7 +99,7 @@ function PaymentReceiveActionsBar({
};
// Handles the print button click.
const handlePrintBtnClick = () => {
exportPdf({ resource: 'PaymentReceive' });
downloadExportPdf({ resource: 'PaymentReceive' });
};
return (
@@ -147,7 +148,6 @@ function PaymentReceiveActionsBar({
icon={<Icon icon={'print-16'} iconSize={'16'} />}
text={<T id={'print'} />}
onClick={handlePrintBtnClick}
disabled={isExportPdfLoading}
/>
<Button
className={Classes.MINIMAL}

View File

@@ -33,7 +33,7 @@ import withDialogActions from '@/containers/Dialog/withDialogActions';
import { useReceiptsListContext } from './ReceiptsListProvider';
import { useRefreshReceipts } from '@/hooks/query/receipts';
import { useResourceExportPdf } from '@/hooks/query/FinancialReports/use-export-pdf';
import { useDownloadExportPdf } from '@/hooks/query/FinancialReports/use-export-pdf';
import { SaleReceiptAction, AbilitySubject } from '@/constants/abilityOption';
import { DialogsName } from '@/constants/dialogs';
@@ -63,8 +63,8 @@ function ReceiptActionsBar({
// Sale receipts list context.
const { receiptsViews, fields } = useReceiptsListContext();
const { mutateAsync: exportPdf, isLoading: isExportPdfLoading } =
useResourceExportPdf();
// Exports pdf document.
const { downloadAsync: downloadExportPdf } = useDownloadExportPdf();
// Handle new receipt button click.
const onClickNewReceipt = () => {
@@ -101,7 +101,7 @@ function ReceiptActionsBar({
};
// Handle print button click.
const handlePrintButtonClick = () => {
exportPdf({ resource: 'SaleReceipt' });
downloadExportPdf({ resource: 'SaleReceipt' });
};
return (
@@ -152,7 +152,6 @@ function ReceiptActionsBar({
icon={<Icon icon={'print-16'} iconSize={'16'} />}
text={<T id={'print'} />}
onClick={handlePrintButtonClick}
disabled={isExportPdfLoading}
/>
<Button
className={Classes.MINIMAL}