Skip to content

Commit

Permalink
chore: lint fix story
Browse files Browse the repository at this point in the history
  • Loading branch information
haakonflatval-cognite committed Jul 31, 2023
1 parent d768d79 commit 5762b1a
Showing 1 changed file with 15 additions and 9 deletions.
24 changes: 15 additions & 9 deletions react-components/stories/HighlightNode.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@
import type { Meta, StoryObj } from '@storybook/react';
import {
CadModelContainer,
FdmAssetMappingsConfig,
type FdmAssetMappingsConfig,
RevealContainer,
RevealToolbar,
useReveal
} from '../src';
import { CogniteClient } from '@cognite/sdk';
import { Color, Matrix4 } from 'three';
import { useEffect, useState } from 'react';
import { PointerEventData } from '@cognite/reveal';
import { type ReactElement, useEffect, useState } from 'react';
import { type PointerEventData } from '@cognite/reveal';
import { queryMappedData } from '../src/components/Reveal3DResources/queryMappedData';
import { useFdmSdk, useSDK } from '../src/components/RevealContainer/SDKProvider';

Expand Down Expand Up @@ -62,22 +62,28 @@ export const Main: Story = {
)
};

const Querier = ({ fdmConfig }: { fdmConfig: FdmAssetMappingsConfig }) => {
const Querier = ({ fdmConfig }: { fdmConfig: FdmAssetMappingsConfig }): ReactElement => {
const viewer = useReveal();
const sdk = useSDK();
const fdmClient = useFdmSdk();

const [nodeData, setNodeData] = useState<any>(undefined);

useEffect(() => {
const callback = async (e: PointerEventData) => {
const nodeData = await queryMappedData(viewer, sdk, fdmClient, fdmConfig, e);
setNodeData(nodeData);
const queryAndSetData = (e: PointerEventData): void => {
void (async (e: PointerEventData): Promise<void> => {
const nodeData = await queryMappedData(viewer, sdk, fdmClient, fdmConfig, e);
setNodeData(nodeData);
})(e);
};

viewer.on('click', callback);
viewer.on('click', (e: PointerEventData) => {
queryAndSetData(e);
});

return () => viewer.off('click', callback);
return (): void => {
viewer.off('click', queryAndSetData);
};
});

return <>Clicked node content: {JSON.stringify(nodeData)}</>;
Expand Down

0 comments on commit 5762b1a

Please sign in to comment.