Skip to content

Commit

Permalink
[change] estela-web: Show the register page based on the REGISTER_PAG…
Browse files Browse the repository at this point in the history
…E_ENABLED value (bitmakerla#232)
  • Loading branch information
mgonnav authored Sep 8, 2023
1 parent 97f8aba commit 6b3e6d5
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 11 deletions.
3 changes: 2 additions & 1 deletion estela-web/.env.development.example
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
REACT_APP_API_BASE_URL=http://localhost:8000
REACT_APP_API_BASE_URL=http://localhost:8000
REGISTER_PAGE_ENABLED=true
1 change: 1 addition & 0 deletions estela-web/src/constants.ts
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
export const API_BASE_URL = process.env.REACT_APP_API_BASE_URL;
export const REGISTER_PAGE_ENABLED = process.env.REGISTER_PAGE_ENABLED === "true";
19 changes: 11 additions & 8 deletions estela-web/src/pages/LoginPage/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { ApiAuthLoginRequest, Token } from "../../services/api";
import { handleInvalidDataError } from "../../utils";
import { UserContext, UserContextProps } from "../../context";
import { EstelaBanner } from "../../components";
import { REGISTER_PAGE_ENABLED } from "../../constants";

const { Content } = Layout;
const { Text } = Typography;
Expand Down Expand Up @@ -105,14 +106,16 @@ export class LoginPage extends Component<unknown, LoginState> {
>
Log in
</Button>
<Content className="text-center text-base m-5">
<p>If you don&apos;t have an account. You can</p>
<p>
<Link className="text-estela text-base font-bold underline" to="/register">
register here
</Link>
</p>
</Content>
{REGISTER_PAGE_ENABLED && (
<Content className="text-center text-base m-5">
<p>If you don&apos;t have an account. You can</p>
<p>
<Link className="text-estela text-base font-bold underline" to="/register">
register here
</Link>
</p>
</Content>
)}
</Form>
</Content>
</Content>
Expand Down
15 changes: 13 additions & 2 deletions estela-web/src/routes/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import React from "react";
import { Switch, Route, Redirect } from "react-router-dom";

import { REGISTER_PAGE_ENABLED } from "../constants";

import { ActivatedAccountPage } from "../pages/ActivatedAccountPage";
import { LoginPage } from "../pages/LoginPage";
import { RegisterPage } from "../pages/RegisterPage";
Expand Down Expand Up @@ -34,10 +36,19 @@ export const MainRoutes: React.FC = () => {
<Redirect to="/login" />
</Route>

<Route path={["/login", "/register", "/forgotPassword", "/resetPassword", "/activatedAccount"]} exact>
<Route
path={[
"/login",
REGISTER_PAGE_ENABLED ? "/register" : null,
"/forgotPassword",
"/resetPassword",
"/activatedAccount",
].filter(Boolean)}
exact
>
<AuthLayout>
<Route path="/login" component={LoginPage} exact />
<Route path="/register" component={RegisterPage} exact />
{REGISTER_PAGE_ENABLED && <Route path="/register" component={RegisterPage} exact />}
<Route path="/forgotPassword" component={ForgotPasswordPage} exact />
<Route path="/resetPassword" component={ResetPasswordPage} exact />
<Route path="/activatedAccount" component={ActivatedAccountPage} exact />
Expand Down

0 comments on commit 6b3e6d5

Please sign in to comment.