Skip to content

Commit

Permalink
fix: study shared trait
Browse files Browse the repository at this point in the history
  • Loading branch information
carcruz committed Dec 9, 2024
1 parent f3fd310 commit 84ef3ea
Showing 1 changed file with 18 additions and 25 deletions.
43 changes: 18 additions & 25 deletions packages/sections/src/study/SharedTraitStudies/Body.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,6 @@
import { Fragment } from "react";
import { Fragment, ReactElement } from "react";
import { Box, Typography } from "@mui/material";
import {
Link,
SectionItem,
Tooltip,
PublicationsDrawer,
OtTable,
useBatchQuery,
} from "ui";
import { Link, SectionItem, Tooltip, PublicationsDrawer, OtTable, useBatchQuery } from "ui";
import { definition } from ".";
import Description from "./Description";
import { naLabel, initialResponse, table5HChunkSize } from "../../constants";
Expand Down Expand Up @@ -56,7 +49,7 @@ function getColumns(diseaseIds: string[]) {
label: "Sample size",
numeric: true,
renderCell: ({ nSamples }) => {
return typeof nSamples === "number" ? nSamples.toLocaleString() : naLabel
return typeof nSamples === "number" ? nSamples.toLocaleString() : naLabel;
},
comparator: (a, b) => a?.nSamples - b?.nSamples,
sortable: true,
Expand Down Expand Up @@ -97,47 +90,47 @@ function getColumns(diseaseIds: string[]) {
getStudyCategory(projectId) === "FINNGEN"
? "FinnGen"
: cohorts?.length
? cohorts.join(", ")
: null,
? cohorts.join(", ")
: null,
},
{
id: "publication",
label: "Publication",
renderCell: ({ publicationFirstAuthor, publicationDate, pubmedId }) => {
if (!publicationFirstAuthor) return naLabel;
return <PublicationsDrawer
entries={[{ name: pubmedId, url: epmcUrl(pubmedId) }]}
customLabel={`${publicationFirstAuthor} et al. (${new Date(publicationDate).getFullYear()})`}
/>
return (
<PublicationsDrawer
entries={[{ name: pubmedId, url: epmcUrl(pubmedId) }]}
customLabel={`${publicationFirstAuthor} et al. (${new Date(
publicationDate
).getFullYear()})`}
/>
);
},
filterValue: ({ publicationYear, publicationFirstAuthor }) =>
`${publicationYear} ${publicationFirstAuthor}`,
exportValue: ({ pubmedId }) =>
`${pubmedId}`,
exportValue: ({ pubmedId }) => `${pubmedId}`,
},
];
}

type BodyProps = {
studyId: string;
diseaseIds: string[];
entity: string;
};

export function Body({ studyId, diseaseIds, entity }: BodyProps) {
export function Body({ studyId, diseaseIds }: BodyProps): ReactElement {
const variables = {
diseaseIds: diseaseIds,
size: table5HChunkSize,
index: 0,
};

const [request, setRequest] = useState<responseType>(initialResponse);

const getData = useBatchQuery({
query: SHARED_TRAIT_STUDIES_QUERY,
variables: {
diseaseIds,
size: table5HChunkSize,
index: 0,
},
variables,
dataPath: "data.studies",
size: table5HChunkSize,
});
Expand Down

0 comments on commit 84ef3ea

Please sign in to comment.