Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/kadena tools/sidebar account transactions #806

Merged
merged 6 commits into from
Aug 21, 2023
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/apps/tools/locales/en/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@
"Search for transactions": "Search for transactions",
"Filters": "Filters",
"Filtered by": "Filtered by",
"Transaction Details": "Transaction Details",
"Reset all filters": "Reset all filters",
"Reload": "Reload",
"Finisher": "Finisher",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,23 @@ import {
Box,
Breadcrumbs,
Button,
Card,
MRVDH marked this conversation as resolved.
Show resolved Hide resolved
ContentHeader,
Grid,
Heading,
ProductIcon,
ProgressBar,
SystemIcon,
Table,
Text,
TrackerCard,
} from '@kadena/react-ui';

import { filterItemClass, headerButtonGroupClass } from './styles.css';
import {
filterItemClass,
headerButtonGroupClass,
mainContentClass,
} from './styles.css';

import { Network } from '@/constants/kadena';
import Routes from '@/constants/routes';
Expand All @@ -23,7 +31,8 @@ import {
import Debug from 'debug';
import { useRouter } from 'next/router';
import useTranslation from 'next-translate/useTranslation';
import React, { FC, useEffect, useState } from 'react';
import React, { FC, useEffect, useRef, useState } from 'react';
import DrawerToolbar from '@/components/Common/DrawerToolbar';

const CheckTransactions: FC = () => {
const debug = Debug(
Expand All @@ -35,6 +44,9 @@ const CheckTransactions: FC = () => {

const [results, setResults] = useState<ITransaction[]>([]);
const [loadingState, setLoadingState] = useState<boolean>(true);
const [transactionDetails, setTransactionDetails] = useState<ITransaction>();

const transactionDetailsRef = useRef<HTMLElement | null>(null);

function displayAccountName(accountName: string): string {
if (accountName.length > 20) {
Expand Down Expand Up @@ -121,8 +133,71 @@ const CheckTransactions: FC = () => {
await router.push(Routes.ACCOUNT_TRANSACTIONS_FILTERS);
}

const handleOpenTransactionDetails = (result: ITransaction): void => {
setTransactionDetails(result);
// @ts-ignore
transactionDetailsRef.openSection(0);
};

return (
<div>
<div className={mainContentClass}>
<DrawerToolbar
ref={transactionDetailsRef}
sections={[
{
icon: SystemIcon.Information,
title: t('Transaction Details'),
children: (
<>
<TrackerCard
labelValues={[
{
label: 'Sender',
value: transactionDetails?.fromAccount,
isAccount: true,
},
{
label: 'From chain',
value: transactionDetails?.chain,
},
]}
icon={ProductIcon.QuickStart}
/>
<Box marginBottom="$5" />
<ProgressBar
checkpoints={[
{
title: 'Initiated transaction',
status: 'complete',
},
{
title: 'Transaction complete',
status: 'complete',
},
]}
/>
<Box marginBottom="$2" />
<TrackerCard
labelValues={[
{
label: 'Receiver',
value: transactionDetails?.fromAccount,
isAccount: true,
},
{
label: 'to chain',
value:
transactionDetails?.crossChainId ||
transactionDetails?.chain,
},
]}
icon={ProductIcon.ReceiverInactive}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The icon should change according to the transfer status. If the transfer is complete then it should show the Receiver icon instead of ReceiverInactive

Copy link
Contributor Author

@MRVDH MRVDH Aug 21, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The problem is that the API that I use (estats) only returns completed transfers it seems. So this PR is just to push the current work, even though it's not done yet. I am going to create tickets with everything that still needs to be refactored and completed

Copy link
Contributor

@nil-amrutlal nil-amrutlal Aug 21, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh ok I see. Then maybe just replace the Icon with ProductIcon.Receiver (used for completed transfers)? And then all good :)

/>
</>
),
},
]}
/>
<Breadcrumbs.Root>
<Breadcrumbs.Item>{t('Account')}</Breadcrumbs.Item>
<Breadcrumbs.Item>{t('Transactions')}</Breadcrumbs.Item>
Expand Down Expand Up @@ -197,7 +272,10 @@ const CheckTransactions: FC = () => {
}

return (
<Table.Tr key={index} url={''}>
<Table.Tr
key={index}
onClick={(_) => handleOpenTransactionDetails(result)}
>
<Table.Td>
{new Date(result.blockTime).toLocaleString()}
</Table.Td>
Expand Down Expand Up @@ -236,7 +314,10 @@ const CheckTransactions: FC = () => {
}

return (
<Table.Tr key={index} url={''}>
<Table.Tr
key={index}
onClick={(_) => handleOpenTransactionDetails(result)}
>
<Table.Td>
{new Date(result.blockTime).toLocaleString()}
</Table.Td>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@ import { sprinkles, vars } from '@kadena/react-ui/theme';

import { style } from '@vanilla-extract/css';

export const mainContentClass = style([
{
width: `calc(100% - ${vars.sizes.$16})`,
},
]);

export const headerButtonGroupClass = style([
sprinkles({
display: 'flex',
Expand Down
Loading