extracts route magic strings to routes constants

This commit is contained in:
Toni Dezman 2017-08-25 08:20:40 +02:00
parent 5733d79943
commit 4ea4c30e29
3 changed files with 33 additions and 8 deletions

View file

@ -1,6 +1,16 @@
export const ROOT_PATH = "/";
// activities
export const ACTIVITIES_PATH = "/client_api/activities";
// settings
export const SETTINGS_PATH = "/settings";
export const SETTINGS_ACCOUNT_PATH = "/settings/account";
export const SETTINGS_TEAMS_PATH = "/settings/teams";
export const SETTINGS_ACCOUNT_PROFILE_PATH = "/settings/account/profile";
export const SETTINGS_ACCOUNT_PREFERENCES_PATH =
"/settings/account/preferences";
// teams
export const TEAMS_PATH = "/client_api/teams";
export const CHANGE_TEAM_PATH = "/client_api/change_team";

View file

@ -5,7 +5,15 @@ import { Nav, NavItem } from "react-bootstrap";
import { FormattedMessage } from "react-intl";
import Navigation from "../../../shared/navigation";
import { SETTINGS_ACCOUNT_PROFILE, SETTINGS_TEAMS } from "../../../app/routes";
import {
ROOT_PATH,
SETTINGS_PATH,
SETTINGS_ACCOUNT_PATH,
SETTINGS_TEAMS_PATH,
SETTINGS_ACCOUNT_PROFILE,
SETTINGS_TEAMS,
SETTINGS_ACCOUNT_PROFILE_PATH
} from "../../../app/routes";
import NotFound from "../../../shared/404/NotFound";
import SettingsAccount from ".././components/account/SettingsAccount";
@ -50,14 +58,14 @@ export default class MainNav extends Component {
</LinkContainer>
</Nav>
<Switch>
<Route exact path="/" component={SettingsAccount} />
<Route exact path={ROOT_PATH} component={SettingsAccount} />
<Route
exact
path="/settings"
render={() => <Redirect to="/settings/account/profile" />}
path={SETTINGS_PATH}
render={() => <Redirect to={SETTINGS_ACCOUNT_PROFILE_PATH} />}
/>
<Route path="/settings/account" component={SettingsAccount} />
<Route path="/settings/teams" component={SettingsTeams} />
<Route path={SETTINGS_ACCOUNT_PATH} component={SettingsAccount} />
<Route path={SETTINGS_TEAMS_PATH} component={SettingsTeams} />
<Route component={NotFound} />
</Switch>
</div>

View file

@ -7,6 +7,10 @@ import SettingsProfile from "./profile/SettingsProfile";
import SettingsPreferences from "./preferences/SettingsPreferences";
import { BORDER_LIGHT_COLOR } from "../../../../app/constants/colors";
import {
SETTINGS_ACCOUNT_PREFERENCES_PATH,
SETTINGS_ACCOUNT_PROFILE_PATH
} from "../../../../app/routes";
const Wrapper = styled.div`
background: white;
@ -25,9 +29,12 @@ class SettingsAccount extends Component {
<SettingsLeftTab />
</div>
<Switch>
<Route path="/settings/account/profile" component={SettingsProfile} />
<Route
path="/settings/account/preferences"
path={SETTINGS_ACCOUNT_PROFILE_PATH}
component={SettingsProfile}
/>
<Route
path={SETTINGS_ACCOUNT_PREFERENCES_PATH}
component={SettingsPreferences}
/>
</Switch>