Skip to content

Commit

Permalink
refactor(route types): refactor route types
Browse files Browse the repository at this point in the history
  • Loading branch information
heorhi-deriv committed Sep 5, 2022
1 parent ecad9b0 commit f41a350
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 23 deletions.
21 changes: 2 additions & 19 deletions packages/cashier/src/constants/routes-config.ts
Original file line number Diff line number Diff line change
@@ -1,30 +1,13 @@
import React from 'react';
import { routes, moduleLoader } from '@deriv/shared';
import { Redirect } from 'react-router-dom';
import { localize } from '@deriv/translations';
import { Cashier } from '../containers';
import { AccountTransfer, Deposit, OnRamp, P2PCashier, PaymentAgent, PaymentAgentTransfer, Withdrawal } from '../pages';

export type TRoute = {
default?: boolean;
exact?: boolean;
id?: string;
icon_component?: string;
is_invisible?: boolean;
path?: string;
to?: string;
component: ((cashier_routes?: TRoute[]) => JSX.Element) | typeof Page404 | typeof Redirect;
getTitle: () => string;
};

export type TRouteConfig = TRoute & {
is_modal?: boolean;
is_authenticated?: boolean;
routes?: TRoute[];
};
import { TRouteConfig, TRoute } from 'Types';

// Error Routes
const Page404 = React.lazy(() => moduleLoader(() => import(/* webpackChunkName: "404" */ 'Components/page-404')));
export type TPage404 = typeof Page404;

// Order matters
const initRoutesConfig = (): TRouteConfig[] => [
Expand Down
3 changes: 1 addition & 2 deletions packages/cashier/src/containers/cashier/cashier.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,8 @@ import { getSelectedRoute, getStaticUrl, isMobile, routes, WS } from '@deriv/sha
import { localize } from '@deriv/translations';
import AccountPromptDialog from 'Components/account-prompt-dialog';
import ErrorDialog from 'Components/error-dialog';
import { TRoute } from 'Constants/routes-config';
import { connect } from 'Stores/connect';
import { TClientStore, TCommonStore, TError, TRootStore, TUiStore } from 'Types';
import { TClientStore, TCommonStore, TError, TRootStore, TRoute, TUiStore } from 'Types';
import './cashier.scss';

type TCashierProps = RouteComponentProps & {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ import {
default_title,
} from '@deriv/shared';
import { getLanguage } from '@deriv/translations';
import { TRouteConfig, TRoute } from 'Constants/routes-config';
import { TClientStore } from 'Types';
import { TClientStore, TRouteConfig, TRoute } from 'Types';

type TRouteWithSubRoutesProps = TRouteConfig & {
is_logged_in: TClientStore['is_logged_in'];
Expand Down
1 change: 1 addition & 0 deletions packages/cashier/src/types/shared/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export * from './crypto-transaction-details.types';
export * from './error.types';
export * from './props.types';
export * from './routes.types';
export * from './websocket.types';
20 changes: 20 additions & 0 deletions packages/cashier/src/types/shared/routes.types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { Redirect } from 'react-router-dom';
import { TPage404 } from 'Constants/routes-config';

export type TRoute = {
default?: boolean;
exact?: boolean;
id?: string;
icon_component?: string;
is_invisible?: boolean;
path?: string;
to?: string;
component: ((cashier_routes?: TRoute[]) => JSX.Element) | TPage404 | typeof Redirect;
getTitle: () => string;
};

export type TRouteConfig = TRoute & {
is_modal?: boolean;
is_authenticated?: boolean;
routes?: TRoute[];
};

0 comments on commit f41a350

Please sign in to comment.