-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f5d63f6
commit 3d9b8db
Showing
8 changed files
with
373 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
'use server'; | ||
|
||
import Box from '@mui/joy/Box'; | ||
import { GridColDef } from '@mui/x-data-grid/models/colDef'; | ||
import Alert from '@mui/joy/Alert'; | ||
import Typography from '@mui/joy/Typography'; | ||
import WarningIcon from '@mui/icons-material/Warning'; | ||
import 'server-only'; | ||
|
||
import { | ||
DataGrid, | ||
renderChip, | ||
renderCompoundCountChip, | ||
renderSparkline, | ||
} from '@/components/data/grid'; | ||
import { EntitySearchArgs } from '@/types/entities'; | ||
|
||
import { fetchEntities } from './actions'; | ||
|
||
const getCompoundColumns = (): GridColDef[] => [ | ||
{ | ||
field: 'name', | ||
headerName: 'Entity', | ||
width: 250, | ||
}, | ||
{ | ||
field: 'trial_count', | ||
headerName: 'Trials', | ||
width: 125, | ||
renderCell: renderCompoundCountChip, | ||
}, | ||
{ | ||
field: 'patent_count', | ||
headerName: 'Patents', | ||
width: 125, | ||
renderCell: renderCompoundCountChip, | ||
}, | ||
{ | ||
field: 'activity', | ||
headerName: 'Activity', | ||
width: 125, | ||
renderCell: renderSparkline, | ||
}, | ||
{ | ||
field: 'last_priority_year', | ||
headerName: 'Latest Priority Date', | ||
width: 125, | ||
}, | ||
{ | ||
field: 'max_phase', | ||
headerName: 'Max Phase', | ||
width: 125, | ||
renderCell: renderChip, | ||
}, | ||
{ | ||
field: 'last_status', | ||
headerName: 'Last Status', | ||
width: 125, | ||
renderCell: renderChip, | ||
}, | ||
{ | ||
field: 'last_updated', | ||
headerName: 'Last Update', | ||
width: 125, | ||
}, | ||
]; | ||
|
||
export const CompoundList = async (args: EntitySearchArgs) => { | ||
const columns = getCompoundColumns(); | ||
try { | ||
const entities = await fetchEntities(args); | ||
return ( | ||
<Box height="100vh"> | ||
<DataGrid | ||
columns={columns} | ||
// detailComponent={PatentDetail<Entity>} | ||
rows={entities.map((entity) => ({ | ||
...entity, | ||
id: entity.name, | ||
}))} | ||
/> | ||
</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> | ||
); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/* eslint-disable @typescript-eslint/naming-convention */ | ||
import { z } from 'zod'; | ||
|
||
import { PatentSchema } from './patents'; | ||
import { TrialSchema } from './trials'; | ||
|
||
export const EntitySchema = z.object({ | ||
activity: z.array(z.number()), | ||
last_status: z.union([z.string(), z.null()]), | ||
last_updated: z.union([z.string(), z.null()]), | ||
name: z.string(), | ||
max_phase: z.union([z.string(), z.null()]), | ||
last_priority_year: z.union([z.number(), z.null()]), | ||
patents: z.array(PatentSchema), | ||
patent_count: z.number(), | ||
record_count: z.number(), | ||
trials: z.array(TrialSchema), | ||
trial_count: z.number(), | ||
}); | ||
|
||
export const EntityResponseSchema = z.array(EntitySchema); | ||
|
||
export type Entity = z.infer<typeof EntitySchema>; | ||
export type EntityResponse = z.infer<typeof EntityResponseSchema>; | ||
|
||
export type EntitySearchArgs = { | ||
queryType: string | null; | ||
terms: string[] | null; | ||
}; |
Oops, something went wrong.