Skip to content

Commit

Permalink
make basic account routing work
Browse files Browse the repository at this point in the history
  • Loading branch information
bnussman committed Sep 26, 2024
1 parent becf94a commit 28511f5
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 52 deletions.
72 changes: 48 additions & 24 deletions packages/manager/src/features/Account/AccountLanding.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ import { sendSwitchAccountEvent } from 'src/utilities/analytics/customEventAnaly
import AccountLogins from './AccountLogins';
import { SwitchAccountButton } from './SwitchAccountButton';
import { SwitchAccountDrawer } from './SwitchAccountDrawer';
import { createLazyRoute, createRoute, Outlet } from '@tanstack/react-router';
import { accountRoute } from 'src/routes/account';

const Billing = React.lazy(() =>
import('src/features/Billing/BillingDetail').then((module) => ({
Expand Down Expand Up @@ -184,29 +186,11 @@ const AccountLanding = () => {

<Tabs index={getDefaultTabIndex()} onChange={handleTabChange}>
<TabLinkList tabs={tabs} />

<React.Suspense fallback={<SuspenseLoader />}>
<TabPanels>
<SafeTabPanel index={idx}>
<Billing />
</SafeTabPanel>
<SafeTabPanel index={++idx}>
<Users />
</SafeTabPanel>
<SafeTabPanel index={++idx}>
<AccountLogins />
</SafeTabPanel>
<SafeTabPanel index={++idx}>
<EntityTransfersLanding />
</SafeTabPanel>
<SafeTabPanel index={++idx}>
<MaintenanceLanding />
</SafeTabPanel>
<SafeTabPanel index={++idx}>
<GlobalSettings />
</SafeTabPanel>
</TabPanels>
</React.Suspense>
<TabPanels>
<React.Suspense fallback={<SuspenseLoader />}>
<Outlet />
</React.Suspense>
</TabPanels>
</Tabs>
<SwitchAccountDrawer
onClose={() => setIsDrawerOpen(false)}
Expand All @@ -217,4 +201,44 @@ const AccountLanding = () => {
);
};

export default AccountLanding;
export const accountIndexRoute = createRoute({
component: AccountLanding,
getParentRoute: () => accountRoute,
path: '/',
});

export const accountBillingRoute = createRoute({
component: Billing,
getParentRoute: () => accountIndexRoute,
path: 'billing'
});

export const accountUsersRoute = createRoute({
component: Users,
getParentRoute: () => accountIndexRoute,
path: 'users',
});

export const accountLoginHistoryRoute = createRoute({
component: AccountLogins,
getParentRoute: () => accountIndexRoute,
path: 'login-history',
});

export const accountServiceTransfersRoute = createRoute({
component: EntityTransfersLanding,
getParentRoute: () => accountIndexRoute,
path: 'service-transfers',
});

export const accountMaintenanceRoute = createRoute({
component: MaintenanceLanding,
getParentRoute: () => accountIndexRoute,
path: 'maintenance',
});

export const accountSettingsRoute = createRoute({
component: GlobalSettings,
getParentRoute: () => accountIndexRoute,
path: 'settings',
});
46 changes: 18 additions & 28 deletions packages/manager/src/routes/account.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,15 @@ import React from 'react';

import { ProductInformationBanner } from 'src/components/ProductInformationBanner/ProductInformationBanner';
import { SuspenseLoader } from 'src/components/SuspenseLoader';
import {
accountBillingRoute,
accountIndexRoute,
accountLoginHistoryRoute,
accountMaintenanceRoute,
accountServiceTransfersRoute,
accountSettingsRoute,
accountUsersRoute,
} from 'src/features/Account/AccountLanding';

import { rootRoute } from './root';
import { strictLazyRouteComponent } from './utils';
Expand All @@ -16,20 +25,12 @@ export const AccountRoutes = () => {
);
};

const accountRoute = createRoute({
export const accountRoute = createRoute({
component: AccountRoutes,
getParentRoute: () => rootRoute,
path: 'account',
});

const accountIndexRoute = createRoute({
component: strictLazyRouteComponent(
() => import('src/features/Account/AccountLanding')
),
getParentRoute: () => accountRoute,
path: '/',
});

const accountUsersUsernameRoute = createRoute({
component: strictLazyRouteComponent(
() => import('src/features/Users/UserDetail'),
Expand All @@ -56,22 +57,6 @@ const accountUsersUsernamePermissionsRoute = createRoute({
path: 'users/$username/permissions',
});

const accountBillingRoute = createRoute({
component: strictLazyRouteComponent(
() => import('src/features/Account/AccountLanding')
),
getParentRoute: () => accountRoute,
path: 'billing',
});

const accountBillingEditRoute = createRoute({
component: strictLazyRouteComponent(
() => import('src/features/Account/AccountLanding')
),
getParentRoute: () => accountRoute,
path: 'billing/edit',
});

const accountInvoicesInvoiceIdRoute = createRoute({
component: strictLazyRouteComponent(
() => import('src/features/Billing/InvoiceDetail/InvoiceDetail'),
Expand All @@ -97,13 +82,18 @@ const accountEntityTransfersCreateRoute = createRoute({
});

export const accountRouteTree = accountRoute.addChildren([
accountIndexRoute,
accountUsersUsernameRoute.addChildren([
accountUsersUsernameProfileRoute,
accountUsersUsernamePermissionsRoute,
]),
accountBillingRoute,
accountBillingEditRoute,
accountIndexRoute.addChildren([
accountBillingRoute,
accountUsersRoute,
accountLoginHistoryRoute,
accountServiceTransfersRoute,
accountMaintenanceRoute,
accountSettingsRoute,
]),
accountInvoicesInvoiceIdRoute,
accountEntityTransfersCreateRoute,
]);

0 comments on commit 28511f5

Please sign in to comment.