Skip to content

Commit

Permalink
feat: refactor drug page
Browse files Browse the repository at this point in the history
  • Loading branch information
carcruz committed Dec 7, 2024
1 parent c41e0cc commit 2581d2b
Showing 1 changed file with 12 additions and 24 deletions.
36 changes: 12 additions & 24 deletions apps/platform/src/pages/DrugPage/DrugPage.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useQuery } from "@apollo/client";
import { BasePage, ScrollToTop } from "ui";
import { Box, Tabs, Tab } from "@mui/material";
import { useLocation, useParams, Routes, Route, useMatch, Link, Navigate } from "react-router-dom";
import { useLocation, useParams, Routes, Route, Link } from "react-router-dom";

import Header from "./Header";
import NotFoundPage from "../NotFoundPage";
Expand All @@ -12,7 +12,6 @@ import Profile from "./Profile";
function DrugPage() {
const location = useLocation();
const { chemblId } = useParams();
const { path } = useMatch();

const { loading, data } = useQuery(DRUG_PAGE_QUERY, {
variables: { chemblId },
Expand All @@ -32,29 +31,18 @@ function DrugPage() {
>
<Header loading={loading} chemblId={chemblId} name={name} crossReferences={crossReferences} />
<ScrollToTop />

<Route
path="/"
render={history => (
<Box sx={{ borderBottom: 1, borderColor: "divider" }}>
<Tabs value={history.location.pathname !== "/" ? history.location.pathname : false}>
<Tab
label={<Box sx={{ textTransform: "capitalize" }}>Profile</Box>}
value={`/drug/${chemblId}`}
component={Link}
to={`/drug/${chemblId}`}
/>
</Tabs>
</Box>
)}
/>
<Box sx={{ borderBottom: 1, borderColor: "divider" }}>
<Tabs value={location.pathname !== "/" ? location.pathname : false}>
<Tab
label={<Box sx={{ textTransform: "capitalize" }}>Profile</Box>}
value={`/drug/${chemblId}`}
component={Link}
to={`/drug/${chemblId}`}
/>
</Tabs>
</Box>
<Routes>
<Route exact path={path}>
<Profile chemblId={chemblId} name={name} />
</Route>
<Route path="*">
<Navigate to={`/drug/${chemblId}`} />
</Route>
<Route path="/" element={<Profile chemblId={chemblId} name={name} />} />
</Routes>
</BasePage>
);
Expand Down

0 comments on commit 2581d2b

Please sign in to comment.