Skip to content

Commit

Permalink
feat: simplify routing component
Browse files Browse the repository at this point in the history
  • Loading branch information
sdrejkarz committed May 28, 2024
1 parent 423afdc commit b591910
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 44 deletions.
89 changes: 46 additions & 43 deletions packages/webapp/src/app/app.component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,53 +44,56 @@ export const App = () => {
<Route element={<ValidRoutesProviders />}>
<Route path={LANG_PREFIX}>
<Route path={RoutesConfig.logout} element={<Logout />} />
</Route>
<Route path={LANG_PREFIX} element={<AnonymousRoute />}>
<Route path={RoutesConfig.signup} element={<Signup />} />
<Route path={RoutesConfig.login} element={<Login />} />
<Route path={RoutesConfig.validateOtp} element={<ValidateOtp />} />
<Route path="*" element={<NotFound />} />
</Route>
<Route path={TENANT_PREFIX} element={<AuthRoute />}>
<Route index element={<Home />} />
<Route element={<TenantAuthRoute allowedRoles={[TenantUserRole.ADMIN, TenantUserRole.OWNER]} />}>
<Route element={<TenantSettings />}>
<Route path={RoutesConfig.tenant.settings.members} element={<TenantMembers />} />
<Route path={RoutesConfig.tenant.settings.general} element={<TenantGeneralSettings />} />
</Route>
<Route element={<ActiveSubscriptionContext />}>
<Route element={<Subscriptions />}>
<Route index path={RoutesConfig.subscriptions.index} element={<CurrentSubscriptionContent />} />
<Route path={RoutesConfig.subscriptions.paymentMethods.index} element={<PaymentMethodContent />} />
<Route
path={RoutesConfig.subscriptions.transactionHistory.index}
element={<TransactionsHistoryContent />}
/>

<Route element={<AnonymousRoute />}>
<Route path={RoutesConfig.signup} element={<Signup />} />
<Route path={RoutesConfig.login} element={<Login />} />
<Route path={RoutesConfig.validateOtp} element={<ValidateOtp />} />
<Route path="*" element={<NotFound />} />
</Route>

<Route path={TENANT_PREFIX} element={<AuthRoute />}>
<Route index element={<Home />} />
<Route element={<TenantAuthRoute allowedRoles={[TenantUserRole.ADMIN, TenantUserRole.OWNER]} />}>
<Route element={<TenantSettings />}>
<Route path={RoutesConfig.tenant.settings.members} element={<TenantMembers />} />
<Route path={RoutesConfig.tenant.settings.general} element={<TenantGeneralSettings />} />
</Route>
<Route path={RoutesConfig.subscriptions.currentSubscription.edit} element={<EditSubscription />} />
<Route path={RoutesConfig.subscriptions.currentSubscription.cancel} element={<CancelSubscription />} />
<Route path={RoutesConfig.subscriptions.paymentMethods.edit} element={<EditPaymentMethod />} />
<Route element={<ActiveSubscriptionContext />}>
<Route element={<Subscriptions />}>
<Route index path={RoutesConfig.subscriptions.index} element={<CurrentSubscriptionContent />} />
<Route path={RoutesConfig.subscriptions.paymentMethods.index} element={<PaymentMethodContent />} />
<Route
path={RoutesConfig.subscriptions.transactionHistory.index}
element={<TransactionsHistoryContent />}
/>
</Route>
<Route path={RoutesConfig.subscriptions.currentSubscription.edit} element={<EditSubscription />} />
<Route path={RoutesConfig.subscriptions.currentSubscription.cancel} element={<CancelSubscription />} />
<Route path={RoutesConfig.subscriptions.paymentMethods.edit} element={<EditPaymentMethod />} />
</Route>
<Route path={RoutesConfig.finances.paymentConfirm} element={<PaymentConfirm />} />
<Route path={RoutesConfig.subscriptions.transactionHistory.history} element={<TransactionHistory />} />
</Route>
<Route path={RoutesConfig.finances.paymentConfirm} element={<PaymentConfirm />} />
<Route path={RoutesConfig.subscriptions.transactionHistory.history} element={<TransactionHistory />} />
<Route path={RoutesConfig.demoItems} element={<DemoItems />} />
<Route path={RoutesConfig.demoItem} element={<DemoItem routesConfig={RoutesConfig} />} />
<Route path={RoutesConfig.crudDemoItem.index} element={<CrudDemoItem routesConfig={RoutesConfig} />} />
<Route path={RoutesConfig.documents} element={<Documents />} />
<Route path={RoutesConfig.saasIdeas} element={<SaasIdeas />} />
</Route>
<Route path={RoutesConfig.demoItems} element={<DemoItems />} />
<Route path={RoutesConfig.demoItem} element={<DemoItem routesConfig={RoutesConfig} />} />
<Route path={RoutesConfig.crudDemoItem.index} element={<CrudDemoItem routesConfig={RoutesConfig} />} />
<Route path={RoutesConfig.documents} element={<Documents />} />
<Route path={RoutesConfig.saasIdeas} element={<SaasIdeas />} />
</Route>
<Route path={LANG_PREFIX} element={<AuthRoute />}>
<Route path={RoutesConfig.profile} element={<Profile />} />
<Route path={RoutesConfig.addTenant} element={<AddTenantForm />} />
<Route path={RoutesConfig.tenantInvitation} element={<TenantInvitation />} />
<Route path="*" element={<NotFound />} />
</Route>
<Route path={LANG_PREFIX} element={<AuthRoute allowedRoles={Role.ADMIN} />}>
<Route path={RoutesConfig.admin} element={<Admin />} />
</Route>

<Route path={LANG_PREFIX}>
<Route element={<AuthRoute />}>
<Route path={RoutesConfig.profile} element={<Profile />} />
<Route path={RoutesConfig.addTenant} element={<AddTenantForm />} />
<Route path={RoutesConfig.tenantInvitation} element={<TenantInvitation />} />
<Route path="*" element={<NotFound />} />
</Route>

<Route element={<AuthRoute allowedRoles={Role.ADMIN} />}>
<Route path={RoutesConfig.admin} element={<Admin />} />
</Route>


<Route path={RoutesConfig.confirmEmail} element={<ConfirmEmail />} />
<Route path={RoutesConfig.privacyPolicy} element={<PrivacyPolicy />} />
<Route path={RoutesConfig.termsAndConditions} element={<TermsAndConditions />} />
Expand Down
2 changes: 1 addition & 1 deletion packages/webapp/src/app/config/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { RoutesConfig as GenerativeAIRoutesConfig } from '@sb/webapp-generative-
import { RoutesConfig as TenantsRoutesConfig } from '@sb/webapp-tenants/config/routes';

export const LANG_PREFIX = `/:lang?/*`;
export const TENANT_PREFIX = `/:lang?/:tenantId?/*`;
export const TENANT_PREFIX = `:tenantId?/*`;

export const RoutesConfig = {
...CoreRoutesConfig,
Expand Down

0 comments on commit b591910

Please sign in to comment.