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

13 lines
644 B

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