diff --git a/apps/web/src/app/(signing)/sign/[token]/complete/share-button.tsx b/apps/web/src/app/(signing)/sign/[token]/complete/share-button.tsx index c13b8a7ab..b7ecde242 100644 --- a/apps/web/src/app/(signing)/sign/[token]/complete/share-button.tsx +++ b/apps/web/src/app/(signing)/sign/[token]/complete/share-button.tsx @@ -2,10 +2,16 @@ import { HTMLAttributes } from 'react'; -import { Share } from 'lucide-react'; +import { Copy, Share, Twitter } from 'lucide-react'; import { trpc } from '@documenso/trpc/react'; import { Button } from '@documenso/ui/primitives/button'; +import { + DropdownMenu, + DropdownMenuContent, + DropdownMenuItem, + DropdownMenuTrigger, +} from '@documenso/ui/primitives/dropdown-menu'; import { useToast } from '@documenso/ui/primitives/use-toast'; import { useCopyToClipboard } from '~/hooks/use-copy-to-clipboard'; @@ -15,6 +21,12 @@ export type ShareButtonProps = HTMLAttributes & { 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(); @@ -22,7 +34,7 @@ export const ShareButton = ({ token, documentId }: ShareButtonProps) => { const { mutateAsync: createOrGetShareLink, isLoading } = trpc.shareLink.createOrGetShareLink.useMutation(); - const onShareClick = async () => { + const onCopyClick = async () => { const { slug } = await createOrGetShareLink({ token: token, documentId, @@ -36,16 +48,48 @@ export const ShareButton = ({ token, documentId }: ShareButtonProps) => { }); }; + const onTweetClick = async () => { + const { slug } = await createOrGetShareLink({ + token: token, + documentId, + }); + + window.open( + generateTwitterIntent( + 'I just signed a document with @documenso. Check it out!', + `${window.location.origin}/share/${slug}`, + ), + '_blank', + ); + }; + return ( - + + + + + + +
+ + Copy Link +
+
+ +
+ + Tweet +
+
+
+
); }; diff --git a/package-lock.json b/package-lock.json index 451b7c2ec..5cf8c38f8 100644 --- a/package-lock.json +++ b/package-lock.json @@ -19809,6 +19809,7 @@ "@aws-sdk/signature-v4-crt": "^3.410.0", "@documenso/email": "*", "@documenso/prisma": "*", + "@documenso/signing": "*", "@next-auth/prisma-adapter": "1.0.7", "@pdf-lib/fontkit": "^1.1.1", "@scure/base": "^1.1.3", @@ -19862,17 +19863,23 @@ "packages/signing": { "name": "@documenso/signing", "version": "1.0.0", - "license": "MIT", + "license": "AGPLv3", "dependencies": { "@documenso/tsconfig": "*", "node-forge": "^1.3.1", "node-signpdf": "^2.0.0", - "pdf-lib": "^1.17.1" + "pdf-lib": "^1.17.1", + "ts-pattern": "^5.0.5" }, "devDependencies": { "@types/node-forge": "^1.3.4" } }, + "packages/signing/node_modules/ts-pattern": { + "version": "5.0.5", + "resolved": "https://registry.npmjs.org/ts-pattern/-/ts-pattern-5.0.5.tgz", + "integrity": "sha512-tL0w8U/pgaacOmkb9fRlYzWEUDCfVjjv9dD4wHTgZ61MjhuMt46VNWTG747NqW6vRzoWIKABVhFSOJ82FvXrfA==" + }, "packages/tailwind-config": { "name": "@documenso/tailwind-config", "version": "0.0.0",