feat: split the preferences pages

This commit is contained in:
Ahmed Bouhuolia
2024-08-29 20:49:08 +02:00
parent c9fe6d9b37
commit af284f3f6d
7 changed files with 888 additions and 85 deletions

View File

@@ -1,4 +1,5 @@
// @ts-nocheck
import { lazy, Suspense } from 'react';
import { Router, Switch, Route } from 'react-router';
import { createBrowserHistory } from 'history';
import { QueryClientProvider, QueryClient } from 'react-query';
@@ -11,27 +12,26 @@ import 'moment/locale/es-us';
import AppIntlLoader from './AppIntlLoader';
import { EnsureAuthenticated } from '@/components/Guards/EnsureAuthenticated';
import GlobalErrors from '@/containers/GlobalErrors/GlobalErrors';
import DashboardPrivatePages from '@/components/Dashboard/PrivatePages';
import LazyLoader from '@/components/LazyLoader';
import { SplashScreen, DashboardThemeProvider } from '../components';
import { queryConfig } from '../hooks/query/base';
import { EnsureUserEmailVerified } from './Guards/EnsureUserEmailVerified';
import { EnsureAuthNotAuthenticated } from './Guards/EnsureAuthNotAuthenticated';
import { EnsureUserEmailNotVerified } from './Guards/EnsureUserEmailNotVerified';
const AuthenticationPage = LazyLoader({
loader: () => import('@/containers/Authentication/AuthenticationPage'),
});
const EmailConfirmation = LazyLoader({
loader: () => import('@/containers/Authentication/EmailConfirmation'),
});
const RegisterVerify = LazyLoader({
loader: () => import('@/containers/Authentication/RegisterVerify'),
});
const OneClickDemoPage = LazyLoader({
loader: () => import('@/containers/OneClickDemo/OneClickDemoPage'),
});
const DashboardPrivatePages = lazy(
() => import('@/components/Dashboard/PrivatePages'),
);
const AuthenticationPage = lazy(
() => import('@/containers/Authentication/AuthenticationPage'),
);
const EmailConfirmation = lazy(
() => import('@/containers/Authentication/EmailConfirmation'),
);
const RegisterVerify = lazy(
() => import('@/containers/Authentication/RegisterVerify'),
);
const OneClickDemoPage = lazy(
() => import('@/containers/OneClickDemo/OneClickDemoPage'),
);
/**
* App inner.
@@ -40,31 +40,27 @@ function AppInsider({ history }) {
return (
<div className="App">
<DashboardThemeProvider>
<Router history={history}>
<Switch>
<Route path={'/one_click_demo'} children={<OneClickDemoPage />} />
<Route path={'/auth/register/verify'}>
<EnsureAuthenticated>
<EnsureUserEmailNotVerified>
<RegisterVerify />
</EnsureUserEmailNotVerified>
</EnsureAuthenticated>
</Route>
<Suspense fallback={'Loading...'}>
<Router history={history}>
<Switch>
<Route path={'/one_click_demo'} children={<OneClickDemoPage />} />
<Route path={'/auth/register/verify'}>
<EnsureAuthenticated>
<EnsureUserEmailNotVerified>
<RegisterVerify />
</EnsureUserEmailNotVerified>
</EnsureAuthenticated>
</Route>
<Route path={'/auth/email_confirmation'}>
<EmailConfirmation />
</Route>
<Route path={'/auth'} children={<AuthenticationPage />} />
<Route path={'/'}>
<EnsureAuthenticated>
<EnsureUserEmailVerified>
<DashboardPrivatePages />
</EnsureUserEmailVerified>
</EnsureAuthenticated>
</Route>
</Switch>
</Router>
<Route
path={'/auth/email_confirmation'}
children={<EmailConfirmation />}
/>
<Route path={'/auth'} children={<AuthenticationPage />} />
<Route path={'/'} children={<DashboardPrivatePages />} />
</Switch>
</Router>
</Suspense>
<GlobalErrors />
</DashboardThemeProvider>

View File

@@ -1,35 +1,37 @@
// @ts-nocheck
import React from 'react';
import React, { lazy } from 'react';
import { Switch, Route } from 'react-router';
import Dashboard from '@/components/Dashboard/Dashboard';
import SetupWizardPage from '@/containers/Setup/WizardSetupPage';
import EnsureOrganizationIsReady from '../Guards/EnsureOrganizationIsReady';
import EnsureOrganizationIsNotReady from '../Guards/EnsureOrganizationIsNotReady';
import { PrivatePagesProvider } from './PrivatePagesProvider';
import EnsureOrganizationIsReady from '../Guards/EnsureOrganizationIsReady';
import { EnsureAuthenticated } from '../Guards/EnsureAuthenticated';
import { EnsureUserEmailVerified } from '../Guards/EnsureUserEmailVerified';
import '@/style/pages/Dashboard/Dashboard.scss';
const SetupWizardPage = lazy(
() => import('@/containers/Setup/WizardSetupPage'),
);
/**
* Dashboard inner private pages.
*/
export default function DashboardPrivatePages() {
return (
<PrivatePagesProvider>
<Switch>
<Route path={'/setup'}>
<EnsureOrganizationIsNotReady>
<SetupWizardPage />
</EnsureOrganizationIsNotReady>
</Route>
<Route path="/">
<EnsureOrganizationIsReady>
<Dashboard />
</EnsureOrganizationIsReady>
</Route>
</Switch>
</PrivatePagesProvider>
<EnsureAuthenticated>
<EnsureUserEmailVerified>
<PrivatePagesProvider>
<Switch>
<Route path={'/setup'} children={<SetupWizardPage />} />
<Route path="/">
<EnsureOrganizationIsReady>
<Dashboard />
</EnsureOrganizationIsReady>
</Route>
</Switch>
</PrivatePagesProvider>
</EnsureUserEmailVerified>
</EnsureAuthenticated>
);
}

View File

@@ -1,9 +1,11 @@
// @ts-nocheck
import React from 'react';
import { Route, Switch } from 'react-router-dom';
import preferencesRoutes from '@/routes/preferences';
import { getPreferenceRoutes } from '@/routes/preferences';
export default function DashboardContentRoute() {
const preferencesRoutes = getPreferenceRoutes();
return (
<Route pathname="/preferences">
<Switch>

View File

@@ -2,14 +2,17 @@
import React from 'react';
import SetupRightSection from './SetupRightSection';
import SetupLeftSection from './SetupLeftSection';
import EnsureOrganizationIsNotReady from '@/components/Guards/EnsureOrganizationIsNotReady';
import '@/style/pages/Setup/SetupPage.scss';
export default function WizardSetupPage() {
return (
<div class="setup-page">
<SetupLeftSection />
<SetupRightSection />
</div>
<EnsureOrganizationIsNotReady>
<div class="setup-page">
<SetupLeftSection />
<SetupRightSection />
</div>
</EnsureOrganizationIsNotReady>
);
};
}

View File

@@ -1,43 +1,35 @@
// @ts-nocheck
import LazyLoader from '@/components/LazyLoader';
import { lazy } from 'react';
const BASE_URL = '/auth';
export default [
{
path: `${BASE_URL}/login`,
component: LazyLoader({
loader: () => import('@/containers/Authentication/Login'),
}),
component: lazy(() => import('@/containers/Authentication/Login')),
},
{
path: `${BASE_URL}/send_reset_password`,
component: LazyLoader({
loader: () => import('@/containers/Authentication/SendResetPassword'),
}),
component: lazy(
() => import('@/containers/Authentication/SendResetPassword'),
),
},
{
path: `${BASE_URL}/reset_password/:token`,
component: LazyLoader({
loader: () => import('@/containers/Authentication/ResetPassword'),
}),
component: lazy(() => import('@/containers/Authentication/ResetPassword')),
},
{
path: `${BASE_URL}/invite/:token/accept`,
component: LazyLoader({
loader: () => import('@/containers/Authentication/InviteAccept'),
}),
component: lazy(() => import('@/containers/Authentication/InviteAccept')),
},
{
path: `${BASE_URL}/register/email_confirmation`,
component: LazyLoader({
loader: () => import('@/containers/Authentication/EmailConfirmation'),
}),
component: lazy(
() => import('@/containers/Authentication/EmailConfirmation'),
),
},
{
path: `${BASE_URL}/register`,
component: LazyLoader({
loader: () => import('@/containers/Authentication/Register'),
}),
component: lazy(() => import('@/containers/Authentication/Register')),
},
];

View File

@@ -3,7 +3,7 @@ import { lazy } from 'react';
const BASE_URL = '/preferences';
export default [
export const getPreferenceRoutes = () => [
{
path: `${BASE_URL}/general`,
component: lazy(() => import('@/containers/Preferences/General/General')),