Skip to content

Commit

Permalink
fix: add feature flag mock data test to open node view
Browse files Browse the repository at this point in the history
  • Loading branch information
Aerilym authored Jul 4, 2024
1 parent 1e8e991 commit 3a49222
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion apps/staking/app/stake/node/[nodeId]/NodeStaking.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,26 @@ import { useMemo, useState } from 'react';
import { ActionModuleDivider, ActionModuleRow } from '../../ActionModule';

export default function NodeStaking({ nodeId }: { nodeId: string }) {
const showMockNodes = useFeatureFlag(FEATURE_FLAG.MOCK_OPEN_NODES);
const showNoNodes = useFeatureFlag(FEATURE_FLAG.MOCK_NO_OPEN_NODES);

if (showMockNodes && showNoNodes) {
console.error('Cannot show mock nodes and no nodes at the same time');
}

const { data, isLoading } = useSessionStakingQuery({
query: 'getOpenNodes',
args: undefined,
});

const node = useMemo(() => data?.nodes.find((node) => node.pubKey === nodeId), [data, nodeId]);
const node = useMemo(() => {
if (showMockNodes) {
return generateOpenNodes({ userAddress: address })[0];
} else if (showNoNodes) {
return {} as OpenNode;
}
return data?.nodes.find((node) => node.pubKey === nodeId);
}, [data, nodeId, showMockNodes, showNoNodes]);

return isLoading ? (
<Loading />
Expand Down

0 comments on commit 3a49222

Please sign in to comment.