mirror of
https://github.com/documenso/documenso.git
synced 2025-11-20 03:32:14 +10:00
fix: tidy code and update endpoints
This commit is contained in:
@ -88,7 +88,7 @@ export default async function CompletedSigningPage({
|
||||
))}
|
||||
|
||||
<div className="mt-8 flex w-full max-w-sm items-center justify-center gap-4">
|
||||
<ShareButton documentId={document.id} recipientId={recipient.id} />
|
||||
<ShareButton documentId={document.id} token={recipient.token} />
|
||||
|
||||
<DownloadButton
|
||||
className="flex-1"
|
||||
|
||||
@ -10,12 +10,13 @@ import { trpc } from '@documenso/trpc/react';
|
||||
import { Button } from '@documenso/ui/primitives/button';
|
||||
|
||||
export type ShareButtonProps = HTMLAttributes<HTMLButtonElement> & {
|
||||
recipientId: number;
|
||||
token: string;
|
||||
documentId: number;
|
||||
};
|
||||
|
||||
export const ShareButton = ({ recipientId, documentId }: ShareButtonProps) => {
|
||||
const { mutateAsync: createShareId, isLoading } = trpc.share.create.useMutation();
|
||||
export const ShareButton = ({ token, documentId }: ShareButtonProps) => {
|
||||
const { mutateAsync: createOrGetShareLink, isLoading } =
|
||||
trpc.shareLink.createOrGetShareLink.useMutation();
|
||||
|
||||
const router = useRouter();
|
||||
|
||||
@ -23,19 +24,17 @@ export const ShareButton = ({ recipientId, documentId }: ShareButtonProps) => {
|
||||
<Button
|
||||
variant="outline"
|
||||
className="flex-1"
|
||||
disabled={!recipientId || !documentId || isLoading}
|
||||
disabled={!token || !documentId || isLoading}
|
||||
onClick={async () => {
|
||||
console.log('Signing Clicked');
|
||||
|
||||
const response = await createShareId({
|
||||
recipientId,
|
||||
const { slug } = await createOrGetShareLink({
|
||||
token,
|
||||
documentId,
|
||||
});
|
||||
|
||||
console.log('response', response);
|
||||
|
||||
// TODO: Router delaying...
|
||||
return router.push(`/share/${response.link}`);
|
||||
return router.push(`/share/${slug}`);
|
||||
}}
|
||||
>
|
||||
<Share className="mr-2 h-5 w-5" />
|
||||
|
||||
Reference in New Issue
Block a user