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(wallet-dashboard): add activity to homepage #3769

Merged
merged 29 commits into from
Nov 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
b0c9983
feat(wallet-dashboard): add protected layout
VmMad Oct 25, 2024
670f496
feat: add missing TopNav
VmMad Oct 28, 2024
d43a921
fix: tests
VmMad Oct 28, 2024
5ba9405
Merge branch 'develop' into tooling-dashboard/add-connected-layout
VmMad Oct 28, 2024
1100c2c
fix: imports
VmMad Oct 28, 2024
379c6a3
feat: add grid
evavirseda Oct 28, 2024
ecf6dc7
feat: refine balance box
evavirseda Oct 28, 2024
0f30b19
Merge branch 'develop' into tooling-dashboard/add-connected-layout
evavirseda Oct 28, 2024
ce8e637
Merge branch 'tooling-dashboard/add-connected-layout' into tooling-da…
evavirseda Oct 28, 2024
decadf0
feat: fix format
evavirseda Oct 28, 2024
37ce97e
fix: add missing themes
VmMad Oct 28, 2024
6211f65
Merge branch 'tooling-dashboard/add-connected-layout' into tooling-da…
evavirseda Oct 28, 2024
ae85129
Merge branch 'develop' into tooling-dashboard/style-balance-box
evavirseda Oct 29, 2024
946bbad
feat: add autoconnect feature
evavirseda Oct 29, 2024
32a875d
Merge branch 'develop' into tooling-dashboard/style-balance-box
begonaalvarezd Oct 29, 2024
5201253
feat: rename folder
evavirseda Oct 29, 2024
e9e11d5
feat: add missing styles
evavirseda Oct 29, 2024
ca3ae52
Merge branch 'develop' into tooling-dashboard/style-balance-box
evavirseda Oct 29, 2024
eb69257
Merge branch 'develop' into tooling-dashboard/style-balance-box
evavirseda Oct 29, 2024
cc2f0fc
feat: add toast after copye address
evavirseda Oct 29, 2024
b500fba
Merge branch 'develop' into tooling-dashboard/style-balance-box
evavirseda Oct 29, 2024
84afa84
feat: refine tx and rename folders
evavirseda Oct 29, 2024
ed6fb87
Merge branch 'develop' into tooling-dashboard/style-activity-homepage
evavirseda Oct 29, 2024
6873d41
Merge branch 'develop' into tooling-dashboard/style-activity-homepage
evavirseda Oct 29, 2024
219beb7
Merge branch 'develop' into tooling-dashboard/style-activity-homepage
evavirseda Oct 30, 2024
b86d433
Merge branch 'develop' into tooling-dashboard/style-activity-homepage
evavirseda Oct 30, 2024
4f7e0ec
Merge branch 'develop' into tooling-dashboard/style-activity-homepage
evavirseda Oct 30, 2024
eef60d1
Merge branch 'develop' into tooling-dashboard/style-activity-homepage
brancoder Nov 4, 2024
aec45e9
resolve conflicts
marc2332 Nov 6, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ export const IMAGE_VARIANT_CLASSES: { [key in ImageShape]: string } = {
};

export const IMAGE_BG_CLASSES: { [key in ImageType]: string } = {
[ImageType.Placeholder]: ``,
[ImageType.BgSolid]: `bg-neutral-96`,
[ImageType.BgTransparent]: ``,
[ImageType.Placeholder]: '',
[ImageType.BgSolid]: 'bg-neutral-96 dark:bg-neutral-10',
[ImageType.BgTransparent]: '',
};

export const CARD_TYPE_CLASSES: Record<CardType, string> = {
Expand Down
4 changes: 2 additions & 2 deletions apps/wallet-dashboard/app/(protected)/home/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// SPDX-License-Identifier: Apache-2.0
'use client';

import { AccountBalance, MyCoins, StakingOverview } from '@/components';
import { AccountBalance, MyCoins, TransactionsOverview, StakingOverview } from '@/components';
import { useFeature } from '@growthbook/growthbook-react';
import { Feature } from '@iota/core';
import { useCurrentAccount, useCurrentWallet } from '@iota/dapp-kit';
Expand Down Expand Up @@ -47,7 +47,7 @@ function HomeDashboardPage(): JSX.Element {
Vesting
</div>
<div style={{ gridArea: 'activity' }} className="flex grow overflow-hidden">
Activity
<TransactionsOverview />
</div>
</div>
</>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
StakeTransactionCard,
TransactionSummary,
UnstakeTransactionCard,
} from '@/components/Transaction';
} from '@/components/transactions';

interface TransactionDetailsPopupProps {
transaction: ExtendedTransaction;
Expand Down
45 changes: 0 additions & 45 deletions apps/wallet-dashboard/components/TransactionIcon.tsx

This file was deleted.

36 changes: 0 additions & 36 deletions apps/wallet-dashboard/components/TransactionTile.tsx

This file was deleted.

2 changes: 1 addition & 1 deletion apps/wallet-dashboard/components/VirtualList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ function VirtualList<T>({
{virtualItems.map((virtualItem) => (
<div
key={virtualItem.key}
className={`absolute w-full pb-4 pr-4 ${onClick ? 'cursor-pointer' : ''}`}
className={`absolute w-full ${onClick ? 'cursor-pointer' : ''}`}
style={{
position: 'absolute',
top: 0,
Expand Down
3 changes: 1 addition & 2 deletions apps/wallet-dashboard/components/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,11 @@

export { default as RouteLink } from './RouteLink';
export { default as Notifications } from './Notifications/Notifications';
export { default as TransactionTile } from './TransactionTile';
export { default as Box } from './Box';
export { default as AmountBox } from './AmountBox';
export { default as Input } from './Input';
export { default as VirtualList } from './VirtualList';
export { default as ExternalImage } from './ExternalImage';
export { default as TransactionIcon } from './TransactionIcon';
export { default as Dropdown } from './Dropdown';

export * from './account-balance/AccountBalance';
Expand All @@ -18,6 +16,7 @@ export * from './Popup';
export * from './AppList';
export * from './Cards';
export * from './Buttons';
export * from './transactions';
export * from './staking-overview';
export * from './Dialogs';
export * from './ImageIcon';
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// Copyright (c) 2024 IOTA Stiftung
// SPDX-License-Identifier: Apache-2.0

import { LoadingIndicator } from '@iota/apps-ui-kit';
import { ArrowBottomLeft, ArrowTopRight, Info, IotaLogoMark, Person, Stake } from '@iota/ui-icons';

const ICON_COLORS = {
primary: 'text-primary-30',
error: 'text-error-30',
};

const icons = {
Send: <ArrowTopRight className={ICON_COLORS.primary} />,
Receive: <ArrowBottomLeft className={ICON_COLORS.primary} />,
Transaction: <ArrowTopRight className={ICON_COLORS.primary} />,
Staked: <Stake className={ICON_COLORS.primary} />,
Unstaked: <Stake className={ICON_COLORS.primary} />,
Rewards: <IotaLogoMark className={ICON_COLORS.primary} />,
Failed: <Info className={ICON_COLORS.error} />,
Loading: <LoadingIndicator />,
PersonalMessage: <Person className={ICON_COLORS.primary} />,
};

interface TransactionIconProps {
txnFailed?: boolean;
variant: keyof typeof icons;
}

function TransactionIcon({ txnFailed, variant }: TransactionIconProps) {
return <div className="[&_svg]:h-5 [&_svg]:w-5">{icons[txnFailed ? 'Failed' : variant]}</div>;
}
export default TransactionIcon;
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
// Copyright (c) 2024 IOTA Stiftung
// SPDX-License-Identifier: Apache-2.0

'use client';

import React from 'react';
import TransactionIcon from './TransactionIcon';
import formatTimestamp from '@/lib/utils/time';
import { usePopups } from '@/hooks';
import { TransactionDetailsPopup } from '@/components';
import { ExtendedTransaction, TransactionState } from '@/lib/interfaces';
import {
Card,
CardType,
CardImage,
ImageType,
ImageShape,
CardBody,
CardAction,
CardActionType,
} from '@iota/apps-ui-kit';
import { useFormatCoin, useExtendedTransactionSummary, getLabel } from '@iota/core';
import { IOTA_TYPE_ARG } from '@iota/iota-sdk/utils';
import { useCurrentAccount } from '@iota/dapp-kit';

interface TransactionTileProps {
transaction: ExtendedTransaction;
}

function TransactionTile({ transaction }: TransactionTileProps): JSX.Element {
const account = useCurrentAccount();
const address = account?.address;
const { openPopup, closePopup } = usePopups();

const transactionSummary = useExtendedTransactionSummary(transaction.raw.digest);
const [formatAmount, symbol] = useFormatCoin(
Math.abs(Number(address ? transactionSummary?.balanceChanges?.[address]?.[0]?.amount : 0)),
IOTA_TYPE_ARG,
);

const handleDetailsClick = () => {
openPopup(<TransactionDetailsPopup transaction={transaction} onClose={closePopup} />);
};

const transactionDate = transaction?.timestamp && formatTimestamp(transaction.timestamp);
return (
<Card type={CardType.Default} isHoverable onClick={handleDetailsClick}>
<CardImage type={ImageType.BgSolid} shape={ImageShape.SquareRounded}>
<TransactionIcon
txnFailed={transaction.state === TransactionState.Failed}
variant={getLabel(transaction?.raw, address)}
/>
</CardImage>
<CardBody
title={
transaction.state === TransactionState.Failed
? 'Transaction Failed'
: (transaction.action ?? 'Unknown')
}
subtitle={transactionDate}
/>
<CardAction
type={CardActionType.SupportingText}
title={
transaction.state === TransactionState.Failed
? '--'
: `${formatAmount} ${symbol}`
}
/>
</Card>
);
}

export default TransactionTile;
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// Copyright (c) 2024 IOTA Stiftung
// SPDX-License-Identifier: Apache-2.0

import React from 'react';
import { useCurrentAccount } from '@iota/dapp-kit';
import { VirtualList, TransactionTile } from '@/components';
import { useQueryTransactionsByAddress } from '@iota/core';
import { getExtendedTransaction } from '@/lib/utils/transaction';
import { IotaTransactionBlockResponse } from '@iota/iota-sdk/client';

function TransactionsList() {
const currentAccount = useCurrentAccount();
const { data: transactions, error } = useQueryTransactionsByAddress(currentAccount?.address);

if (error) {
return <div>{error?.message}</div>;
}

const virtualItem = (rawTransaction: IotaTransactionBlockResponse): JSX.Element => {
const transaction = getExtendedTransaction(rawTransaction, currentAccount?.address || '');
return <TransactionTile transaction={transaction} />;
};

return <VirtualList items={transactions || []} estimateSize={() => 60} render={virtualItem} />;
}

export default TransactionsList;
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// Copyright (c) 2024 IOTA Stiftung
// SPDX-License-Identifier: Apache-2.0
'use client';

import { Panel, Title } from '@iota/apps-ui-kit';
import TransactionsList from './TransactionsList';

function TransactionsOverview() {
return (
<Panel>
<Title title="Activity" />
<div className="px-sm pb-md pt-sm">
<TransactionsList />
</div>
</Panel>
);
}

export default TransactionsOverview;
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

import { BalanceChange } from '@iota/core';
import { useMemo } from 'react';
import { BalanceChangeEntry } from './';
import { BalanceChangeEntry } from '.';
import { getRecognizedUnRecognizedTokenChanges } from '@iota/core';

interface BalanceChangeEntriesProps {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// SPDX-License-Identifier: Apache-2.0

import { BalanceChange } from '@iota/core';
import { BalanceChangeEntries } from './';
import { BalanceChangeEntries } from '.';

interface BalanceChangesProps {
balanceChanges: Record<string, BalanceChange[]>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ export { default as TransactionAmount } from './TransactionAmount';
export { default as StakeTransactionCard } from './StakeTransactionCard';
export { default as UnstakeTransactionCard } from './UnstakeTransactionCard';
export { default as TransactionSummary } from './TransactionSummary';
export { default as TransactionTile } from './TransactionTile';
export { default as TransactionIcon } from './TransactionIcon';
export { default as TransactionsList } from './TransactionsList';
export { default as TransactionsOverview } from './TransactionsOverview';

export * from './BalanceChanges';
export * from './ObjectChanges';
export * from './balance-changes';
export * from './object-changes';
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

import { ObjectChangesByOwner, IotaObjectChangeTypes } from '@iota/core';
import { IotaObjectChange } from '@iota/iota-sdk/client';
import { ObjectDetail } from './';
import { ObjectDetail } from '.';
import React from 'react';

interface ObjectChangeEntryProps {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// SPDX-License-Identifier: Apache-2.0

import { ObjectChangeSummary, IotaObjectChangeTypes } from '@iota/core';
import { ObjectChangeEntry } from './';
import { ObjectChangeEntry } from '.';

interface ObjectChangesProps {
objectSummary: ObjectChangeSummary;
Expand Down
Loading