Skip to content

Commit

Permalink
feat(explorer): use proper layout for no results found
Browse files Browse the repository at this point in the history
  • Loading branch information
alber70g committed Dec 19, 2024
1 parent aec35fe commit f3421ca
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 22 deletions.
Original file line number Diff line number Diff line change
@@ -1,45 +1,35 @@
import { Heading, Stack } from '@kadena/kode-ui';
import { Heading, Text } from '@kadena/kode-ui';
import type { FC } from 'react';
import React from 'react';

interface NoSearchResultsProps {
interface INoSearchResultsProps {
type?: 'requestKey' | 'accountName' | 'blockhash';
value?: string;
}

export const NoSearchResults: FC<NoSearchResultsProps> = ({ type, value }) => {
export const NoSearchResults: FC<INoSearchResultsProps> = ({ type, value }) => {
// TODO: add buttons to navigate to other networks testnet/mainnet
// Use url from router to query other networks to see if the search result is
// there

switch (true) {
case type === 'requestKey' && value !== undefined:
return (
<Stack justifyContent="center" width="100%">
<Heading as="h3">No search results for request key: {value}</Heading>
</Stack>
<Heading as="h3">No search results for request key: {value}</Heading>
);

case type === 'accountName' && value !== undefined:
return (
<Stack justifyContent="center" flexDirection={'column'} width="100%">
<>
<Heading as="h3">No search results for account: {value}</Heading>
<Heading as="h4">Please check the account name and try again</Heading>
</Stack>
<Text>Please check the network and account name and try again</Text>
</>
);

case type === 'blockhash' && value !== undefined:
return (
<Stack justifyContent="center" width="100%">
<Heading as="h3">No search results for block: {value}</Heading>
</Stack>
);
return <Heading as="h3">No search results for block: {value}</Heading>;

default:
return (
<Stack justifyContent="center" width="100%">
<Heading as="h3">No search results</Heading>
</Stack>
);
return <Heading as="h3">No search results</Heading>;
}
};
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@ const Height: React.FC = () => {
key={`chain${chainData.chainId}`}
>
{chainData.data.edges.length === 0 ? (
<NoSearchResults />
<LayoutBody>
<NoSearchResults />
</LayoutBody>
) : (
<CompactTable
isLoading={isLoading}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ const Transaction: React.FC = () => {
}, [loading, data, error, setIsLoading]);

return (
<Layout>
<Layout layout='full'>
{innerData && innerData.transaction ? (
<>
<LayoutHeader>
Expand Down Expand Up @@ -120,7 +120,12 @@ const Transaction: React.FC = () => {
</>
) : (
!Array.isArray(router.query.requestKey) && (
<NoSearchResults type="requestKey" value={router.query.requestKey} />
<LayoutBody>
<NoSearchResults
type="requestKey"
value={router.query.requestKey}
/>
</LayoutBody>
)
)}
</Layout>
Expand Down

0 comments on commit f3421ca

Please sign in to comment.