Skip to content

Commit

Permalink
feat(rwa): check a check banner if the graphql backend is online (#2773)
Browse files Browse the repository at this point in the history
  • Loading branch information
sstraatemans authored Jan 7, 2025
1 parent 839d61f commit 2c9828f
Show file tree
Hide file tree
Showing 6 changed files with 85 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .changeset/good-bulldogs-train.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
---
44 changes: 44 additions & 0 deletions packages/apps/rwa-demo/src/__generated__/sdk.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions packages/apps/rwa-demo/src/app/(app)/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
import { ActiveTransactionsList } from '@/components/ActiveTransactionsList/ActiveTransactionsList';
import { AssetInfo } from '@/components/AssetInfo/AssetInfo';
import { DemoBanner } from '@/components/DemoBanner/DemoBanner';
import { GraphOnlineBanner } from '@/components/GraphOnlineBanner/GraphOnlineBanner';
import { TransactionPendingIcon } from '@/components/TransactionPendingIcon/TransactionPendingIcon';
import { useAccount } from '@/hooks/account';
import { useTransactions } from '@/hooks/transactions';
Expand Down Expand Up @@ -90,6 +91,7 @@ const RootLayout = ({
topBanner={
<Stack width="100%" gap="xs" flexDirection="column">
<DemoBanner />
<GraphOnlineBanner />
</Stack>
}
logo={
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { useNetworkInfoQuery } from '@/__generated__/sdk';
import { NETWORK_POLLING_RATE } from '@/constants';
import { Notification } from '@kadena/kode-ui';
import type { FC } from 'react';
import { useEffect } from 'react';

export const GraphOnlineBanner: FC = () => {
const variables = {
pollInterval: NETWORK_POLLING_RATE,
};

const { error, stopPolling } = useNetworkInfoQuery(variables);

useEffect(() => {
return () => {
stopPolling();
};
}, []);

if (!error) return;
return (
<Notification role="status" intent="warning">
The Graphql backend is down
</Notification>
);
};
1 change: 1 addition & 0 deletions packages/apps/rwa-demo/src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ export const ACCOUNT_COOKIE_NAME = 'rwa';
export const LOCALSTORAGE_ASSETS_KEY = 'assets';
export const LOCALSTORAGE_ASSETS_SELECTED_KEY = 'selected_asset';
export const INFINITE_COMPLIANCE = -1;
export const NETWORK_POLLING_RATE = 1000 * 30; /* 30 sec */

// todo: this is temporary for devnet
export const ADMIN = {
Expand Down
10 changes: 10 additions & 0 deletions packages/apps/rwa-demo/src/services/graph/network-info.graph.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { gql } from '@apollo/client';
import type { DocumentNode } from 'graphql';

export const networkInfo: DocumentNode = gql`
query networkInfo {
networkInfo {
apiVersion
}
}
`;

0 comments on commit 2c9828f

Please sign in to comment.