mirror of
https://github.com/documenso/documenso.git
synced 2025-11-17 18:21:32 +10:00
feat: redirect share page to marketing page after 3 seconds
This commit is contained in:
@ -5,6 +5,8 @@ import { notFound } from 'next/navigation';
|
|||||||
|
|
||||||
import { getSharingId } from '@documenso/lib/server-only/share/get-share-id';
|
import { getSharingId } from '@documenso/lib/server-only/share/get-share-id';
|
||||||
|
|
||||||
|
import Redirect from './redirect';
|
||||||
|
|
||||||
type MetadataProps = {
|
type MetadataProps = {
|
||||||
params: { shareId: string };
|
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">
|
<div className="flex h-screen flex-col items-center justify-center">
|
||||||
<h1 className="my-2 text-4xl font-semibold">Share Page</h1>
|
<h1 className="my-2 text-4xl font-semibold">Share Page</h1>
|
||||||
<p className="my-2 text-xl">Redirecting...</p>
|
<p className="my-2 text-xl">Redirecting...</p>
|
||||||
|
<Redirect />
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
14
apps/web/src/app/(share)/share/[shareId]/redirect.tsx
Normal file
14
apps/web/src/app/(share)/share/[shareId]/redirect.tsx
Normal 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>;
|
||||||
|
}
|
||||||
@ -15,7 +15,7 @@ export type ShareButtonProps = HTMLAttributes<HTMLButtonElement> & {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const ShareButton = ({ recipientId, documentId }: ShareButtonProps) => {
|
export const ShareButton = ({ recipientId, documentId }: ShareButtonProps) => {
|
||||||
const { mutateAsync: createShareId } = trpc.share.create.useMutation();
|
const { mutateAsync: createShareId, isLoading } = trpc.share.create.useMutation();
|
||||||
|
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
|
|
||||||
@ -23,14 +23,18 @@ export const ShareButton = ({ recipientId, documentId }: ShareButtonProps) => {
|
|||||||
<Button
|
<Button
|
||||||
variant="outline"
|
variant="outline"
|
||||||
className="flex-1"
|
className="flex-1"
|
||||||
|
disabled={!recipientId || !documentId || isLoading}
|
||||||
onClick={async () => {
|
onClick={async () => {
|
||||||
// redirect to the share page
|
console.log('Signing Clicked');
|
||||||
// create link once and dont allow a user to create the link
|
|
||||||
const response = await createShareId({
|
const response = await createShareId({
|
||||||
recipientId,
|
recipientId,
|
||||||
documentId,
|
documentId,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
console.log('response', response);
|
||||||
|
|
||||||
|
// TODO: Router delaying...
|
||||||
return router.push(`/share/${response.link}`);
|
return router.push(`/share/${response.link}`);
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
|
|||||||
Reference in New Issue
Block a user