feat: redirect share page to marketing page after 3 seconds

This commit is contained in:
Ephraim Atta-Duncan
2023-08-29 19:42:37 +00:00
committed by Mythie
parent f2da49d0e8
commit b12f5b62f1
3 changed files with 24 additions and 3 deletions

View File

@ -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)
<div className="flex h-screen flex-col items-center justify-center">
<h1 className="my-2 text-4xl font-semibold">Share Page</h1>
<p className="my-2 text-xl">Redirecting...</p>
<Redirect />
</div>
);
}

View File

@ -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 <div></div>;
}

View File

@ -15,7 +15,7 @@ export type ShareButtonProps = HTMLAttributes<HTMLButtonElement> & {
};
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) => {
<Button
variant="outline"
className="flex-1"
disabled={!recipientId || !documentId || isLoading}
onClick={async () => {
// redirect to the share page
// create link once and dont allow a user to create the link
console.log('Signing Clicked');
const response = await createShareId({
recipientId,
documentId,
});
console.log('response', response);
// TODO: Router delaying...
return router.push(`/share/${response.link}`);
}}
>