From d4a933ef1879777d3fdf231705c7f4aac47b59fe Mon Sep 17 00:00:00 2001 From: Ahmed Bouhuolia Date: Mon, 17 Jul 2023 01:41:13 +0200 Subject: [PATCH] fix(webapp): show loading message of cost computing job on financial reports --- .../BalanceSheet/components.tsx | 26 ++++++++++--------- .../CashFlowStatement/components.tsx | 23 +++++++++------- .../GeneralLedger/components.tsx | 22 +++++++++------- .../InventoryItemDetails/components.tsx | 21 ++++++++------- .../Journal/components.tsx | 22 +++++++++------- .../ProfitLossSheet/ProfitLossSheet.tsx | 4 +-- .../ProfitLossSheet/components.tsx | 22 +++++++++------- .../TrialBalanceSheet/components.tsx | 22 +++++++++------- 8 files changed, 89 insertions(+), 73 deletions(-) diff --git a/packages/webapp/src/containers/FinancialStatements/BalanceSheet/components.tsx b/packages/webapp/src/containers/FinancialStatements/BalanceSheet/components.tsx index 9bde9747d..08f946f75 100644 --- a/packages/webapp/src/containers/FinancialStatements/BalanceSheet/components.tsx +++ b/packages/webapp/src/containers/FinancialStatements/BalanceSheet/components.tsx @@ -21,19 +21,21 @@ export function BalanceSheetAlerts() { refetchBalanceSheet(); }; // Can't display any error if the report is loading. - if (isLoading) return null; - + if (isLoading) { + return null; + } + // Can't continue if the cost compute job is not running. + if (!balanceSheet.meta.is_cost_compute_running) { + return null; + } return ( - - - {' '} - - - - - + + {' '} + + + ); } diff --git a/packages/webapp/src/containers/FinancialStatements/CashFlowStatement/components.tsx b/packages/webapp/src/containers/FinancialStatements/CashFlowStatement/components.tsx index 5458fc7f9..1d1af31f5 100644 --- a/packages/webapp/src/containers/FinancialStatements/CashFlowStatement/components.tsx +++ b/packages/webapp/src/containers/FinancialStatements/CashFlowStatement/components.tsx @@ -7,6 +7,7 @@ import FinancialLoadingBar from '../FinancialLoadingBar'; import { dynamicColumns } from './dynamicColumns'; import { useCashFlowStatementContext } from './CashFlowStatementProvider'; +import { FinancialComputeAlert } from '../FinancialReportPage'; /** * Retrieve cash flow statement columns. @@ -27,6 +28,7 @@ export const useCashFlowStatementColumns = () => { */ export function CashFlowStatementLoadingBar() { const { isCashFlowFetching } = useCashFlowStatementContext(); + return ( @@ -45,20 +47,21 @@ export function CashFlowStatementAlerts() { const handleRecalcReport = () => { refetchCashFlow(); }; - // Can't display any error if the report is loading if (isCashFlowLoading) { return null; } + // Can't continue if the cost compute is not running. + if (!cashFlowStatement.meta.is_cost_compute_running) { + return null; + } return ( - -
- - - -
-
+ + + + + ); } diff --git a/packages/webapp/src/containers/FinancialStatements/GeneralLedger/components.tsx b/packages/webapp/src/containers/FinancialStatements/GeneralLedger/components.tsx index b3793a5e1..441892178 100644 --- a/packages/webapp/src/containers/FinancialStatements/GeneralLedger/components.tsx +++ b/packages/webapp/src/containers/FinancialStatements/GeneralLedger/components.tsx @@ -8,6 +8,7 @@ import { getColumnWidth } from '@/utils'; import { useGeneralLedgerContext } from './GeneralLedgerProvider'; import FinancialLoadingBar from '../FinancialLoadingBar'; +import { FinancialComputeAlert } from '../FinancialReportPage'; import { Align } from '@/constants'; /** @@ -116,17 +117,18 @@ export function GeneralLedgerSheetAlerts() { if (isLoading) { return null; } - + // Can't continue if the cost compute job is not running. + if (!generalLedger.meta.is_cost_compute_running) { + return null; + } return ( - -
- - - -
-
+ + + + + ); } diff --git a/packages/webapp/src/containers/FinancialStatements/InventoryItemDetails/components.tsx b/packages/webapp/src/containers/FinancialStatements/InventoryItemDetails/components.tsx index 6349b0a55..b56f91a23 100644 --- a/packages/webapp/src/containers/FinancialStatements/InventoryItemDetails/components.tsx +++ b/packages/webapp/src/containers/FinancialStatements/InventoryItemDetails/components.tsx @@ -6,6 +6,7 @@ import { Icon, If, FormattedMessage as T } from '@/components'; import { dynamicColumns } from './utils'; import FinancialLoadingBar from '../FinancialLoadingBar'; import { useInventoryItemDetailsContext } from './InventoryItemDetailsProvider'; +import { FinancialComputeAlert } from '../FinancialReportPage'; /** * Retrieve inventory item details columns. @@ -53,17 +54,19 @@ export function InventoryItemDetailsAlerts() { if (isInventoryItemDetailsLoading) { return null; } + // Can't continue if the cost compute job is running. + if (!inventoryItemDetails.meta.is_cost_compute_running) { + return null; + } return ( - -
- - + + + - -
-
+ + ); } diff --git a/packages/webapp/src/containers/FinancialStatements/Journal/components.tsx b/packages/webapp/src/containers/FinancialStatements/Journal/components.tsx index d3ebab02c..23a744091 100644 --- a/packages/webapp/src/containers/FinancialStatements/Journal/components.tsx +++ b/packages/webapp/src/containers/FinancialStatements/Journal/components.tsx @@ -7,6 +7,7 @@ import { Button } from '@blueprintjs/core'; import { Icon, If, FormattedMessage as T } from '@/components'; import { useJournalSheetContext } from './JournalProvider'; import FinancialLoadingBar from '../FinancialLoadingBar'; +import { FinancialComputeAlert } from '../FinancialReportPage'; import { Align } from '@/constants'; @@ -99,17 +100,18 @@ export function JournalSheetAlerts() { if (isLoading) { return null; } - + // Can't continue if the cost compute job is running. + if (!journalSheet.meta.is_cost_compute_running) { + return null; + } return ( - -
- - + + + - -
-
+ + ); } diff --git a/packages/webapp/src/containers/FinancialStatements/ProfitLossSheet/ProfitLossSheet.tsx b/packages/webapp/src/containers/FinancialStatements/ProfitLossSheet/ProfitLossSheet.tsx index b1bd9b164..151937c3a 100644 --- a/packages/webapp/src/containers/FinancialStatements/ProfitLossSheet/ProfitLossSheet.tsx +++ b/packages/webapp/src/containers/FinancialStatements/ProfitLossSheet/ProfitLossSheet.tsx @@ -13,7 +13,7 @@ import withProfitLossActions from './withProfitLossActions'; import { useProfitLossSheetQuery } from './utils'; import { ProfitLossSheetProvider } from './ProfitLossProvider'; -import { ProfitLossSheetLoadingBar } from './components'; +import { ProfitLossSheetAlerts, ProfitLossSheetLoadingBar } from './components'; import { ProfitLossBody } from './ProfitLossBody'; /** @@ -58,7 +58,7 @@ function ProfitLossSheet({ onNumberFormatSubmit={handleNumberFormatSubmit} /> - {/* */} + -
- - + + + - -
-
+ + ); } diff --git a/packages/webapp/src/containers/FinancialStatements/TrialBalanceSheet/components.tsx b/packages/webapp/src/containers/FinancialStatements/TrialBalanceSheet/components.tsx index 38f7e3051..c24efd6bc 100644 --- a/packages/webapp/src/containers/FinancialStatements/TrialBalanceSheet/components.tsx +++ b/packages/webapp/src/containers/FinancialStatements/TrialBalanceSheet/components.tsx @@ -8,9 +8,9 @@ import { getColumnWidth } from '@/utils'; import { CellTextSpan } from '@/components/Datatable/Cells'; import { If, Icon, FormattedMessage as T } from '@/components'; import { useTrialBalanceSheetContext } from './TrialBalanceProvider'; +import { FinancialComputeAlert } from '../FinancialReportPage'; import FinancialLoadingBar from '../FinancialLoadingBar'; - /** * Retrieves the credit column. */ @@ -114,17 +114,19 @@ export function TrialBalanceSheetAlerts() { if (isLoading) { return null; } + // Can't continue if the cost compute job is not running. + if (!meta.is_cost_compute_running) { + return null; + } return ( - -
- - + + + - -
-
+ + ); }