Skip to content

Commit

Permalink
chore: 🔧 add score query
Browse files Browse the repository at this point in the history
  • Loading branch information
apotdevin committed Dec 15, 2020
1 parent d1fec2b commit 7fa7cfc
Show file tree
Hide file tree
Showing 55 changed files with 1,863 additions and 52 deletions.
3 changes: 2 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,10 @@ module.exports = {
'@typescript-eslint/explicit-module-boundary-types': 'off',
'@typescript-eslint/explicit-function-return-type': 'off',
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-unused-vars': 0,
'import/no-unresolved': 'off',
'import/order': 2,
'no-unused-vars': 2,
'no-unused-vars': 0,
camelcase: 'off',
'@typescript-eslint/camelcase': 'off',
'react/prop-types': 'off',
Expand Down
110 changes: 94 additions & 16 deletions package-lock.json

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

5 changes: 5 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,13 @@
"@apollo/client": "^3.3.5",
"@next/bundle-analyzer": "^10.0.3",
"@visx/chord": "^1.0.0",
"@visx/curve": "^1.0.0",
"@visx/event": "^1.0.0",
"@visx/group": "^1.0.0",
"@visx/responsive": "^1.1.0",
"@visx/scale": "^1.1.0",
"@visx/shape": "^1.2.0",
"@visx/tooltip": "^1.1.0",
"apollo-server-micro": "^2.19.0",
"balanceofsatoshis": "^7.10.0",
"bcryptjs": "^2.4.3",
Expand All @@ -50,6 +53,7 @@
"boltz-core": "^0.3.5",
"cookie": "^0.4.1",
"crypto-js": "^4.0.0",
"d3-array": "^2.9.1",
"date-fns": "^2.16.1",
"graphql": "^15.4.0",
"graphql-iso-date": "^3.6.1",
Expand Down Expand Up @@ -109,6 +113,7 @@
"@types/bcryptjs": "^2.4.2",
"@types/cookie": "^0.4.0",
"@types/crypto-js": "^4.0.1",
"@types/d3-array": "^2.8.0",
"@types/graphql-iso-date": "^3.4.0",
"@types/js-cookie": "^2.2.6",
"@types/js-yaml": "^3.12.5",
Expand Down
13 changes: 8 additions & 5 deletions pages/_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { StyledToastContainer } from 'src/components/toastContainer/ToastContain
import { AppProps } from 'next/app';
import { ApolloProvider } from '@apollo/client';
import { useApollo } from 'config/client';
import { BaseProvider } from 'src/context/BaseContext';
import { ContextProvider } from '../src/context/ContextProvider';
import { useConfigState, ConfigProvider } from '../src/context/ConfigContext';
import { GlobalStyles } from '../src/styles/GlobalStyle';
Expand Down Expand Up @@ -46,11 +47,13 @@ export default function App({ Component, pageProps }: AppProps) {
<title>ThunderHub - Lightning Node Manager</title>
</Head>
<ConfigProvider initialConfig={pageProps.initialConfig}>
<ContextProvider>
<Wrapper>
<Component {...pageProps} />
</Wrapper>
</ContextProvider>
<BaseProvider initialHasToken={pageProps.hasToken}>
<ContextProvider>
<Wrapper>
<Component {...pageProps} />
</Wrapper>
</ContextProvider>
</BaseProvider>
</ConfigProvider>
<StyledToastContainer />
</ApolloProvider>
Expand Down
61 changes: 61 additions & 0 deletions pages/scores/[id].tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
import { GridWrapper } from 'src/components/gridWrapper/GridWrapper';
import { NextPageContext } from 'next';
import { getProps } from 'src/utils/ssr';
import { NodeInfo } from 'src/views/scores/NodeInfo';
import { useRouter } from 'next/router';
import { useBaseDispatch, useBaseState } from 'src/context/BaseContext';
import { useEffect, useState } from 'react';
import { appendBasePath } from 'src/utils/basePath';
import { NodeScores } from 'src/views/scores/NodeScores';
import { Graph } from 'src/views/scores/NodeGraph';
import { useDeleteBaseTokenMutation } from 'src/graphql/mutations/__generated__/deleteBaseToken.generated';

const NodeScoreView = () => {
const [loading, setLoading] = useState<boolean>(true);

const { push } = useRouter();

const { hasToken } = useBaseState();
const dispatch = useBaseDispatch();

const [deleteToken] = useDeleteBaseTokenMutation();

useEffect(() => {
if (!hasToken) {
push(appendBasePath('/token'));
}
}, [hasToken, push]);

const handleAuthError = () => {
dispatch({ type: 'change', hasToken: false });
deleteToken();
push(appendBasePath('/token'));
};

return (
<>
{!loading && (
<>
<Graph />
<NodeInfo />
</>
)}
<NodeScores
callback={() => setLoading(false)}
errorCallback={handleAuthError}
/>
</>
);
};

const Wrapped = () => (
<GridWrapper>
<NodeScoreView />
</GridWrapper>
);

export default Wrapped;

export async function getServerSideProps(context: NextPageContext) {
return await getProps(context);
}
Loading

0 comments on commit 7fa7cfc

Please sign in to comment.