mirror of
https://github.com/apotdevin/thunderhub.git
synced 2025-02-21 22:11:37 +01:00
* feat: initial nextjs commit * chore: general card styles changes * chore: add storybook * chore: small changes and fixes * fix: trading filter encoding * fix: add link to node * chore: set to correct version
52 lines
1.3 KiB
TypeScript
52 lines
1.3 KiB
TypeScript
import React, { useState } from 'react';
|
|
import { useQuery } from '@apollo/react-hooks';
|
|
import { useAccount } from '../src/context/AccountContext';
|
|
import {
|
|
CardWithTitle,
|
|
SubTitle,
|
|
Card,
|
|
} from '../src/components/generic/Styled';
|
|
import { PeersCard } from '../src/views/peers/PeersCard';
|
|
import { LoadingCard } from '../src/components/loading/LoadingCard';
|
|
import { AddPeer } from '../src/views/peers/AddPeer';
|
|
import { GET_PEERS } from '../src/graphql/query';
|
|
|
|
const PeersView = () => {
|
|
const [indexOpen, setIndexOpen] = useState(0);
|
|
const { host, viewOnly, cert, sessionAdmin } = useAccount();
|
|
const auth = {
|
|
host,
|
|
macaroon: viewOnly !== '' ? viewOnly : sessionAdmin,
|
|
cert,
|
|
};
|
|
|
|
const { loading, data } = useQuery(GET_PEERS, {
|
|
variables: { auth },
|
|
});
|
|
|
|
if (loading || !data || !data.getPeers) {
|
|
return <LoadingCard title={'Peers'} />;
|
|
}
|
|
|
|
return (
|
|
<>
|
|
<AddPeer />
|
|
<CardWithTitle>
|
|
<SubTitle>Peers</SubTitle>
|
|
<Card>
|
|
{data.getPeers.map((peer: any, index: number) => (
|
|
<PeersCard
|
|
peer={peer}
|
|
index={index + 1}
|
|
setIndexOpen={setIndexOpen}
|
|
indexOpen={indexOpen}
|
|
key={`${index}-${peer.public_key}`}
|
|
/>
|
|
))}
|
|
</Card>
|
|
</CardWithTitle>
|
|
</>
|
|
);
|
|
};
|
|
|
|
export default PeersView;
|