Skip to content

Commit

Permalink
feat: conditionally show "devnet" or "testnet" depending on process ID
Browse files Browse the repository at this point in the history
  • Loading branch information
kunstmusik committed Feb 19, 2025
1 parent 05d08b8 commit 6a2adf8
Showing 1 changed file with 29 additions and 11 deletions.
40 changes: 29 additions & 11 deletions src/components/layout/Navbar/Navbar.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
import {
ARIO_DEVNET_PROCESS_ID,
ARIO_TESTNET_PROCESS_ID,
} from '@ar.io/sdk/web';
import { useGlobalState } from '@src/state';
import { useMemo } from 'react';
import { Link } from 'react-router-dom';

import { useRegistrationState } from '../../../state/contexts/RegistrationState';
Expand All @@ -8,8 +14,18 @@ import NetworkStatusBanner from './NetworkStatusBanner/NetworkStatusBanner';
import './styles.css';

function NavBar() {
const [{ arioProcessId }] = useGlobalState();
const [, dispatchRegisterState] = useRegistrationState();

const bannerText = useMemo(() => {
if (arioProcessId == ARIO_DEVNET_PROCESS_ID) {
return `Devnet`;
} else if (arioProcessId == ARIO_TESTNET_PROCESS_ID) {
return `Testnet`;
}
return undefined;
}, [arioProcessId]);

return (
<div
className="flex flex-column"
Expand All @@ -28,17 +44,19 @@ function NavBar() {
<div style={{ position: 'relative' }}>
<BrandLogo width={'36px'} height={'36px'} fill={'white'} />

{/* TODO: Conditionally show testnet depending on environment when mainnet becomes available */}
<div
className="testnet"
style={{
position: 'absolute',
top: '-6px',
left: '24px',
}}
>
Testnet
</div>
{/* TODO: Conditionally show tesnet/devnet depending on process id */}
{bannerText && (
<div
className="testnet"
style={{
position: 'absolute',
top: '-6px',
left: '24px',
}}
>
{bannerText}
</div>
)}
</div>
</Link>
</div>
Expand Down

0 comments on commit 6a2adf8

Please sign in to comment.