Skip to content

Commit

Permalink
No commit message
Browse files Browse the repository at this point in the history
  • Loading branch information
bchu1 committed Jan 24, 2025
1 parent 76c4b05 commit ac678ff
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions frontend/packages/data-portal/app/hooks/useDepositionById.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,28 @@ import { useMemo } from 'react'
import { useTypedLoaderData } from 'remix-typedjson'

import { GetDepositionByIdQuery } from 'app/__generated__/graphql'
import { GetDepositionByIdV2Query } from 'app/__generated_v2__/graphql'
import { isDefined } from 'app/utils/nullish'

export type Deposition = NonNullable<GetDepositionByIdQuery['deposition']>

export type Dataset = GetDepositionByIdQuery['datasets'][number]

export function useDepositionById() {
const { v1, annotationMethodCounts } = useTypedLoaderData<{
const { v1, v2 } = useTypedLoaderData<{
v1: GetDepositionByIdQuery
annotationMethodCounts: Map<string, number>
v2: GetDepositionByIdV2Query
}>()

const annotationMethodCounts = new Map<string, number>(
v2.depositions[0].annotationMethodCounts?.aggregate
?.map((aggregate) => [
aggregate.groupBy?.annotationMethod,
aggregate.count ?? 0,
])
.filter((entry): entry is [string, number] => isDefined(entry[0])) ?? [],
)

const objectNames = useMemo(
() =>
Array.from(
Expand Down

0 comments on commit ac678ff

Please sign in to comment.