From 967182392dea2dfcf2c93d4b1384bbd00473d9f0 Mon Sep 17 00:00:00 2001 From: Bryan Chu Date: Wed, 22 Jan 2025 16:48:15 -0800 Subject: [PATCH] --- .../app/hooks/useDatasetsFilterData.ts | 49 +++++++++++-------- 1 file changed, 29 insertions(+), 20 deletions(-) diff --git a/frontend/packages/data-portal/app/hooks/useDatasetsFilterData.ts b/frontend/packages/data-portal/app/hooks/useDatasetsFilterData.ts index c76bcaa02..250d07665 100644 --- a/frontend/packages/data-portal/app/hooks/useDatasetsFilterData.ts +++ b/frontend/packages/data-portal/app/hooks/useDatasetsFilterData.ts @@ -1,31 +1,40 @@ import { useTypedLoaderData } from 'remix-typedjson' -import { GetDatasetsV2Query } from 'app/__generated_v2__/graphql' +import { + GetDatasetsV2Query, + GetDepositionByIdV2Query, +} from 'app/__generated_v2__/graphql' import { isDefined } from 'app/utils/nullish' export function useDatasetsFilterData() { const { v2 } = useTypedLoaderData<{ - v2: GetDatasetsV2Query + v2: GetDatasetsV2Query | GetDepositionByIdV2Query // TODO: Move this data into props. }>() return { - organismNames: v2.distinctOrganismNames.aggregate - ?.map((aggregate) => aggregate.groupBy?.organismName) - .filter(isDefined), - cameraManufacturers: v2.distinctCameraManufacturers.aggregate - ?.map((aggregate) => aggregate.groupBy?.cameraManufacturer) - .filter(isDefined), - reconstructionMethods: v2.distinctReconstructionMethods.aggregate - ?.map((aggregate) => aggregate.groupBy?.reconstructionMethod) - .filter(isDefined), - reconstructionSoftwares: v2.distinctReconstructionSoftwares.aggregate - ?.map((aggregate) => aggregate.groupBy?.reconstructionSoftware) - .filter(isDefined), - objectNames: v2.distinctObjectNames.aggregate - ?.map((aggregate) => aggregate.groupBy?.objectName) - .filter(isDefined), - objectShapeTypes: v2.distinctShapeTypes.aggregate - ?.map((aggregate) => aggregate.groupBy?.shapeType) - .filter(isDefined), + organismNames: + v2.distinctOrganismNames.aggregate + ?.map((aggregate) => aggregate.groupBy?.organismName) + .filter(isDefined) ?? [], + cameraManufacturers: + v2.distinctCameraManufacturers.aggregate + ?.map((aggregate) => aggregate.groupBy?.cameraManufacturer) + .filter(isDefined) ?? [], + reconstructionMethods: + v2.distinctReconstructionMethods.aggregate + ?.map((aggregate) => aggregate.groupBy?.reconstructionMethod) + .filter(isDefined) ?? [], + reconstructionSoftwares: + v2.distinctReconstructionSoftwares.aggregate + ?.map((aggregate) => aggregate.groupBy?.reconstructionSoftware) + .filter(isDefined) ?? [], + objectNames: + v2.distinctObjectNames.aggregate + ?.map((aggregate) => aggregate.groupBy?.objectName) + .filter(isDefined) ?? [], + objectShapeTypes: + v2.distinctShapeTypes.aggregate + ?.map((aggregate) => aggregate.groupBy?.shapeType) + .filter(isDefined) ?? [], } }