From 66dfdc5ad09e1158ca2ecca90307403e1e701183 Mon Sep 17 00:00:00 2001 From: Ephraim Atta-Duncan Date: Tue, 29 Aug 2023 19:42:37 +0000 Subject: [PATCH] feat: redirect share page to marketing page after 3 seconds --- apps/web/src/app/(share)/share/[shareId]/page.tsx | 3 +++ .../src/app/(share)/share/[shareId]/redirect.tsx | 14 ++++++++++++++ .../sign/[token]/complete/share-button.tsx | 10 +++++++--- 3 files changed, 24 insertions(+), 3 deletions(-) create mode 100644 apps/web/src/app/(share)/share/[shareId]/redirect.tsx diff --git a/apps/web/src/app/(share)/share/[shareId]/page.tsx b/apps/web/src/app/(share)/share/[shareId]/page.tsx index 6d6b2c436..69e40f6a2 100644 --- a/apps/web/src/app/(share)/share/[shareId]/page.tsx +++ b/apps/web/src/app/(share)/share/[shareId]/page.tsx @@ -5,6 +5,8 @@ import { notFound } from 'next/navigation'; import { getSharingId } from '@documenso/lib/server-only/share/get-share-id'; +import Redirect from './redirect'; + type MetadataProps = { params: { shareId: string }; }; @@ -43,6 +45,7 @@ export default async function SharePage({ params: { shareId } }: SharePageProps)

Share Page

Redirecting...

+
); } diff --git a/apps/web/src/app/(share)/share/[shareId]/redirect.tsx b/apps/web/src/app/(share)/share/[shareId]/redirect.tsx new file mode 100644 index 000000000..593d5b1cc --- /dev/null +++ b/apps/web/src/app/(share)/share/[shareId]/redirect.tsx @@ -0,0 +1,14 @@ +'use client'; + +import React from 'react'; + +export default function Redirect() { + React.useEffect(() => { + const timer = setTimeout(() => { + window.location.href = 'https://www.documenso.com'; + }, 3000); + return () => clearTimeout(timer); + }, []); + + return
; +} 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 182a7a805..e9dedcfe9 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 @@ -15,7 +15,7 @@ export type ShareButtonProps = HTMLAttributes & { }; export const ShareButton = ({ recipientId, documentId }: ShareButtonProps) => { - const { mutateAsync: createShareId } = trpc.share.create.useMutation(); + const { mutateAsync: createShareId, isLoading } = trpc.share.create.useMutation(); const router = useRouter(); @@ -23,14 +23,18 @@ export const ShareButton = ({ recipientId, documentId }: ShareButtonProps) => {