Skip to content

Commit

Permalink
[Platform]: Homepage crash sharing parameter by value (#298)
Browse files Browse the repository at this point in the history
  • Loading branch information
chinmehta authored Nov 23, 2023
1 parent 36f27db commit 2755c1c
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 32 deletions.
43 changes: 22 additions & 21 deletions apps/platform/src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,37 +1,38 @@
import { BrowserRouter as Router, Route, Switch } from 'react-router-dom';
import { ApolloProvider } from '@apollo/client';
import { ThemeProvider, SearchProvider, PrivateRoute } from 'ui';
import { BrowserRouter as Router, Route, Switch } from "react-router-dom";
import { ApolloProvider } from "@apollo/client";
import { ThemeProvider, SearchProvider, PrivateRoute } from "ui";

import SEARCH_QUERY from './components/Search/SearchQuery.gql';
import ShouldAccessPPP from './components/ShouldAccessPPP';
import client from './client';
import theme from './theme';
import HomePage from './pages/HomePage';
import SearchPage from './pages/SearchPage';
import DiseasePage from './pages/DiseasePage';
import DownloadsPage from './pages/DownloadsPage';
import DrugPage from './pages/DrugPage';
import TargetPage from './pages/TargetPage';
import EvidencePage from './pages/EvidencePage';
import VariantsPage from './pages/VariantsPage';
import APIPage from './pages/APIPage';
import NotFoundPage from './pages/NotFoundPage';
import ProjectsPage from './pages/ProjectsPage';
import { getSuggestedSearch } from './utils/global';
import SEARCH_QUERY from "./components/Search/SearchQuery.gql";
import ShouldAccessPPP from "./components/ShouldAccessPPP";
import client from "./client";
import theme from "./theme";
import HomePage from "./pages/HomePage";
import SearchPage from "./pages/SearchPage";
import DiseasePage from "./pages/DiseasePage";
import DownloadsPage from "./pages/DownloadsPage";
import DrugPage from "./pages/DrugPage";
import TargetPage from "./pages/TargetPage";
import EvidencePage from "./pages/EvidencePage";
import VariantsPage from "./pages/VariantsPage";
import APIPage from "./pages/APIPage";
import NotFoundPage from "./pages/NotFoundPage";
import ProjectsPage from "./pages/ProjectsPage";
import { getSuggestedSearch } from "./utils/global";

function App() {
const suggestions = getSuggestedSearch();
return (
<ApolloProvider client={client}>
<ThemeProvider theme={theme}>
<SearchProvider
searchSuggestions={getSuggestedSearch()}
searchSuggestions={suggestions}
searchQuery={SEARCH_QUERY}
searchPlaceholder="Search for a target, drug, disease, or phenotype..."
>
<Router>
<Switch>
<Route exact path="/">
<HomePage />
<HomePage suggestions={suggestions} />
</Route>
<Route path="/search">
<SearchPage />
Expand Down
3 changes: 1 addition & 2 deletions apps/platform/src/pages/HomePage/HomePage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,8 @@ function HelpBoxPanel({ fai, url, label, external }) {
);
}

function HomePage() {
function HomePage({ suggestions }) {
const classes = useStyles();
const suggestions = getSuggestedSearch();

const handleScrollDown = () => {
window.scrollTo({ top: window.innerHeight, left: 0, behavior: "smooth" });
Expand Down
3 changes: 1 addition & 2 deletions apps/platform/src/pages/HomePage/PPHomePage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,8 @@ function HelpBoxPanel({ fai, url, label, external }) {
);
}

function HomePage() {
function HomePage({ suggestions }) {
const classes = useStyles();
const suggestions = getSuggestedSearch();

const handleScrollDown = () => {
window.scrollTo({ top: window.innerHeight, left: 0, behavior: "smooth" });
Expand Down
12 changes: 6 additions & 6 deletions apps/platform/src/pages/HomePage/index.jsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import PublicHome from './HomePage';
import PPHome from './PPHomePage';
import { usePermissions } from 'ui';
import PublicHome from "./HomePage";
import PPHome from "./PPHomePage";
import { usePermissions } from "ui";

function GetHomePage() {
function GetHomePage({ suggestions }) {
const { isPartnerPreview } = usePermissions();
if (isPartnerPreview) return <PPHome />;
return <PublicHome />;
if (isPartnerPreview) return <PPHome suggestions={suggestions} />;
return <PublicHome suggestions={suggestions} />;
}

export default GetHomePage;
2 changes: 1 addition & 1 deletion apps/platform/src/utils/global.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { format } from "d3-format";
import config from "../config";
import { searchExamples, pppSearchExamples } from "../pages/HomePage/searchExamples";

function pickTwo(arr) {
function pickTwo([...arr]) {
const i1 = Math.floor(Math.random() * arr.length);
const resultArray = arr.splice(i1, 1);
const i2 = Math.floor(Math.random() * arr.length);
Expand Down

0 comments on commit 2755c1c

Please sign in to comment.