Skip to content

Commit

Permalink
refactor: rename props and interface to custom Screen
Browse files Browse the repository at this point in the history
  • Loading branch information
rsbh committed Oct 7, 2024
1 parent d6934ca commit 6870abb
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@ export const OrganizationProfile = ({
showTokens = false,
showPreferences = false,
hideToast = false,
customComponents = []
customScreens = []
}: OrganizationProfileProps) => {
const memoryHistory = createMemoryHistory({
initialEntries: [defaultRoute]
});

const customRoutes = getCustomRoutes(customComponents);
const customRoutes = getCustomRoutes(customScreens);

const routeTree = getRootTree({ customComponents: customComponents });
const routeTree = getRootTree({ customScreens: customScreens });

const memoryRouter = createRouter({
routeTree,
Expand Down
18 changes: 9 additions & 9 deletions sdks/js/packages/core/react/components/organization/routes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ import Plans from './plans';
import ConfirmPlanChange from './plans/confirm-change';
import MemberRemoveConfirm from './members/MemberRemoveConfirm';

export interface CustomComponent {
export interface CustomScreen {
name: string;
path: string;
category: 'Organization' | 'User';
Expand All @@ -56,12 +56,12 @@ export interface OrganizationProfileProps {
showTokens?: boolean;
showPreferences?: boolean;
hideToast?: boolean;
customComponents?: CustomComponent[];
customScreens?: CustomScreen[];
}

export interface CustomRoutes {
Organization: Pick<CustomComponent, 'name' | 'path'>[];
User: Pick<CustomComponent, 'name' | 'path'>[];
Organization: Pick<CustomScreen, 'name' | 'path'>[];
User: Pick<CustomScreen, 'name' | 'path'>[];
}

type RouterContext = Pick<
Expand All @@ -73,9 +73,9 @@ type RouterContext = Pick<
| 'showPreferences'
> & { customRoutes: CustomRoutes };

export function getCustomRoutes(customComponents: CustomComponent[] = []) {
export function getCustomRoutes(customScreens: CustomScreen[] = []) {
return (
customComponents?.reduce(
customScreens?.reduce(
(acc: CustomRoutes, { name, category, path }) => {
acc[category].push({ name, path });
return acc;
Expand Down Expand Up @@ -292,10 +292,10 @@ const tokensRoute = createRoute({
});

interface getRootTreeOptions {
customComponents?: CustomComponent[];
customScreens?: CustomScreen[];
}

export function getRootTree({ customComponents = [] }: getRootTreeOptions) {
export function getRootTree({ customScreens = [] }: getRootTreeOptions) {
return rootRoute.addChildren([
indexRoute.addChildren([deleteOrgRoute]),
securityRoute,
Expand All @@ -314,7 +314,7 @@ export function getRootTree({ customComponents = [] }: getRootTreeOptions) {
billingRoute.addChildren([switchBillingCycleModalRoute]),
plansRoute.addChildren([planDowngradeRoute]),
tokensRoute,
...customComponents.map(cc =>
...customScreens.map(cc =>
createRoute({
path: cc.path,
component: cc.component,
Expand Down

0 comments on commit 6870abb

Please sign in to comment.