Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Suspense the lazy loaded components in banking pages #657

Merged
merged 1 commit into from
Sep 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading