Skip to content

Commit

Permalink
[web] Enhance transaction icon
Browse files Browse the repository at this point in the history
  • Loading branch information
dnjooiopa committed Apr 27, 2024
1 parent 2b6d21c commit 573e551
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions web/src/components/Transactions.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
'use client'

import { FC, useEffect, useMemo, useState } from 'react'
import { RiSendPlaneFill } from 'react-icons/ri'

import useIsMounted from '@/hooks/useIsMounted'
import Axios from '@/libs/axios'
Expand All @@ -11,16 +12,24 @@ import { shortenTime } from '@/utils/date'
const TxItem = ({ amountSat, description, createdAt, type }: Transaction) => {
const amountColor = type === TransactionType.PAYMENT_SENT ? 'text-gray-100' : 'text-green-500'
const displayAmount = type === TransactionType.PAYMENT_SENT ? `-${amountSat}` : `+${amountSat}`
const displayDescription = description || (type === TransactionType.PAYMENT_SENT ? 'Sent' : 'Received')
// const displayDescription = description || (type === TransactionType.PAYMENT_SENT ? 'Sent' : 'Received')

const txIcon = useMemo(
() =>
type === TransactionType.PAYMENT_SENT ? (
<RiSendPlaneFill className={`text-2xl ${amountColor}`} />
) : (
<RiSendPlaneFill className={`text-2xl ${amountColor} rotate-90`} />
),
[type]
)

return (
<div className="flex justify-between mt-3">
<div className="flex flex-col items-start">
<div>
<span className="text-lg">{displayDescription}</span>
</div>
<div className="flex justify-between mt-3 py-1">
<div className="flex gap-2 items-start">
<div>{txIcon}</div>
<div>
<span className="text-sm">{shortenTime(new Date(createdAt))}</span>
<span className="text-md">{shortenTime(new Date(createdAt))}</span>
</div>
</div>
<div>
Expand Down

0 comments on commit 573e551

Please sign in to comment.