Skip to content

Commit

Permalink
feat: applay message only for search page
Browse files Browse the repository at this point in the history
  • Loading branch information
ImenOuidou committed Oct 25, 2023
1 parent baccf3e commit 9b9c003
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 4 deletions.
8 changes: 7 additions & 1 deletion src/client/src/components/App/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,17 @@ const App = () => {
<Maintenance />
) : (
<Switch>
<PrivateRoute exact path="/" component={Search} />
<PrivateRoute
exact
displayMessage
path="/"
component={Search}
/>
<PrivateRoute
exact
path="/search"
component={Search}
displayMessage
/>
<PrivateRoute
exact
Expand Down
4 changes: 3 additions & 1 deletion src/client/src/components/App/Layout.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ const Layout = ({
hasLandingHeader = false,
hasSharedButton = false,
children,
displayMessage = false,
}) => {
const isActiveMaintenanceMode = Config.get("maintenanceMode");

Expand All @@ -20,7 +21,7 @@ const Layout = ({
{hasLandingHeader ? (
<LandingHeader hasSharedButton={hasSharedButton} />
) : (
<Header showBetaMessage={!isActiveMaintenanceMode} />
<Header showBetaMessage={!isActiveMaintenanceMode && displayMessage} />
)}
<div className={classNames("app-container", { ie11: isIE })}>
{children}
Expand All @@ -32,6 +33,7 @@ const Layout = ({

Layout.propTypes = {
children: PropTypes.node,
displayMessage: PropTypes.bool,
hasLandingHeader: PropTypes.bool,
hasSharedButton: PropTypes.bool,
};
Expand Down
10 changes: 8 additions & 2 deletions src/client/src/services/PrivateRoute/PrivateRoute.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,12 @@ import { Redirect, Route, useHistory } from "react-router-dom";
import Layout from "../../components/App/Layout";
import Auth from "../Auth";

const PrivateRoute = ({ component: Component, location, ...rest }) => {
const PrivateRoute = ({
component: Component,
displayMessage,
location,
...rest
}) => {
const history = useHistory();

async function getTempAuthAndRedirect(credential, location) {
Expand Down Expand Up @@ -46,7 +51,7 @@ const PrivateRoute = ({ component: Component, location, ...rest }) => {
{...rest}
render={(props) => {
return authorization.auth ? (
<Layout>
<Layout displayMessage={displayMessage}>
<Component {...props} />
</Layout>
) : (
Expand All @@ -64,6 +69,7 @@ const PrivateRoute = ({ component: Component, location, ...rest }) => {

PrivateRoute.propTypes = {
component: PropTypes.elementType,
displayMessage: PropTypes.bool,
history: PropTypes.shape({
push: PropTypes.func,
}),
Expand Down

0 comments on commit 9b9c003

Please sign in to comment.