Skip to content

Commit

Permalink
refactor(#1137): separate deleteLineFromPath function from the logic …
Browse files Browse the repository at this point in the history
…of the settings-routes
  • Loading branch information
d1mon1k committed Sep 10, 2022
1 parent 72f4869 commit e258d2c
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 9 deletions.
6 changes: 3 additions & 3 deletions src/routing/routes/main-routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ const MainRoutes: MainRoutesObject = {
props: {
element: withPageGuard([REGISTERED_USER])(ChatPage),
children: [
React.createElement(Route, { key: 1, index: true, element: React.createElement(Welcome) }),
React.createElement(Route, { key: 2, path: ':id', element: React.createElement(MessageList) }),
React.createElement(Route, { key: 3, path: '*', element: React.createElement(Welcome) }),
React.createElement(Route, { key: '1', index: true, element: React.createElement(Welcome) }),
React.createElement(Route, { key: '2', path: ':id', element: React.createElement(MessageList) }),
React.createElement(Route, { key: '3', path: '*', element: React.createElement(Welcome) }),
],
},
},
Expand Down
9 changes: 3 additions & 6 deletions src/routing/routes/settings-routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ import {
import { SettingsRoutesEnum, SettingsRoutesObject } from '@routing/routing.types';
import withPageGuard from '@routing/with-page-guard';

import { deleteLineFromPath } from './utils';

/* ------------- LazyLoading ------------- */
const ProfileSettings = LazyPreload(() => import('@pages/settings/edit-profile'));
const NotificationsSettings = LazyPreload(() => import('@pages/settings/notifications-settings'));
const LanguageSettings = LazyPreload(() => import('@pages/settings/language-settings'));
Expand All @@ -25,12 +28,6 @@ const AppearanceSettings = LazyPreload(() => import('@pages/settings/appearance'
const PrivacySecuritySettings = LazyPreload(() => import('@pages/settings/privacy-security'));
const AudioVideoSettings = LazyPreload(() => import('@pages/settings/audio-video'));

const deleteLineFromPath = (path: string, line: string) => {
const preparedPath = path.split('');
preparedPath.splice(path.indexOf(line), line.length);
return preparedPath.join('');
};

/* ------------- Routes ------------- */
const SettingsRoutes: SettingsRoutesObject = {
[SettingsRoutesEnum.PROFILE_SETTINGS]: {
Expand Down
5 changes: 5 additions & 0 deletions src/routing/routes/utils.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export const deleteLineFromPath = (path: string, line: string) => {
const preparedPath = path.split('');
preparedPath.splice(path.indexOf(line), line.length);
return preparedPath.join('');
};

0 comments on commit e258d2c

Please sign in to comment.