mirror of
https://github.com/fallenbagel/jellyseerr.git
synced 2026-01-01 20:28:40 -05:00
* fix(deps): update dependency @heroicons/react to v2 * fix: update imports and fix icon name changes for heroicons * fix: also update MiniStatusBadge to use new check icon * fix: update last place with old import Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: sct <ryan@sct.dev>
41 lines
985 B
TypeScript
41 lines
985 B
TypeScript
import { ClipboardDocumentIcon } from '@heroicons/react/24/solid';
|
|
import { useEffect } from 'react';
|
|
import { defineMessages, useIntl } from 'react-intl';
|
|
import { useToasts } from 'react-toast-notifications';
|
|
import useClipboard from 'react-use-clipboard';
|
|
|
|
const messages = defineMessages({
|
|
copied: 'Copied API key to clipboard.',
|
|
});
|
|
|
|
const CopyButton = ({ textToCopy }: { textToCopy: string }) => {
|
|
const intl = useIntl();
|
|
const [isCopied, setCopied] = useClipboard(textToCopy, {
|
|
successDuration: 1000,
|
|
});
|
|
const { addToast } = useToasts();
|
|
|
|
useEffect(() => {
|
|
if (isCopied) {
|
|
addToast(intl.formatMessage(messages.copied), {
|
|
appearance: 'info',
|
|
autoDismiss: true,
|
|
});
|
|
}
|
|
}, [isCopied, addToast, intl]);
|
|
|
|
return (
|
|
<button
|
|
onClick={(e) => {
|
|
e.preventDefault();
|
|
setCopied();
|
|
}}
|
|
className="input-action"
|
|
>
|
|
<ClipboardDocumentIcon />
|
|
</button>
|
|
);
|
|
};
|
|
|
|
export default CopyButton;
|