The communications platform that puts data protection first.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
Rocket.Chat/apps/meteor/client/hooks/useClipboardWithToast.ts

14 lines
676 B

import type { UseClipboardReturn } from '@rocket.chat/fuselage-hooks';
import { useClipboard, useEffectEvent } from '@rocket.chat/fuselage-hooks';
import { useToastMessageDispatch } from '@rocket.chat/ui-contexts';
import { useTranslation } from 'react-i18next';
export default function useClipboardWithToast(text: string): UseClipboardReturn {
const { t } = useTranslation();
const dispatchToastMessage = useToastMessageDispatch();
return useClipboard(text, {
onCopySuccess: useEffectEvent(() => dispatchToastMessage({ type: 'success', message: t('Copied') })),
onCopyError: useEffectEvent((e?: Error) => dispatchToastMessage({ type: 'error', message: e })),
});
}