import React, { useState } from 'react'
import PropTypes from 'prop-types'
import { Typography, Tooltip, Button } from 'antd'
import CopyButton from './CopyButton'
import EyeIcon from '../../Icons/EyeIcon'
import EyeSlashIcon from '../../Icons/EyeSlashIcon'
const { Text } = Typography
const SecretDisplay = ({ value, reveal = false }) => {
const [visible, setVisible] = useState(false)
if (!value) {
return n/a
}
const masked = '•'.repeat(Math.max(8, value.length))
return (
{reveal && visible ? value : masked}
{reveal && (
: }
onClick={() => setVisible((v) => !v)}
size='small'
aria-label={visible ? 'Hide secret' : 'Show secret'}
/>
)}
{reveal && value && (
)}
)
}
SecretDisplay.propTypes = {
value: PropTypes.string,
reveal: PropTypes.bool
}
export default SecretDisplay