AVIS / frontend /src /components /violation /EvidenceHash.jsx
X2-0's picture
HF Clean Deploy
1c0c94d
Raw
History Blame Contribute Delete
679 Bytes
import { useState } from 'react'
import { shortHash } from '../../lib/format.js'
export default function EvidenceHash({ hash }) {
const [copied, setCopied] = useState(false)
if (!hash) return <span className="muted"></span>
const copy = () => {
navigator.clipboard?.writeText(hash).then(() => {
setCopied(true)
setTimeout(() => setCopied(false), 1500)
})
}
return (
<span className="row" style={{ gap: 8 }}>
<span className="hash" title={hash}>
{shortHash(hash)}
</span>
<button className="ghost" onClick={copy} style={{ padding: '2px 8px' }}>
{copied ? 'copied' : 'copy'}
</button>
</span>
)
}