chore: refactor function
This commit is contained in:
committed by
Mythie
parent
127dc42dc5
commit
34ce0d084e
@@ -4,6 +4,7 @@ import { HTMLAttributes } from 'react';
|
|||||||
|
|
||||||
import { Copy, Share, Twitter } from 'lucide-react';
|
import { Copy, Share, Twitter } from 'lucide-react';
|
||||||
|
|
||||||
|
import { generateTwitterIntent } from '@documenso/lib/universal/generate-twitter-intent';
|
||||||
import { trpc } from '@documenso/trpc/react';
|
import { trpc } from '@documenso/trpc/react';
|
||||||
import { Button } from '@documenso/ui/primitives/button';
|
import { Button } from '@documenso/ui/primitives/button';
|
||||||
import {
|
import {
|
||||||
@@ -21,12 +22,6 @@ export type ShareButtonProps = HTMLAttributes<HTMLButtonElement> & {
|
|||||||
documentId: number;
|
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) => {
|
export const ShareButton = ({ token, documentId }: ShareButtonProps) => {
|
||||||
const { toast } = useToast();
|
const { toast } = useToast();
|
||||||
const [, copyToClipboard] = useCopyToClipboard();
|
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