mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-21 15:20:34 +00:00
feat: Optimize loading perf. by spliting big chunks and lazy loading them
This commit is contained in:
@@ -12,7 +12,6 @@ import AppIntlLoader from './AppIntlLoader';
|
|||||||
import { EnsureAuthenticated } from '@/components/Guards/EnsureAuthenticated';
|
import { EnsureAuthenticated } from '@/components/Guards/EnsureAuthenticated';
|
||||||
import GlobalErrors from '@/containers/GlobalErrors/GlobalErrors';
|
import GlobalErrors from '@/containers/GlobalErrors/GlobalErrors';
|
||||||
import DashboardPrivatePages from '@/components/Dashboard/PrivatePages';
|
import DashboardPrivatePages from '@/components/Dashboard/PrivatePages';
|
||||||
import { Authentication } from '@/containers/Authentication/Authentication';
|
|
||||||
|
|
||||||
import LazyLoader from '@/components/LazyLoader';
|
import LazyLoader from '@/components/LazyLoader';
|
||||||
import { SplashScreen, DashboardThemeProvider } from '../components';
|
import { SplashScreen, DashboardThemeProvider } from '../components';
|
||||||
@@ -21,6 +20,9 @@ import { EnsureUserEmailVerified } from './Guards/EnsureUserEmailVerified';
|
|||||||
import { EnsureAuthNotAuthenticated } from './Guards/EnsureAuthNotAuthenticated';
|
import { EnsureAuthNotAuthenticated } from './Guards/EnsureAuthNotAuthenticated';
|
||||||
import { EnsureUserEmailNotVerified } from './Guards/EnsureUserEmailNotVerified';
|
import { EnsureUserEmailNotVerified } from './Guards/EnsureUserEmailNotVerified';
|
||||||
|
|
||||||
|
const AuthenticationPage = LazyLoader({
|
||||||
|
loader: () => import('@/containers/Authentication/AuthenticationPage'),
|
||||||
|
});
|
||||||
const EmailConfirmation = LazyLoader({
|
const EmailConfirmation = LazyLoader({
|
||||||
loader: () => import('@/containers/Authentication/EmailConfirmation'),
|
loader: () => import('@/containers/Authentication/EmailConfirmation'),
|
||||||
});
|
});
|
||||||
@@ -53,12 +55,7 @@ function AppInsider({ history }) {
|
|||||||
<EmailConfirmation />
|
<EmailConfirmation />
|
||||||
</Route>
|
</Route>
|
||||||
|
|
||||||
<Route path={'/auth'}>
|
<Route path={'/auth'} children={<AuthenticationPage />} />
|
||||||
<EnsureAuthNotAuthenticated>
|
|
||||||
<Authentication />
|
|
||||||
</EnsureAuthNotAuthenticated>
|
|
||||||
</Route>
|
|
||||||
|
|
||||||
<Route path={'/'}>
|
<Route path={'/'}>
|
||||||
<EnsureAuthenticated>
|
<EnsureAuthenticated>
|
||||||
<EnsureUserEmailVerified>
|
<EnsureUserEmailVerified>
|
||||||
|
|||||||
@@ -0,0 +1,10 @@
|
|||||||
|
import { EnsureAuthNotAuthenticated } from "@/components/Guards/EnsureAuthNotAuthenticated";
|
||||||
|
import { Authentication } from "./Authentication";
|
||||||
|
|
||||||
|
export default function AuthenticationPage() {
|
||||||
|
return (
|
||||||
|
<EnsureAuthNotAuthenticated>
|
||||||
|
<Authentication />
|
||||||
|
</EnsureAuthNotAuthenticated>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -1,88 +1,96 @@
|
|||||||
// @ts-nocheck
|
// @ts-nocheck
|
||||||
import { lazy } from 'react';
|
import { lazy } from 'react';
|
||||||
import General from '@/containers/Preferences/General/General';
|
|
||||||
import Users from '../containers/Preferences/Users/Users';
|
|
||||||
import Roles from '../containers/Preferences/Users/Roles/RolesForm/RolesFormPage';
|
|
||||||
import Accountant from '@/containers/Preferences/Accountant/Accountant';
|
|
||||||
import Currencies from '@/containers/Preferences/Currencies/Currencies';
|
|
||||||
import Item from '@/containers/Preferences/Item';
|
|
||||||
// import SMSIntegration from '../containers/Preferences/SMSIntegration';
|
|
||||||
import DefaultRoute from '../containers/Preferences/DefaultRoute';
|
|
||||||
import Warehouses from '../containers/Preferences/Warehouses';
|
|
||||||
import Branches from '../containers/Preferences/Branches';
|
|
||||||
import Invoices from '../containers/Preferences/Invoices/PreferencesInvoices';
|
|
||||||
import { PreferencesCreditNotes } from '../containers/Preferences/CreditNotes/PreferencesCreditNotes';
|
|
||||||
import { PreferencesEstimates } from '@/containers/Preferences/Estimates/PreferencesEstimates';
|
|
||||||
import { PreferencesReceipts } from '@/containers/Preferences/Receipts/PreferencesReceipts';
|
|
||||||
|
|
||||||
import BillingPage from '@/containers/Subscriptions/BillingPage';
|
|
||||||
|
|
||||||
const BASE_URL = '/preferences';
|
const BASE_URL = '/preferences';
|
||||||
|
|
||||||
export default [
|
export default [
|
||||||
{
|
{
|
||||||
path: `${BASE_URL}/general`,
|
path: `${BASE_URL}/general`,
|
||||||
component: General,
|
component: lazy(() => import('@/containers/Preferences/General/General')),
|
||||||
exact: true,
|
exact: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: `${BASE_URL}/users`,
|
path: `${BASE_URL}/users`,
|
||||||
component: Users,
|
component: lazy(() => import('../containers/Preferences/Users/Users')),
|
||||||
exact: true,
|
exact: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: `${BASE_URL}/invoices`,
|
path: `${BASE_URL}/invoices`,
|
||||||
component: Invoices,
|
component: lazy(
|
||||||
|
() => import('../containers/Preferences/Invoices/PreferencesInvoices'),
|
||||||
|
),
|
||||||
exact: true,
|
exact: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: `${BASE_URL}/credit-notes`,
|
path: `${BASE_URL}/credit-notes`,
|
||||||
component: PreferencesCreditNotes,
|
component: lazy(() =>
|
||||||
|
import(
|
||||||
|
'../containers/Preferences/CreditNotes/PreferencesCreditNotes'
|
||||||
|
).then((module) => ({ default: module.PreferencesCreditNotes })),
|
||||||
|
),
|
||||||
exact: true,
|
exact: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: `${BASE_URL}/estimates`,
|
path: `${BASE_URL}/estimates`,
|
||||||
component: PreferencesEstimates,
|
component: lazy(() =>
|
||||||
|
import('@/containers/Preferences/Estimates/PreferencesEstimates').then(
|
||||||
|
(module) => ({ default: module.PreferencesEstimates }),
|
||||||
|
),
|
||||||
|
),
|
||||||
exact: true,
|
exact: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: `${BASE_URL}/receipts`,
|
path: `${BASE_URL}/receipts`,
|
||||||
component: PreferencesReceipts,
|
component: lazy(() =>
|
||||||
|
import('@/containers/Preferences/Receipts/PreferencesReceipts').then(
|
||||||
|
(module) => ({ default: module.PreferencesReceipts }),
|
||||||
|
),
|
||||||
|
),
|
||||||
exact: true,
|
exact: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: `${BASE_URL}/roles`,
|
path: `${BASE_URL}/roles`,
|
||||||
component: Roles,
|
component: lazy(
|
||||||
|
() =>
|
||||||
|
import('../containers/Preferences/Users/Roles/RolesForm/RolesFormPage'),
|
||||||
|
),
|
||||||
exact: true,
|
exact: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: `${BASE_URL}/roles/:id`,
|
path: `${BASE_URL}/roles/:id`,
|
||||||
component: Roles,
|
component: lazy(
|
||||||
|
() =>
|
||||||
|
import('../containers/Preferences/Users/Roles/RolesForm/RolesFormPage'),
|
||||||
|
),
|
||||||
exact: true,
|
exact: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: `${BASE_URL}/currencies`,
|
path: `${BASE_URL}/currencies`,
|
||||||
component: Currencies,
|
component: lazy(
|
||||||
|
() => import('@/containers/Preferences/Currencies/Currencies'),
|
||||||
|
),
|
||||||
exact: true,
|
exact: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: `${BASE_URL}/warehouses`,
|
path: `${BASE_URL}/warehouses`,
|
||||||
component: Warehouses,
|
component: lazy(() => import('../containers/Preferences/Warehouses')),
|
||||||
exact: true,
|
exact: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: `${BASE_URL}/branches`,
|
path: `${BASE_URL}/branches`,
|
||||||
component: Branches,
|
component: lazy(() => import('../containers/Preferences/Branches')),
|
||||||
exact: true,
|
exact: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: `${BASE_URL}/accountant`,
|
path: `${BASE_URL}/accountant`,
|
||||||
component: Accountant,
|
component: lazy(
|
||||||
|
() => import('@/containers/Preferences/Accountant/Accountant'),
|
||||||
|
),
|
||||||
exact: true,
|
exact: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: `${BASE_URL}/items`,
|
path: `${BASE_URL}/items`,
|
||||||
component: Item,
|
component: lazy(() => import('@/containers/Preferences/Item')),
|
||||||
exact: true,
|
exact: true,
|
||||||
},
|
},
|
||||||
// {
|
// {
|
||||||
@@ -92,12 +100,12 @@ export default [
|
|||||||
// },
|
// },
|
||||||
{
|
{
|
||||||
path: `${BASE_URL}/billing`,
|
path: `${BASE_URL}/billing`,
|
||||||
component: BillingPage,
|
component: lazy(() => import('@/containers/Subscriptions/BillingPage')),
|
||||||
exact: true,
|
exact: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: `${BASE_URL}/`,
|
path: `${BASE_URL}/`,
|
||||||
component: DefaultRoute,
|
component: lazy(() => import('../containers/Preferences/DefaultRoute')),
|
||||||
exact: true,
|
exact: true,
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|||||||
Reference in New Issue
Block a user