diff --git a/apps/ui-kit/src/lib/components/molecules/card/card.classes.ts b/apps/ui-kit/src/lib/components/molecules/card/card.classes.ts index 4dd93547069..b1d9987f968 100644 --- a/apps/ui-kit/src/lib/components/molecules/card/card.classes.ts +++ b/apps/ui-kit/src/lib/components/molecules/card/card.classes.ts @@ -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 = { diff --git a/apps/wallet-dashboard/app/(protected)/home/page.tsx b/apps/wallet-dashboard/app/(protected)/home/page.tsx index 0ffe5f2eb76..61ba1487213 100644 --- a/apps/wallet-dashboard/app/(protected)/home/page.tsx +++ b/apps/wallet-dashboard/app/(protected)/home/page.tsx @@ -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'; @@ -47,7 +47,7 @@ function HomeDashboardPage(): JSX.Element { Vesting
- Activity +
diff --git a/apps/wallet-dashboard/components/Popup/Popups/TransactionDetailsPopup.tsx b/apps/wallet-dashboard/components/Popup/Popups/TransactionDetailsPopup.tsx index 5ab2eb72942..bb622c166dd 100644 --- a/apps/wallet-dashboard/components/Popup/Popups/TransactionDetailsPopup.tsx +++ b/apps/wallet-dashboard/components/Popup/Popups/TransactionDetailsPopup.tsx @@ -13,7 +13,7 @@ import { StakeTransactionCard, TransactionSummary, UnstakeTransactionCard, -} from '@/components/Transaction'; +} from '@/components/transactions'; interface TransactionDetailsPopupProps { transaction: ExtendedTransaction; diff --git a/apps/wallet-dashboard/components/TransactionIcon.tsx b/apps/wallet-dashboard/components/TransactionIcon.tsx deleted file mode 100644 index 72e8eb65d06..00000000000 --- a/apps/wallet-dashboard/components/TransactionIcon.tsx +++ /dev/null @@ -1,45 +0,0 @@ -// Copyright (c) 2024 IOTA Stiftung -// SPDX-License-Identifier: Apache-2.0 - -import { TransactionAction, TransactionState } from '@/lib/interfaces'; -import { ArrowRight, IotaLogoMark, Person, Stake, Unstake } from '@iota/ui-icons'; - -const icons = { - [TransactionAction.Send]: ( - - ), - [TransactionAction.Receive]: ( - - ), - [TransactionAction.Transaction]: ( - - ), - [TransactionAction.Staked]: ( - - ), - [TransactionAction.Unstaked]: , - [TransactionAction.Rewards]: , - [TransactionAction.PersonalMessage]: ( - - ), -}; - -interface TransactionIconProps { - state: TransactionState; - action: keyof typeof icons; -} - -function TransactionIcon({ state, action }: TransactionIconProps) { - const isError = state === TransactionState.Failed; - return ( -
- {icons[action]} -
- ); -} - -export default TransactionIcon; diff --git a/apps/wallet-dashboard/components/TransactionTile.tsx b/apps/wallet-dashboard/components/TransactionTile.tsx deleted file mode 100644 index 0dda8f3f10c..00000000000 --- a/apps/wallet-dashboard/components/TransactionTile.tsx +++ /dev/null @@ -1,36 +0,0 @@ -// 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, Button } from '@/components'; -import { ExtendedTransaction } from '@/lib/interfaces'; - -interface TransactionTileProps { - transaction: ExtendedTransaction; -} - -function TransactionTile({ transaction }: TransactionTileProps): JSX.Element { - const { openPopup, closePopup } = usePopups(); - - const handleDetailsClick = () => { - openPopup(); - }; - - return ( -
- -
-

{transaction.action}

- {transaction?.timestamp && {formatTimestamp(transaction.timestamp)}} -
- -
- ); -} - -export default TransactionTile; diff --git a/apps/wallet-dashboard/components/VirtualList.tsx b/apps/wallet-dashboard/components/VirtualList.tsx index 7ca2d37187b..49178382bfc 100644 --- a/apps/wallet-dashboard/components/VirtualList.tsx +++ b/apps/wallet-dashboard/components/VirtualList.tsx @@ -72,7 +72,7 @@ function VirtualList({ {virtualItems.map((virtualItem) => (
, + Receive: , + Transaction: , + Staked: , + Unstaked: , + Rewards: , + Failed: , + Loading: , + PersonalMessage: , +}; + +interface TransactionIconProps { + txnFailed?: boolean; + variant: keyof typeof icons; +} + +function TransactionIcon({ txnFailed, variant }: TransactionIconProps) { + return
{icons[txnFailed ? 'Failed' : variant]}
; +} +export default TransactionIcon; diff --git a/apps/wallet-dashboard/components/Transaction/TransactionSummary.tsx b/apps/wallet-dashboard/components/transactions/TransactionSummary.tsx similarity index 100% rename from apps/wallet-dashboard/components/Transaction/TransactionSummary.tsx rename to apps/wallet-dashboard/components/transactions/TransactionSummary.tsx diff --git a/apps/wallet-dashboard/components/transactions/TransactionTile.tsx b/apps/wallet-dashboard/components/transactions/TransactionTile.tsx new file mode 100644 index 00000000000..cb029808b3c --- /dev/null +++ b/apps/wallet-dashboard/components/transactions/TransactionTile.tsx @@ -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(); + }; + + const transactionDate = transaction?.timestamp && formatTimestamp(transaction.timestamp); + return ( + + + + + + + + ); +} + +export default TransactionTile; diff --git a/apps/wallet-dashboard/components/transactions/TransactionsList.tsx b/apps/wallet-dashboard/components/transactions/TransactionsList.tsx new file mode 100644 index 00000000000..526329aed43 --- /dev/null +++ b/apps/wallet-dashboard/components/transactions/TransactionsList.tsx @@ -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
{error?.message}
; + } + + const virtualItem = (rawTransaction: IotaTransactionBlockResponse): JSX.Element => { + const transaction = getExtendedTransaction(rawTransaction, currentAccount?.address || ''); + return ; + }; + + return 60} render={virtualItem} />; +} + +export default TransactionsList; diff --git a/apps/wallet-dashboard/components/transactions/TransactionsOverview.tsx b/apps/wallet-dashboard/components/transactions/TransactionsOverview.tsx new file mode 100644 index 00000000000..a590e3abcdb --- /dev/null +++ b/apps/wallet-dashboard/components/transactions/TransactionsOverview.tsx @@ -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 ( + + + <div className="px-sm pb-md pt-sm"> + <TransactionsList /> + </div> + </Panel> + ); +} + +export default TransactionsOverview; diff --git a/apps/wallet-dashboard/components/Transaction/UnstakeTransactionCard.tsx b/apps/wallet-dashboard/components/transactions/UnstakeTransactionCard.tsx similarity index 100% rename from apps/wallet-dashboard/components/Transaction/UnstakeTransactionCard.tsx rename to apps/wallet-dashboard/components/transactions/UnstakeTransactionCard.tsx diff --git a/apps/wallet-dashboard/components/Transaction/BalanceChanges/BalanceChangeEntries.tsx b/apps/wallet-dashboard/components/transactions/balance-changes/BalanceChangeEntries.tsx similarity index 95% rename from apps/wallet-dashboard/components/Transaction/BalanceChanges/BalanceChangeEntries.tsx rename to apps/wallet-dashboard/components/transactions/balance-changes/BalanceChangeEntries.tsx index 9ee8daeab4d..14cc9ad7891 100644 --- a/apps/wallet-dashboard/components/Transaction/BalanceChanges/BalanceChangeEntries.tsx +++ b/apps/wallet-dashboard/components/transactions/balance-changes/BalanceChangeEntries.tsx @@ -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 { diff --git a/apps/wallet-dashboard/components/Transaction/BalanceChanges/BalanceChangeEntry.tsx b/apps/wallet-dashboard/components/transactions/balance-changes/BalanceChangeEntry.tsx similarity index 100% rename from apps/wallet-dashboard/components/Transaction/BalanceChanges/BalanceChangeEntry.tsx rename to apps/wallet-dashboard/components/transactions/balance-changes/BalanceChangeEntry.tsx diff --git a/apps/wallet-dashboard/components/Transaction/BalanceChanges/BalanceChanges.tsx b/apps/wallet-dashboard/components/transactions/balance-changes/BalanceChanges.tsx similarity index 92% rename from apps/wallet-dashboard/components/Transaction/BalanceChanges/BalanceChanges.tsx rename to apps/wallet-dashboard/components/transactions/balance-changes/BalanceChanges.tsx index 9f421c9e17c..34c507c62d7 100644 --- a/apps/wallet-dashboard/components/Transaction/BalanceChanges/BalanceChanges.tsx +++ b/apps/wallet-dashboard/components/transactions/balance-changes/BalanceChanges.tsx @@ -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[]>; diff --git a/apps/wallet-dashboard/components/Transaction/BalanceChanges/index.ts b/apps/wallet-dashboard/components/transactions/balance-changes/index.ts similarity index 100% rename from apps/wallet-dashboard/components/Transaction/BalanceChanges/index.ts rename to apps/wallet-dashboard/components/transactions/balance-changes/index.ts diff --git a/apps/wallet-dashboard/components/Transaction/index.ts b/apps/wallet-dashboard/components/transactions/index.ts similarity index 55% rename from apps/wallet-dashboard/components/Transaction/index.ts rename to apps/wallet-dashboard/components/transactions/index.ts index e87efcb41e4..7602efd1395 100644 --- a/apps/wallet-dashboard/components/Transaction/index.ts +++ b/apps/wallet-dashboard/components/transactions/index.ts @@ -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'; diff --git a/apps/wallet-dashboard/components/Transaction/ObjectChanges/ObjectChangeEntry.tsx b/apps/wallet-dashboard/components/transactions/object-changes/ObjectChangeEntry.tsx similarity index 97% rename from apps/wallet-dashboard/components/Transaction/ObjectChanges/ObjectChangeEntry.tsx rename to apps/wallet-dashboard/components/transactions/object-changes/ObjectChangeEntry.tsx index 7b765fac8de..9d386d6e6d3 100644 --- a/apps/wallet-dashboard/components/Transaction/ObjectChanges/ObjectChangeEntry.tsx +++ b/apps/wallet-dashboard/components/transactions/object-changes/ObjectChangeEntry.tsx @@ -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 { diff --git a/apps/wallet-dashboard/components/Transaction/ObjectChanges/ObjectChanges.tsx b/apps/wallet-dashboard/components/transactions/object-changes/ObjectChanges.tsx similarity index 93% rename from apps/wallet-dashboard/components/Transaction/ObjectChanges/ObjectChanges.tsx rename to apps/wallet-dashboard/components/transactions/object-changes/ObjectChanges.tsx index 8df1decfea8..b3b246e6f0e 100644 --- a/apps/wallet-dashboard/components/Transaction/ObjectChanges/ObjectChanges.tsx +++ b/apps/wallet-dashboard/components/transactions/object-changes/ObjectChanges.tsx @@ -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; diff --git a/apps/wallet-dashboard/components/Transaction/ObjectChanges/ObjectDetail.tsx b/apps/wallet-dashboard/components/transactions/object-changes/ObjectDetail.tsx similarity index 100% rename from apps/wallet-dashboard/components/Transaction/ObjectChanges/ObjectDetail.tsx rename to apps/wallet-dashboard/components/transactions/object-changes/ObjectDetail.tsx diff --git a/apps/wallet-dashboard/components/Transaction/ObjectChanges/index.ts b/apps/wallet-dashboard/components/transactions/object-changes/index.ts similarity index 100% rename from apps/wallet-dashboard/components/Transaction/ObjectChanges/index.ts rename to apps/wallet-dashboard/components/transactions/object-changes/index.ts