Skip to content

Commit

Permalink
Merge branch 'open_nodes' into feat/no-ref/metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
yougotwill committed Jul 9, 2024
2 parents 57ff1dc + 6d0aa42 commit 8211ff6
Show file tree
Hide file tree
Showing 7 changed files with 46 additions and 11 deletions.
1 change: 1 addition & 0 deletions apps/staking/app/faucet/AuthModule.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ export const AuthModule = () => {
const { hash, error, faucetError } = res;
if (hash) {
setTransactionHash(hash);
setFormState(FORM_STATE.SUCCESS);
return resolve(hash);
}

Expand Down
2 changes: 1 addition & 1 deletion apps/staking/app/stake/ActionModule.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export const actionModuleBackground = {
background: 'url(/images/action-module-background-1.png)',
backgroundPositionX: '85%',
backgroundPositionY: 'bottom',
backgroundSize: '350%',
backgroundSize: '150%',
backgroundRepeat: 'no-repeat',
},
2: {
Expand Down
42 changes: 42 additions & 0 deletions apps/staking/app/stake/node/[nodeId]/BlockExplorerLink.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
'use client';

import { OpenNode } from '@session/sent-staking-js/client';
import { LoadingText } from '@session/ui/components/loading-text';
import { LinkOutIcon } from '@session/ui/icons/LinkOutIcon';
import { useTranslations } from 'next-intl';
import Link from 'next/link';
import { useEffect, useMemo, useState } from 'react';

export const BlockExplorerLink = ({ nodeId }: { nodeId: string }) => {
const [loading, setLoading] = useState<boolean>(true);
const [nodes, setNodes] = useState<Array<OpenNode>>([]);
const dictionary = useTranslations('actionModules.node');

useEffect(() => {
fetch('/api/sent/nodes/open')
.then((res) => res.json())
.then((data) => setNodes(data.nodes))
.catch(console.error)
.finally(() => setLoading(false));
}, []);

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

return loading ? (
<LoadingText />
) : node?.contract ? (
<Link href={`/explorer/${node?.contract}`} target="_blank">
<span className="text-session-green fill-session-green inline-flex items-center gap-1 align-middle">
{dictionary('viewOnExplorer')}
<LinkOutIcon className="h-4 w-4" />
</span>
</Link>
) : null;
};
12 changes: 2 additions & 10 deletions apps/staking/app/stake/node/[nodeId]/page.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { LinkOutIcon } from '@session/ui/icons/LinkOutIcon';
import { useTranslations } from 'next-intl';
import Link from 'next/link';
import ActionModule from '../../ActionModule';
import { BlockExplorerLink } from './BlockExplorerLink';
import NodeStaking from './NodeStaking';

interface NodePageParams {
Expand All @@ -17,14 +16,7 @@ export default function NodePage({ params }: NodePageParams) {
<ActionModule
background={1}
title={dictionary('title')}
headerAction={
<Link href={`/explorer/${nodeId}`}>
<span className="text-session-green fill-session-green inline-flex items-center gap-1 align-middle">
{dictionary('viewOnExplorer')}
<LinkOutIcon className="h-4 w-4" />
</span>
</Link>
}
headerAction={<BlockExplorerLink nodeId={nodeId} />}
>
<NodeStaking nodeId={nodeId} />
</ActionModule>
Expand Down
Binary file modified apps/staking/public/images/action-module-background-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified apps/staking/public/images/action-module-background-2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified apps/staking/public/images/action-module-background-3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 8211ff6

Please sign in to comment.