mirror of
https://github.com/luxfhe/example-poker.git
synced 2026-10-30 18:13:22 +00:00
49 lines
1.8 KiB
TypeScript
49 lines
1.8 KiB
TypeScript
import { useState } from "react";
|
|
import { CopyToClipboard } from "react-copy-to-clipboard";
|
|
import { TransactionReceipt } from "viem";
|
|
import { CheckCircleIcon, DocumentDuplicateIcon } from "@heroicons/react/24/outline";
|
|
import { displayTxResult } from "~~/app/debug/_components/contract";
|
|
|
|
export const TxReceipt = (
|
|
txResult: string | number | bigint | Record<string, any> | TransactionReceipt | undefined,
|
|
) => {
|
|
const [txResultCopied, setTxResultCopied] = useState(false);
|
|
|
|
return (
|
|
<div className="flex text-sm rounded-3xl peer-checked:rounded-b-none min-h-0 bg-secondary py-0">
|
|
<div className="mt-1 pl-2">
|
|
{txResultCopied ? (
|
|
<CheckCircleIcon
|
|
className="ml-1.5 text-xl font-normal text-sky-600 h-5 w-5 cursor-pointer"
|
|
aria-hidden="true"
|
|
/>
|
|
) : (
|
|
<CopyToClipboard
|
|
text={displayTxResult(txResult) as string}
|
|
onCopy={() => {
|
|
setTxResultCopied(true);
|
|
setTimeout(() => {
|
|
setTxResultCopied(false);
|
|
}, 800);
|
|
}}
|
|
>
|
|
<DocumentDuplicateIcon
|
|
className="ml-1.5 text-xl font-normal text-sky-600 h-5 w-5 cursor-pointer"
|
|
aria-hidden="true"
|
|
/>
|
|
</CopyToClipboard>
|
|
)}
|
|
</div>
|
|
<div className="flex-wrap collapse collapse-arrow">
|
|
<input type="checkbox" className="min-h-0 peer" />
|
|
<div className="collapse-title text-sm min-h-0 py-1.5 pl-1">
|
|
<strong>Transaction Receipt</strong>
|
|
</div>
|
|
<div className="collapse-content overflow-auto bg-secondary rounded-t-none rounded-3xl">
|
|
<pre className="text-xs pt-4">{displayTxResult(txResult)}</pre>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
);
|
|
};
|