mirror of
https://github.com/documenso/documenso.git
synced 2025-11-10 04:22:32 +10:00
chore: refactor function
This commit is contained in:
@ -4,6 +4,7 @@ import { HTMLAttributes } from 'react';
|
||||
|
||||
import { Copy, Share, Twitter } from 'lucide-react';
|
||||
|
||||
import { generateTwitterIntent } from '@documenso/lib/universal/generate-twitter-intent';
|
||||
import { trpc } from '@documenso/trpc/react';
|
||||
import { Button } from '@documenso/ui/primitives/button';
|
||||
import {
|
||||
@ -21,12 +22,6 @@ export type ShareButtonProps = HTMLAttributes<HTMLButtonElement> & {
|
||||
documentId: number;
|
||||
};
|
||||
|
||||
const generateTwitterIntent = (text: string, shareUrl: string) => {
|
||||
return `https://twitter.com/intent/tweet?text=${encodeURIComponent(text)}%0A${encodeURIComponent(
|
||||
shareUrl,
|
||||
)}`;
|
||||
};
|
||||
|
||||
export const ShareButton = ({ token, documentId }: ShareButtonProps) => {
|
||||
const { toast } = useToast();
|
||||
const [, copyToClipboard] = useCopyToClipboard();
|
||||
|
||||
5
packages/lib/universal/generate-twitter-intent.ts
Normal file
5
packages/lib/universal/generate-twitter-intent.ts
Normal file
@ -0,0 +1,5 @@
|
||||
export const generateTwitterIntent = (text: string, shareUrl: string) => {
|
||||
return `https://twitter.com/intent/tweet?text=${encodeURIComponent(text)}%0A${encodeURIComponent(
|
||||
shareUrl,
|
||||
)}`;
|
||||
};
|
||||
Reference in New Issue
Block a user