mirror of https://github.com/boxyhq/jackson.git
39 lines
1.1 KiB
TypeScript
39 lines
1.1 KiB
TypeScript
import { useTranslation } from 'next-i18next';
|
|
import { copyToClipboard } from '../utils';
|
|
import { IconButton } from './IconButton';
|
|
import ClipboardDocumentIcon from '@heroicons/react/24/outline/ClipboardDocumentIcon';
|
|
|
|
export const CopyToClipboardButton = ({ text }: { text: string }) => {
|
|
const { t } = useTranslation('common');
|
|
|
|
return (
|
|
<IconButton
|
|
tooltip={t('copy')}
|
|
Icon={ClipboardDocumentIcon}
|
|
className='hover:text-primary'
|
|
onClick={() => {
|
|
copyToClipboard(text);
|
|
// successToast(t('copied'));
|
|
}}
|
|
/>
|
|
);
|
|
};
|
|
|
|
export const InputWithCopyButton = ({ text, label }: { text: string; label: string }) => {
|
|
return (
|
|
<>
|
|
<div className='flex justify-between'>
|
|
<label className='mb-2 block text-sm font-medium text-gray-900 dark:text-gray-300'>{label}</label>
|
|
<CopyToClipboardButton text={text} />
|
|
</div>
|
|
<input
|
|
type='text'
|
|
defaultValue={text}
|
|
key={text}
|
|
readOnly
|
|
className='input-bordered input w-full text-sm'
|
|
/>
|
|
</>
|
|
);
|
|
};
|