Skip to content

Commit

Permalink
Merge pull request #102 from palladians/fix/transaction-labels
Browse files Browse the repository at this point in the history
Feat: Transaction Labels 🥩
  • Loading branch information
teddyjfpender authored Dec 21, 2023
2 parents e0ab2ba + e34c2c2 commit 5c563b2
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 14 deletions.
29 changes: 17 additions & 12 deletions packages/features/src/transactions/components/TxIndicator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@ import { Mina } from '@palladxyz/mina-core'
import {
ArrowDownLeftIcon,
ArrowUpRightIcon,
BeefIcon,
CoinsIcon,
RepeatIcon
} from 'lucide-react'

import { TxSide } from '../../common/types'
import { TxKind, TxSide } from '../../common/types'

interface TxSideIndicatorProps {
side: TxSide
Expand All @@ -19,19 +20,23 @@ interface TxSideIndicatorProps {
export const TxIndicator = ({ kind, side, from, to }: TxSideIndicatorProps) => {
const isSentToSelf = from === to

let icon

if (kind === TxKind.PAYMENT) {
if (isSentToSelf) {
icon = <RepeatIcon />
} else {
icon =
side === TxSide.INCOMING ? <ArrowDownLeftIcon /> : <ArrowUpRightIcon />
}
} else if (kind === TxKind.STAKE_DELEGATION) {
icon = <BeefIcon />
} else {
icon = <CoinsIcon />
}
return (
<div className="flex rounded-full dark:bg-blue-900 bg-blue-300 dark:text-blue-300 text-blue-900 w-10 h-10 justify-center items-center">
{kind === 'payment'.toUpperCase() && !isSentToSelf ? (
side === TxSide.INCOMING ? (
<ArrowDownLeftIcon />
) : (
<ArrowUpRightIcon />
)
) : isSentToSelf ? (
<RepeatIcon />
) : (
<CoinsIcon />
)}
{icon}
</div>
)
}
7 changes: 5 additions & 2 deletions packages/features/src/transactions/components/TxTile.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useNavigate } from 'react-router-dom'

import { StructurizedTransaction, TxSide } from '../../common/types'
import { StructurizedTransaction, TxKind, TxSide } from '../../common/types'
import { TxIndicator } from './TxIndicator'

interface TxTileProps {
Expand All @@ -10,7 +10,10 @@ interface TxTileProps {
export const TxTile = ({ tx }: TxTileProps) => {
const navigate = useNavigate()
const getTransactionLabel = (tx: StructurizedTransaction) => {
if (tx.from === tx.to) {
if (tx.kind === TxKind.STAKE_DELEGATION) {
return 'Delegation'
}
if (tx.from === tx.to && tx.kind === TxKind.PAYMENT) {
return 'Sent to Self'
}
return tx.side === TxSide.INCOMING ? 'Received' : 'Sent'
Expand Down

0 comments on commit 5c563b2

Please sign in to comment.