Skip to content

Commit

Permalink
Merge pull request #31 from biosymbolics/refine_entity_display
Browse files Browse the repository at this point in the history
Asset-oriented display
  • Loading branch information
kristinlindquist authored Dec 21, 2023
2 parents 3d9b8db + d4804eb commit 7829e85
Show file tree
Hide file tree
Showing 36 changed files with 964 additions and 872 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ export const fetchDescription = cache(
* @param args
* @returns patents promise
*/
export const fetchEntities = cache(
export const fetchAssets = cache(
async (args: EntitySearchArgs): Promise<EntityResponse> => {
if (args.terms?.length === 0) {
return [];
Expand Down
32 changes: 32 additions & 0 deletions src/app/core/asset/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
'use server';

import Typography from '@mui/joy/Typography';

import { fetchAutocompletions } from '@/app/core/actions';
import { SearchBar } from '@/components/composite';
import { Section } from '@/components/layout/section';

const Page = ({ searchParams }: { searchParams: Record<string, string> }) => {
const { asset } = searchParams;

return (
<>
<Section variant="separated">
<SearchBar
exemplarPatents={null}
fetchAutocompletions={fetchAutocompletions}
minPatentYears={null}
queryType={null}
terms={null}
/>
</Section>
<Section variant="main">
<Section>
<Typography level="h1">{asset}</Typography>
</Section>
</Section>
</>
);
};

export default Page;
47 changes: 47 additions & 0 deletions src/app/core/dashboard/asset.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
'use server';

import Box from '@mui/joy/Box';
import Alert from '@mui/joy/Alert';
import Typography from '@mui/joy/Typography';
import WarningIcon from '@mui/icons-material/Warning';
import 'server-only';

import { getAssetColumns } from '@/components/composite/assets/config';
import { DataGrid } from '@/components/data/grid';
import { EntitySearchArgs } from '@/types/entities';

import { fetchAssets } from '../actions';

export const AssetList = async (args: EntitySearchArgs) => {
const columns = getAssetColumns();
try {
const assets = await fetchAssets(args);
return (
<Box height="100vh">
<DataGrid
checkboxSelection
disableRowSelectionOnClick
columns={columns}
rows={assets.map((asset) => ({
...asset,
id: asset.name,
}))}
variant="maximal"
/>
</Box>
);
} catch (e) {
return (
<Alert
startDecorator={<WarningIcon />}
variant="soft"
color="warning"
>
<Typography level="h4">Failed to fetch patents</Typography>
<Typography>
{e instanceof Error ? e.message : JSON.stringify(e)}
</Typography>
</Alert>
);
}
};
Original file line number Diff line number Diff line change
Expand Up @@ -7,41 +7,23 @@ import Skeleton from '@mui/joy/Skeleton';
import Typography from '@mui/joy/Typography';
import WarningIcon from '@mui/icons-material/Warning';

import { getStyles } from '@/components/composite/styles';
import { Tabs } from '@/components/layout/tabs';
import { PatentSearchArgs } from '@/types/patents';

import { getStyles } from './client';
import { CompoundList } from './compound';
import { PatentList } from './patent';
import { PatentGraph } from './graph';
import { AssetList } from './asset';
// import { PatentGraph } from './graph';
import { OverTime } from './over-time';
import { Summary } from './summary';
import { TrialList } from './trials';

export const Content = (args: PatentSearchArgs) => {
try {
const tabs = [
{
label: 'Compounds',
label: 'Assets',
panel: (
<Suspense fallback={<Skeleton />}>
<CompoundList {...args} />
</Suspense>
),
},
{
label: 'Patents',
panel: (
<Suspense fallback={<Skeleton />}>
<PatentList {...args} />
</Suspense>
),
},
{
label: 'Trials',
panel: (
<Suspense fallback={<Skeleton />}>
<TrialList {...args} />
<AssetList {...args} />
</Suspense>
),
},
Expand All @@ -61,14 +43,14 @@ export const Content = (args: PatentSearchArgs) => {
</Suspense>
),
},
{
label: 'Graph',
panel: (
<Suspense fallback={<Skeleton />}>
<PatentGraph {...args} />
</Suspense>
),
},
// {
// label: 'Graph',
// panel: (
// <Suspense fallback={<Skeleton />}>
// <PatentGraph {...args} />
// </Suspense>
// ),
// },
];
return (
<Box sx={getStyles}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import Box from '@mui/joy/Box';
import ReactMarkdown from 'react-markdown';
import 'server-only';

import { fetchDescription } from './actions';
import { fetchDescription } from '../actions';

export const Description = async ({ terms }: { terms: string[] }) => {
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const fetchGraph = cache(
);

export const PatentGraph = async ({
pathname = '/core/patents',
pathname = '/core/dashboard',
terms,
...args
}: PatentSearchArgs & { pathname?: string }) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { doFetch } from '@/utils/actions';
import { getQueryArgs } from '@/utils/patents';
import { formatLabel } from '@/utils/string';

import { getStyles } from './client';
import { getStyles } from '../../../components/composite/styles';

const fetchReports = cache(
async (args: PatentSearchArgs): Promise<PatentsSummaries> => {
Expand All @@ -35,7 +35,7 @@ const fetchReports = cache(
);

export const OverTime = async ({
pathname = '/core/patents',
pathname = '/core/dashboard',
...args
}: PatentSearchArgs & { pathname?: string }) => {
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@ import { Suspense } from 'react';
import Skeleton from '@mui/joy/Skeleton';
import Typography from '@mui/joy/Typography';

import { SearchBar } from '@/components/composite';
import { Section } from '@/components/layout/section';
import { formatLabel } from '@/utils/string';

import { fetchAutocompletions } from './actions';
import { Description } from './description';
import { Content } from './content';
import { SearchBar } from './search';

import { fetchAutocompletions } from '../actions';

const Page = ({ searchParams }: { searchParams: Record<string, string> }) => {
const terms = searchParams.terms?.split(';') ?? null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
import { doFetch } from '@/utils/actions';
import { getQueryArgs } from '@/utils/patents';

import { getStyles } from './client';
import { getStyles } from '../../../components/composite/styles';

const fetchSummaries = cache(
async (args: PatentSearchArgs): Promise<PatentsSummaries> => {
Expand Down Expand Up @@ -44,7 +44,7 @@ const fetchSummaries = cache(
// );

export const Summary = async ({
pathname = '/core/patents',
pathname = '/core/dashboard',
terms,
...args
}: PatentSearchArgs & { pathname?: string }) => {
Expand Down
Loading

0 comments on commit 7829e85

Please sign in to comment.