import { useState } from 'react'
import { FaEye, FaEyeSlash, FaCheck } from 'react-icons/fa6'
/**
* Anzeige mit Auge: Klick kopiert den Wert und schaltet Sichtbarkeit um.
*/
export default function CopyableCredential({ value }) {
const [visible, setVisible] = useState(false)
const [copied, setCopied] = useState(false)
const text = (value || '').trim()
if (!text) {
return –
}
const handleClick = async (e) => {
e.preventDefault()
e.stopPropagation()
setVisible((v) => !v)
try {
await navigator.clipboard.writeText(text)
} catch {
const ta = document.createElement('textarea')
ta.value = text
ta.setAttribute('readonly', '')
ta.style.position = 'fixed'
ta.style.left = '-9999px'
document.body.appendChild(ta)
ta.select()
document.execCommand('copy')
document.body.removeChild(ta)
}
setCopied(true)
setTimeout(() => setCopied(false), 2000)
}
const masked = '•'.repeat(Math.min(Math.max(text.length, 8), 16))
const display = visible ? text : masked
return (
{display}
)
}
export function getCustomerPortalPassword(customer) {
return customer?.portalPassword || customer?.password || ''
}