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

feat: simplify routing component #579

Merged
merged 1 commit into from
May 30, 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
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
Loading