From dc18bde6be4812526adf27d0aeadaf6e888306f3 Mon Sep 17 00:00:00 2001 From: Ahmed Bouhuolia Date: Mon, 9 Sep 2024 19:40:23 +0200 Subject: [PATCH] feat: wip invoice customizer --- .../src/components/DrawersContainer.tsx | 7 +- .../EstimateCustomizeContent.tsx | 3 + .../EstimateCustomizeDrawer.tsx | 33 +++ .../EstimatesLanding/EstimatesActionsBar.tsx | 34 +++ .../InvoiceCustomize/InvoiceCustomize.tsx | 74 ++++++ .../InvoiceCustomizeContent.tsx | 70 +++++- .../InvoiceCustomizeDrawer.tsx | 11 +- .../InvoiceCustomizeFields.tsx | 24 +- .../InvoiceCustomizePreviewContent.tsx | 8 +- .../InvoiceCustomizeProvider.tsx | 32 +++ .../InvoiceCustomize/InvoiceCustomizeTabs.tsx | 13 +- .../InvoiceCustomizerForm.tsx | 32 +-- .../InvoiceCustomize/InvoicePaperTemplate.tsx | 235 ++++++++++++++++++ .../InvoiceCustomize/PaperTemplate.tsx | 141 ----------- .../ReceiptCustomizeContent.tsx | 3 + .../ReceiptCustomizeDrawer.tsx | 32 +++ .../ReceiptsLanding/ReceiptActionsBar.tsx | 34 +++ packages/webapp/src/utils/extract-children.ts | 10 + 18 files changed, 602 insertions(+), 194 deletions(-) create mode 100644 packages/webapp/src/containers/Sales/Estimates/EstimateCustomize/EstimateCustomizeContent.tsx create mode 100644 packages/webapp/src/containers/Sales/Estimates/EstimateCustomize/EstimateCustomizeDrawer.tsx create mode 100644 packages/webapp/src/containers/Sales/Invoices/InvoiceCustomize/InvoiceCustomize.tsx create mode 100644 packages/webapp/src/containers/Sales/Invoices/InvoiceCustomize/InvoiceCustomizeProvider.tsx create mode 100644 packages/webapp/src/containers/Sales/Invoices/InvoiceCustomize/InvoicePaperTemplate.tsx delete mode 100644 packages/webapp/src/containers/Sales/Invoices/InvoiceCustomize/PaperTemplate.tsx create mode 100644 packages/webapp/src/containers/Sales/Receipts/ReceiptCustomize/ReceiptCustomizeContent.tsx create mode 100644 packages/webapp/src/containers/Sales/Receipts/ReceiptCustomize/ReceiptCustomizeDrawer.tsx create mode 100644 packages/webapp/src/utils/extract-children.ts diff --git a/packages/webapp/src/components/DrawersContainer.tsx b/packages/webapp/src/components/DrawersContainer.tsx index 43b594ff3..88fc83397 100644 --- a/packages/webapp/src/components/DrawersContainer.tsx +++ b/packages/webapp/src/components/DrawersContainer.tsx @@ -23,10 +23,11 @@ import WarehouseTransferDetailDrawer from '@/containers/Drawers/WarehouseTransfe import TaxRateDetailsDrawer from '@/containers/TaxRates/drawers/TaxRateDetailsDrawer/TaxRateDetailsDrawer'; import CategorizeTransactionDrawer from '@/containers/CashFlow/CategorizeTransaction/drawers/CategorizeTransactionDrawer/CategorizeTransactionDrawer'; import ChangeSubscriptionPlanDrawer from '@/containers/Subscriptions/drawers/ChangeSubscriptionPlanDrawer/ChangeSubscriptionPlanDrawer'; +import { InvoiceCustomizeDrawer } from '@/containers/Sales/Invoices/InvoiceCustomize/InvoiceCustomizeDrawer'; +import { EstimateCustomizeDrawer } from '@/containers/Sales/Estimates/EstimateCustomize/EstimateCustomizeDrawer'; +import { ReceiptCustomizeDrawer } from '@/containers/Sales/Receipts/ReceiptCustomize/ReceiptCustomizeDrawer'; import { DRAWERS } from '@/constants/drawers'; -import { InvoiceCustomizeDrawer } from '@/containers/Sales/Invoices/InvoiceCustomize/InvoiceCustomizeDrawer'; - /** * Drawers container of the dashboard. */ @@ -67,6 +68,8 @@ export default function DrawersContainer() { + + ); } diff --git a/packages/webapp/src/containers/Sales/Estimates/EstimateCustomize/EstimateCustomizeContent.tsx b/packages/webapp/src/containers/Sales/Estimates/EstimateCustomize/EstimateCustomizeContent.tsx new file mode 100644 index 000000000..e208e0b2e --- /dev/null +++ b/packages/webapp/src/containers/Sales/Estimates/EstimateCustomize/EstimateCustomizeContent.tsx @@ -0,0 +1,3 @@ +export default function EstimateCustomizeContent() { + return

Hello World

; +} diff --git a/packages/webapp/src/containers/Sales/Estimates/EstimateCustomize/EstimateCustomizeDrawer.tsx b/packages/webapp/src/containers/Sales/Estimates/EstimateCustomize/EstimateCustomizeDrawer.tsx new file mode 100644 index 000000000..6a6042ba8 --- /dev/null +++ b/packages/webapp/src/containers/Sales/Estimates/EstimateCustomize/EstimateCustomizeDrawer.tsx @@ -0,0 +1,33 @@ +// @ts-nocheck +import React from 'react'; +import * as R from 'ramda'; +import { Drawer, DrawerSuspense } from '@/components'; +import withDrawers from '@/containers/Drawer/withDrawers'; + +const EstimateCustomizeContent = React.lazy( + () => import('./EstimateCustomizeContent'), +); + +/** + * Estimate customize drawer. + * @returns {React.ReactNode} + */ +function EstimateCustomizeDrawerRoot({ + name, + + // #withDrawer + isOpen, + payload: {}, +}) { + return ( + + + + + + ); +} + +export const EstimateCustomizeDrawer = R.compose(withDrawers())( + EstimateCustomizeDrawerRoot, +); diff --git a/packages/webapp/src/containers/Sales/Estimates/EstimatesLanding/EstimatesActionsBar.tsx b/packages/webapp/src/containers/Sales/Estimates/EstimatesLanding/EstimatesActionsBar.tsx index e035bbcf3..0bc42c5d4 100644 --- a/packages/webapp/src/containers/Sales/Estimates/EstimatesLanding/EstimatesActionsBar.tsx +++ b/packages/webapp/src/containers/Sales/Estimates/EstimatesLanding/EstimatesActionsBar.tsx @@ -7,6 +7,11 @@ import { NavbarGroup, Intent, Alignment, + Menu, + MenuItem, + Popover, + PopoverInteractionKind, + Position, } from '@blueprintjs/core'; import { useHistory } from 'react-router-dom'; @@ -35,6 +40,8 @@ import { useDownloadExportPdf } from '@/hooks/query/FinancialReports/use-export- import { SaleEstimateAction, AbilitySubject } from '@/constants/abilityOption'; import { compose } from '@/utils'; import { DialogsName } from '@/constants/dialogs'; +import withDrawerActions from '@/containers/Drawer/withDrawerActions'; +import { DRAWERS } from '@/constants/drawers'; /** * Estimates list actions bar. @@ -52,6 +59,9 @@ function EstimateActionsBar({ // #withDialogActions openDialog, + // #withDrawerActions + openDrawer, + // #withSettingsActions addSetting, }) { @@ -96,6 +106,10 @@ function EstimateActionsBar({ const handlePrintBtnClick = () => { downloadExportPdf({ resource: 'SaleEstimate' }); }; + // Handle customize button clicl. + const handleCustomizeBtnClick = () => { + openDrawer(DRAWERS.ESTIMATE_CUSTOMIZE); + }; return ( @@ -167,6 +181,25 @@ function EstimateActionsBar({ + + + + } + > +