|
|
|
@ -1,4 +1,6 @@ |
|
|
|
|
import Link from 'next/link'; |
|
|
|
|
import { useRouter } from 'next/router'; |
|
|
|
|
import { PropsWithChildren } from 'react'; |
|
|
|
|
|
|
|
|
|
import { ChainIcon } from '../../components/icons/ChainIcon'; |
|
|
|
|
import { MessageStatus, MessageStub } from '../../types'; |
|
|
|
@ -35,7 +37,7 @@ export function MessageTable({ |
|
|
|
|
className={`cursor-pointer hover:bg-gray-100 active:bg-gray-200 border-b border-gray-100 last:border-0 ${ |
|
|
|
|
isFetching && 'blur-xs' |
|
|
|
|
} transition-all duration-500`}
|
|
|
|
|
onClick={() => router.push(`/message/${m.id}`)} |
|
|
|
|
// onClick={() => router.push(`/message/${m.id}`)}
|
|
|
|
|
> |
|
|
|
|
<MessageSummaryRow message={m} /> |
|
|
|
|
</tr> |
|
|
|
@ -47,6 +49,7 @@ export function MessageTable({ |
|
|
|
|
|
|
|
|
|
export function MessageSummaryRow({ message }: { message: MessageStub }) { |
|
|
|
|
const { |
|
|
|
|
id, |
|
|
|
|
status, |
|
|
|
|
sender, |
|
|
|
|
recipient, |
|
|
|
@ -68,50 +71,59 @@ export function MessageSummaryRow({ message }: { message: MessageStub }) { |
|
|
|
|
|
|
|
|
|
return ( |
|
|
|
|
<> |
|
|
|
|
<td className="py-3.5"> |
|
|
|
|
<div className="flex items-center pl-3 sm:pl-5"> |
|
|
|
|
<ChainIcon chainId={originChainId} size={22} /> |
|
|
|
|
<div className={styles.valueChainName}>{getChainDisplayName(originChainId, true)}</div> |
|
|
|
|
</div> |
|
|
|
|
</td> |
|
|
|
|
<td> |
|
|
|
|
<div className="flex items-center"> |
|
|
|
|
<ChainIcon chainId={destinationChainId} size={22} /> |
|
|
|
|
<div className={styles.valueChainName}> |
|
|
|
|
{getChainDisplayName(destinationChainId, true)} |
|
|
|
|
</div> |
|
|
|
|
</div> |
|
|
|
|
</td> |
|
|
|
|
<td className="hidden sm:table-cell"> |
|
|
|
|
<div className={styles.value}>{shortenAddress(sender) || 'Invalid Address'}</div> |
|
|
|
|
</td> |
|
|
|
|
<td className="hidden sm:table-cell"> |
|
|
|
|
<div className={styles.value}>{shortenAddress(recipient) || 'Invalid Address'}</div> |
|
|
|
|
</td> |
|
|
|
|
<td> |
|
|
|
|
<div className={styles.valueTruncated}>{getHumanReadableTimeString(originTimestamp)}</div> |
|
|
|
|
</td> |
|
|
|
|
<td className="hidden lg:table-cell text-center px-4"> |
|
|
|
|
<div className={styles.valueTruncated}> |
|
|
|
|
<LinkCell id={id} aClasses="flex items-center py-3.5 pl-3 sm:pl-5"> |
|
|
|
|
<ChainIcon chainId={originChainId} size={20} /> |
|
|
|
|
<div className={styles.chainName}>{getChainDisplayName(originChainId, true)}</div> |
|
|
|
|
</LinkCell> |
|
|
|
|
<LinkCell id={id} aClasses="flex items-center py-3.5 "> |
|
|
|
|
<ChainIcon chainId={destinationChainId} size={20} /> |
|
|
|
|
<div className={styles.chainName}>{getChainDisplayName(destinationChainId, true)}</div> |
|
|
|
|
</LinkCell> |
|
|
|
|
<LinkCell id={id} tdClasses="hidden sm:table-cell" aClasses={styles.value}> |
|
|
|
|
{shortenAddress(sender) || 'Invalid Address'} |
|
|
|
|
</LinkCell> |
|
|
|
|
<LinkCell id={id} tdClasses="hidden sm:table-cell" aClasses={styles.value}> |
|
|
|
|
{shortenAddress(recipient) || 'Invalid Address'} |
|
|
|
|
</LinkCell> |
|
|
|
|
<LinkCell id={id} aClasses={styles.valueTruncated}> |
|
|
|
|
{getHumanReadableTimeString(originTimestamp)} |
|
|
|
|
</LinkCell> |
|
|
|
|
<LinkCell |
|
|
|
|
id={id} |
|
|
|
|
tdClasses="hidden lg:table-cell text-center px-4" |
|
|
|
|
aClasses={styles.valueTruncated} |
|
|
|
|
> |
|
|
|
|
{destinationTimestamp |
|
|
|
|
? getHumanReadableDuration(destinationTimestamp - originTimestamp, 3) |
|
|
|
|
: '-'} |
|
|
|
|
</div> |
|
|
|
|
</td> |
|
|
|
|
<td> |
|
|
|
|
<div className="flex items-center justify-center"> |
|
|
|
|
</LinkCell> |
|
|
|
|
<LinkCell id={id} aClasses="flex items-center justify-center"> |
|
|
|
|
<div className={`text-center w-20 md:w-[5.25rem] py-1.5 text-sm rounded ${statusColor}`}> |
|
|
|
|
{statusText} |
|
|
|
|
</div> |
|
|
|
|
</div> |
|
|
|
|
</td> |
|
|
|
|
</LinkCell> |
|
|
|
|
</> |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function LinkCell({ |
|
|
|
|
id, |
|
|
|
|
tdClasses, |
|
|
|
|
aClasses, |
|
|
|
|
children, |
|
|
|
|
}: PropsWithChildren<{ id: number; tdClasses?: string; aClasses?: string }>) { |
|
|
|
|
return ( |
|
|
|
|
<td className={tdClasses}> |
|
|
|
|
<Link href={`/message/${id}`}> |
|
|
|
|
<a className={aClasses}>{children}</a> |
|
|
|
|
</Link> |
|
|
|
|
</td> |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
const styles = { |
|
|
|
|
header: 'text-sm text-gray-700 font-normal pt-2 pb-3 text-center', |
|
|
|
|
value: 'text-sm text-center px-1', |
|
|
|
|
valueChainName: 'text-sm ml-2', |
|
|
|
|
valueTruncated: 'text-sm text-center truncate', |
|
|
|
|
value: 'py-3.5 flex items-center justify-center text-sm text-center px-1', |
|
|
|
|
valueTruncated: 'py-3.5 flex items-center justify-center text-sm text-center truncate', |
|
|
|
|
chainName: 'text-sm ml-2', |
|
|
|
|
}; |
|
|
|
|