-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge master into pramodcog/bump-react-recomponent-v0.6.1
- Loading branch information
Showing
13 changed files
with
400 additions
and
101 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
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
37 changes: 37 additions & 0 deletions
37
react-components/src/hooks/useMappedEquipmentBy3DModelsList.tsx
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,37 @@ | ||
/*! | ||
* Copyright 2023 Cognite AS | ||
*/ | ||
import { type UseQueryResult, useQuery } from '@tanstack/react-query'; | ||
import { type FdmAssetMappingsConfig } from '..'; | ||
import { useFdmSdk } from '../components/RevealContainer/SDKProvider'; | ||
|
||
export const useMappedEquipmentBy3DModelsList = ( | ||
Default3DFdmConfig: FdmAssetMappingsConfig, | ||
modelsList: Array<{ modelId: number; revisionId: number }> = [] | ||
): UseQueryResult<string[]> => { | ||
const fdmClient = useFdmSdk(); | ||
|
||
return useQuery( | ||
['reveal', 'react-components', ...modelsList.map(({ modelId }) => modelId.toString()).sort()], | ||
async () => { | ||
const filter = { | ||
in: { | ||
property: ['edge', 'endNode'], | ||
values: modelsList.map(({ modelId }) => ({ | ||
space: Default3DFdmConfig.global3dSpace, | ||
externalId: `model_3d_${modelId}` | ||
})) | ||
} | ||
}; | ||
|
||
const mappings = await fdmClient.filterAllInstances( | ||
filter, | ||
'edge', | ||
Default3DFdmConfig.source | ||
); | ||
|
||
return mappings.edges.map((edge) => edge.startNode.externalId); | ||
}, | ||
{ staleTime: Infinity } | ||
); | ||
}; |
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
Oops, something went wrong.