Skip to content

Commit

Permalink
Merge pull request #657 from bigcapitalhq/suspense-lazy-banking-pages
Browse files Browse the repository at this point in the history
fix: Suspense the lazy loaded components in banking pages
  • Loading branch information
abouolia authored Sep 3, 2024
2 parents 0c6f23e + 9add716 commit 3b7e0fb
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 16 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// @ts-nocheck
import { Suspense, lazy } from 'react';
import { Spinner } from '@blueprintjs/core';
import { AppContentShell } from '@/components/AppShell';

const CategorizeTransactionAside = lazy(() =>
import('../CategorizeTransactionAside/CategorizeTransactionAside').then(
(module) => ({ default: module.CategorizeTransactionAside }),
),
);

export function AccountTransactionsAside() {
return (
<AppContentShell.Aside>
<Suspense fallback={<Spinner size={20} />}>
<CategorizeTransactionAside />
</Suspense>
</AppContentShell.Aside>
);
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// @ts-nocheck
import React, { Suspense } from 'react';
import * as R from 'ramda';
import { Spinner } from '@blueprintjs/core';
import { Suspense, lazy } from 'react';

import '@/style/pages/CashFlow/AccountTransactions/List.scss';

Expand All @@ -15,7 +15,7 @@ import {
import { AccountTransactionsDetailsBar } from './AccountTransactionsDetailsBar';
import { AccountTransactionsFilterTabs } from './AccountTransactionsFilterTabs';
import { AppContentShell } from '@/components/AppShell';
import { CategorizeTransactionAside } from '../CategorizeTransactionAside/CategorizeTransactionAside';
import { AccountTransactionsAside } from './AccountTransactionsAside';
import { AccountTransactionsLoadingBar } from './components';
import { withBanking } from '../withBanking';

Expand Down Expand Up @@ -56,14 +56,6 @@ function AccountTransactionsMain() {
);
}

function AccountTransactionsAside() {
return (
<AppContentShell.Aside>
<CategorizeTransactionAside />
</AppContentShell.Aside>
);
}

export default R.compose(
withBanking(
({ selectedUncategorizedTransactionId, openMatchingTransactionAside }) => ({
Expand All @@ -73,11 +65,8 @@ export default R.compose(
),
)(AccountTransactionsListRoot);

const AccountsTransactionsAll = React.lazy(
() => import('./AccountsTransactionsAll'),
);

const AccountsTransactionsUncategorized = React.lazy(
const AccountsTransactionsAll = lazy(() => import('./AccountsTransactionsAll'));
const AccountsTransactionsUncategorized = lazy(
() => import('./AllTransactionsUncategorized'),
);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// @ts-nocheck
import { Suspense } from 'react';
import styled from 'styled-components';
import * as R from 'ramda';
import { Spinner } from '@blueprintjs/core';
import { CategorizeTransactionBoot } from './CategorizeTransactionBoot';
import { CategorizeTransactionForm } from './CategorizeTransactionForm';
import { withBanking } from '@/containers/CashFlow/withBanking';
Expand All @@ -13,7 +15,9 @@ function CategorizeTransactionContentRoot({
uncategorizedTransactionsIds={transactionsToCategorizeIdsSelected}
>
<CategorizeTransactionDrawerBody>
<CategorizeTransactionForm />
<Suspense fallback={<Spinner size={40} />}>
<CategorizeTransactionForm />
</Suspense>
</CategorizeTransactionDrawerBody>
</CategorizeTransactionBoot>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import React, { createContext } from 'react';
import { defaultTo } from 'lodash';
import * as R from 'ramda';
import { useGetBankTransactionsMatches } from '@/hooks/query/bank-rules';
import { Spinner } from '@blueprintjs/core';

interface MatchingTransactionBootValues {
isMatchingTransactionsLoading: boolean;
Expand Down Expand Up @@ -52,6 +53,11 @@ function MatchingTransactionBoot({
matches,
} as MatchingTransactionBootValues;

const isLoading = isMatchingTransactionsLoading;

if (isLoading) {
return <Spinner size={40} />;
}
return <RuleFormBootContext.Provider value={provider} {...props} />;
}

Expand Down

0 comments on commit 3b7e0fb

Please sign in to comment.