diff --git a/packages/webapp/src/containers/FinancialStatements/BalanceSheet/components.tsx b/packages/webapp/src/containers/FinancialStatements/BalanceSheet/components.tsx index 9bde9747da..08f946f750 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 ( - <If condition={balanceSheet.meta.is_cost_compute_running}> - <FinancialComputeAlert> - <Icon icon="info-block" iconSize={12} />{' '} - <T id={'just_a_moment_we_re_calculating_your_cost_transactions'} /> - - <Button onClick={handleRecalcReport} minimal={true} small={true}> - <T id={'report.compute_running.refresh'} /> - </Button> - </FinancialComputeAlert> - </If> + <FinancialComputeAlert> + <Icon icon="info-block" iconSize={12} />{' '} + <T id={'just_a_moment_we_re_calculating_your_cost_transactions'} /> + <Button onClick={handleRecalcReport} minimal={true} small={true}> + <T id={'report.compute_running.refresh'} /> + </Button> + </FinancialComputeAlert> ); } diff --git a/packages/webapp/src/containers/FinancialStatements/CashFlowStatement/components.tsx b/packages/webapp/src/containers/FinancialStatements/CashFlowStatement/components.tsx index 5458fc7f94..1d1af31f57 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 ( <If condition={isCashFlowFetching}> <FinancialLoadingBar /> @@ -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 ( - <If condition={cashFlowStatement.meta.is_cost_compute_running}> - <div className="alert-compute-running"> - <Icon icon="info-block" iconSize={12} /> - <T id={'just_a_moment_we_re_calculating_your_cost_transactions'} /> - <Button onClick={handleRecalcReport} minimal={true} small={true}> - <T id={'refresh'} /> - </Button> - </div> - </If> + <FinancialComputeAlert> + <Icon icon="info-block" iconSize={12} /> + <T id={'just_a_moment_we_re_calculating_your_cost_transactions'} /> + <Button onClick={handleRecalcReport} minimal={true} small={true}> + <T id={'refresh'} /> + </Button> + </FinancialComputeAlert> ); } diff --git a/packages/webapp/src/containers/FinancialStatements/GeneralLedger/components.tsx b/packages/webapp/src/containers/FinancialStatements/GeneralLedger/components.tsx index b3793a5e1d..4418921782 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 ( - <If condition={generalLedger.meta.is_cost_compute_running}> - <div class="alert-compute-running"> - <Icon icon="info-block" iconSize={12} /> - <T id={'just_a_moment_we_re_calculating_your_cost_transactions'} /> - <Button onClick={handleRecalcReport} minimal={true} small={true}> - <T id={'refresh'} /> - </Button> - </div> - </If> + <FinancialComputeAlert> + <Icon icon="info-block" iconSize={12} /> + <T id={'just_a_moment_we_re_calculating_your_cost_transactions'} /> + <Button onClick={handleRecalcReport} minimal={true} small={true}> + <T id={'refresh'} /> + </Button> + </FinancialComputeAlert> ); } diff --git a/packages/webapp/src/containers/FinancialStatements/InventoryItemDetails/components.tsx b/packages/webapp/src/containers/FinancialStatements/InventoryItemDetails/components.tsx index 6349b0a557..b56f91a238 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 ( - <If condition={inventoryItemDetails.meta.is_cost_compute_running}> - <div className="alert-compute-running"> - <Icon icon="info-block" iconSize={12} /> - <T id={'just_a_moment_we_re_calculating_your_cost_transactions'} /> + <FinancialComputeAlert> + <Icon icon="info-block" iconSize={12} /> + <T id={'just_a_moment_we_re_calculating_your_cost_transactions'} /> - <Button onClick={handleRecalcReport} minimal={true} small={true}> - <T id={'refresh'} /> - </Button> - </div> - </If> + <Button onClick={handleRecalcReport} minimal={true} small={true}> + <T id={'refresh'} /> + </Button> + </FinancialComputeAlert> ); } diff --git a/packages/webapp/src/containers/FinancialStatements/Journal/components.tsx b/packages/webapp/src/containers/FinancialStatements/Journal/components.tsx index d3ebab02c2..23a7440919 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 ( - <If condition={journalSheet.meta.is_cost_compute_running}> - <div class="alert-compute-running"> - <Icon icon="info-block" iconSize={12} /> - <T id={'just_a_moment_we_re_calculating_your_cost_transactions'} /> + <FinancialComputeAlert> + <Icon icon="info-block" iconSize={12} /> + <T id={'just_a_moment_we_re_calculating_your_cost_transactions'} /> - <Button onClick={handleRecalcReport} minimal={true} small={true}> - <T id={'refresh'} /> - </Button> - </div> - </If> + <Button onClick={handleRecalcReport} minimal={true} small={true}> + <T id={'refresh'} /> + </Button> + </FinancialComputeAlert> ); } diff --git a/packages/webapp/src/containers/FinancialStatements/ProfitLossSheet/ProfitLossSheet.tsx b/packages/webapp/src/containers/FinancialStatements/ProfitLossSheet/ProfitLossSheet.tsx index b1bd9b1642..151937c3a4 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} /> <ProfitLossSheetLoadingBar /> - {/* <ProfitLossSheetAlerts /> */} + <ProfitLossSheetAlerts /> <DashboardPageContent> <ProfitLossSheetHeader diff --git a/packages/webapp/src/containers/FinancialStatements/ProfitLossSheet/components.tsx b/packages/webapp/src/containers/FinancialStatements/ProfitLossSheet/components.tsx index 32a5160528..e64255953d 100644 --- a/packages/webapp/src/containers/FinancialStatements/ProfitLossSheet/components.tsx +++ b/packages/webapp/src/containers/FinancialStatements/ProfitLossSheet/components.tsx @@ -4,6 +4,7 @@ import { Button } from '@blueprintjs/core'; import { Icon, If, FormattedMessage as T } from '@/components'; import { useProfitLossSheetContext } from './ProfitLossProvider'; +import { FinancialComputeAlert } from '../FinancialReportPage'; import FinancialLoadingBar from '../FinancialLoadingBar'; /** @@ -34,17 +35,18 @@ export function ProfitLossSheetAlerts() { if (isLoading) { return null; } - + // Can't continue if the cost compute job is not running. + if (!profitLossSheet.meta.is_cost_compute_running) { + return null; + } return ( - <If condition={profitLossSheet.meta.is_cost_compute_running}> - <div class="alert-compute-running"> - <Icon icon="info-block" iconSize={12} /> - <T id={'just_a_moment_we_re_calculating_your_cost_transactions'} /> + <FinancialComputeAlert> + <Icon icon="info-block" iconSize={12} /> + <T id={'just_a_moment_we_re_calculating_your_cost_transactions'} /> - <Button onClick={handleRecalcReport} minimal={true} small={true}> - <T id={'refresh'} /> - </Button> - </div> - </If> + <Button onClick={handleRecalcReport} minimal={true} small={true}> + <T id={'refresh'} /> + </Button> + </FinancialComputeAlert> ); } diff --git a/packages/webapp/src/containers/FinancialStatements/TrialBalanceSheet/components.tsx b/packages/webapp/src/containers/FinancialStatements/TrialBalanceSheet/components.tsx index 38f7e30517..c24efd6bc0 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 ( - <If condition={meta.is_cost_compute_running}> - <div class="alert-compute-running"> - <Icon icon="info-block" iconSize={12} /> - <T id={'just_a_moment_we_re_calculating_your_cost_transactions'} /> + <FinancialComputeAlert> + <Icon icon="info-block" iconSize={12} /> + <T id={'just_a_moment_we_re_calculating_your_cost_transactions'} /> - <Button onClick={handleRecalcReport} minimal={true} small={true}> - <T id={'refresh'} /> - </Button> - </div> - </If> + <Button onClick={handleRecalcReport} minimal={true} small={true}> + <T id={'refresh'} /> + </Button> + </FinancialComputeAlert> ); }