Commit 058a6dd7 authored by tom's avatar tom

account routes and home route

parent b6626be8
...@@ -3,14 +3,13 @@ import { useRouter } from 'next/router'; ...@@ -3,14 +3,13 @@ import { useRouter } from 'next/router';
import React from 'react'; import React from 'react';
import useGradualIncrement from 'lib/hooks/useGradualIncrement'; import useGradualIncrement from 'lib/hooks/useGradualIncrement';
import { ROUTES } from 'lib/link/routes';
import useSocketChannel from 'lib/socket/useSocketChannel'; import useSocketChannel from 'lib/socket/useSocketChannel';
import useSocketMessage from 'lib/socket/useSocketMessage'; import useSocketMessage from 'lib/socket/useSocketMessage';
function getSocketParams(router: NextRouter) { function getSocketParams(router: NextRouter) {
if ( if (
router.pathname === ROUTES.txs.pattern && router.pathname === '/txs' &&
(router.query.tab === 'validated' || router.query.tab === undefined) && (router.query.tab === 'validated' || router.query.tab === undefined) &&
!router.query.block_number && !router.query.block_number &&
!router.query.page !router.query.page
...@@ -18,12 +17,12 @@ function getSocketParams(router: NextRouter) { ...@@ -18,12 +17,12 @@ function getSocketParams(router: NextRouter) {
return { topic: 'transactions:new_transaction' as const, event: 'transaction' as const }; return { topic: 'transactions:new_transaction' as const, event: 'transaction' as const };
} }
if (router.pathname === ROUTES.network_index.pattern) { if (router.pathname === '/') {
return { topic: 'transactions:new_transaction' as const, event: 'transaction' as const }; return { topic: 'transactions:new_transaction' as const, event: 'transaction' as const };
} }
if ( if (
router.pathname === ROUTES.txs.pattern && router.pathname === '/txs' &&
router.query.tab === 'pending' && router.query.tab === 'pending' &&
!router.query.block_number && !router.query.block_number &&
!router.query.page !router.query.page
......
export const ACCOUNT_ROUTES: Array<RouteName> = [ 'watchlist', 'private_tags', 'public_tags', 'api_keys', 'custom_abi' ];
import type { RouteName } from 'lib/link/routes';
export default function isAccountRoute(route: RouteName) {
return ACCOUNT_ROUTES.includes(route);
}
import link from './link'; import link from './link';
it('makes correct link if there are no params in path', () => { it('makes correct link if there are no params in path', () => {
const result = link('api_keys'); const result = link('stats');
expect(result).toBe('https://blockscout.com/account/api_key'); expect(result).toBe('https://blockscout.com/stats');
}); });
it('makes correct link if there are params in path', () => { it('makes correct link if there are params in path', () => {
......
...@@ -11,30 +11,31 @@ export type RouteName = keyof typeof ROUTES; ...@@ -11,30 +11,31 @@ export type RouteName = keyof typeof ROUTES;
export const ROUTES = { export const ROUTES = {
// NETWORK MAIN PAGE // NETWORK MAIN PAGE
// todo_tom need full url builder
network_index: { network_index: {
pattern: PATHS.network_index, pattern: PATHS.network_index,
crossNetworkNavigation: true, crossNetworkNavigation: true,
}, },
// ACCOUNT // ACCOUNT
watchlist: { // watchlist: {
pattern: PATHS.watchlist, // pattern: PATHS.watchlist,
}, // },
private_tags: { // private_tags: {
pattern: PATHS.private_tags, // pattern: PATHS.private_tags,
}, // },
public_tags: { // public_tags: {
pattern: PATHS.public_tags, // pattern: PATHS.public_tags,
}, // },
api_keys: { // api_keys: {
pattern: PATHS.api_keys, // pattern: PATHS.api_keys,
}, // },
custom_abi: { // custom_abi: {
pattern: PATHS.custom_abi, // pattern: PATHS.custom_abi,
}, // },
profile: { // profile: {
pattern: PATHS.profile, // pattern: PATHS.profile,
}, // },
// TRANSACTIONS // TRANSACTIONS
txs: { txs: {
......
import { test as base, expect } from '@playwright/experimental-ct-react'; import { test as base, expect } from '@playwright/experimental-ct-react';
import React from 'react'; import React from 'react';
import { ROUTES } from 'lib/link/routes';
import * as statsMock from 'mocks/stats/index'; import * as statsMock from 'mocks/stats/index';
import * as txMock from 'mocks/txs/tx'; import * as txMock from 'mocks/txs/tx';
import * as socketServer from 'playwright/fixtures/socketServer'; import * as socketServer from 'playwright/fixtures/socketServer';
...@@ -42,7 +41,7 @@ test.describe('socket', () => { ...@@ -42,7 +41,7 @@ test.describe('socket', () => {
const hooksConfig = { const hooksConfig = {
router: { router: {
pathname: ROUTES.network_index.pattern, pathname: '/',
query: {}, query: {},
}, },
}; };
......
import { Box, Button, Heading, Icon, Text, chakra } from '@chakra-ui/react'; import { Box, Button, Heading, Icon, Text, chakra } from '@chakra-ui/react';
import { route } from 'nextjs-routes';
import React from 'react'; import React from 'react';
import icon404 from 'icons/error-pages/404.svg'; import icon404 from 'icons/error-pages/404.svg';
import icon422 from 'icons/error-pages/422.svg'; import icon422 from 'icons/error-pages/422.svg';
import icon500 from 'icons/error-pages/500.svg'; import icon500 from 'icons/error-pages/500.svg';
import link from 'lib/link/link';
interface Props { interface Props {
statusCode: number; statusCode: number;
...@@ -42,7 +42,7 @@ const AppError = ({ statusCode, className }: Props) => { ...@@ -42,7 +42,7 @@ const AppError = ({ statusCode, className }: Props) => {
size="lg" size="lg"
variant="outline" variant="outline"
as="a" as="a"
href={ link('network_index') } href={ route({ pathname: '/' }) }
> >
Back to home Back to home
</Button> </Button>
......
import { Icon, Box, Image, useColorModeValue } from '@chakra-ui/react'; import { Icon, Box, Image, useColorModeValue } from '@chakra-ui/react';
import { route } from 'nextjs-routes';
import React from 'react'; import React from 'react';
import appConfig from 'configs/app/config'; import appConfig from 'configs/app/config';
import smallLogoPlaceholder from 'icons/networks/icons/placeholder.svg'; import smallLogoPlaceholder from 'icons/networks/icons/placeholder.svg';
import logoPlaceholder from 'icons/networks/logos/blockscout.svg'; import logoPlaceholder from 'icons/networks/logos/blockscout.svg';
import link from 'lib/link/link';
import ASSETS from 'lib/networks/networkAssets'; import ASSETS from 'lib/networks/networkAssets';
interface Props { interface Props {
...@@ -14,7 +14,7 @@ interface Props { ...@@ -14,7 +14,7 @@ interface Props {
const NetworkLogo = ({ isCollapsed, onClick }: Props) => { const NetworkLogo = ({ isCollapsed, onClick }: Props) => {
const logoColor = useColorModeValue('blue.600', 'white'); const logoColor = useColorModeValue('blue.600', 'white');
const href = link('network_index'); const href = route({ pathname: '/' });
const [ isLogoError, setLogoError ] = React.useState(false); const [ isLogoError, setLogoError ] = React.useState(false);
const [ isSmallLogoError, setSmallLogoError ] = React.useState(false); const [ isSmallLogoError, setSmallLogoError ] = React.useState(false);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment