mirror of
https://github.com/documenso/documenso.git
synced 2025-11-19 03:01:59 +10:00
Compare commits
6 Commits
feat/impro
...
fix/downlo
| Author | SHA1 | Date | |
|---|---|---|---|
| ffef52565a | |||
| 86fb6de9c3 | |||
| b93b0aae64 | |||
| 7080a36f21 | |||
| 2ae94b1e55 | |||
| 4bb50487e7 |
@ -6,7 +6,7 @@ import { useLingui } from '@lingui/react';
|
|||||||
import { Trans } from '@lingui/react/macro';
|
import { Trans } from '@lingui/react/macro';
|
||||||
import { type Recipient, SigningStatus } from '@prisma/client';
|
import { type Recipient, SigningStatus } from '@prisma/client';
|
||||||
import { History } from 'lucide-react';
|
import { History } from 'lucide-react';
|
||||||
import { useForm, useWatch } from 'react-hook-form';
|
import { useForm } from 'react-hook-form';
|
||||||
import * as z from 'zod';
|
import * as z from 'zod';
|
||||||
|
|
||||||
import { useSession } from '@documenso/lib/client-only/providers/session';
|
import { useSession } from '@documenso/lib/client-only/providers/session';
|
||||||
@ -85,11 +85,6 @@ export const DocumentResendDialog = ({ document, recipients }: DocumentResendDia
|
|||||||
formState: { isSubmitting },
|
formState: { isSubmitting },
|
||||||
} = form;
|
} = form;
|
||||||
|
|
||||||
const selectedRecipients = useWatch({
|
|
||||||
control: form.control,
|
|
||||||
name: 'recipients',
|
|
||||||
});
|
|
||||||
|
|
||||||
const onFormSubmit = async ({ recipients }: TResendDocumentFormSchema) => {
|
const onFormSubmit = async ({ recipients }: TResendDocumentFormSchema) => {
|
||||||
try {
|
try {
|
||||||
await resendDocument({ documentId: document.id, recipients });
|
await resendDocument({ documentId: document.id, recipients });
|
||||||
@ -156,7 +151,7 @@ export const DocumentResendDialog = ({ document, recipients }: DocumentResendDia
|
|||||||
|
|
||||||
<FormControl>
|
<FormControl>
|
||||||
<Checkbox
|
<Checkbox
|
||||||
className="h-5 w-5 rounded-full border border-neutral-400"
|
className="h-5 w-5 rounded-full"
|
||||||
value={recipient.id}
|
value={recipient.id}
|
||||||
checked={value.includes(recipient.id)}
|
checked={value.includes(recipient.id)}
|
||||||
onCheckedChange={(checked: boolean) =>
|
onCheckedChange={(checked: boolean) =>
|
||||||
@ -187,13 +182,7 @@ export const DocumentResendDialog = ({ document, recipients }: DocumentResendDia
|
|||||||
</Button>
|
</Button>
|
||||||
</DialogClose>
|
</DialogClose>
|
||||||
|
|
||||||
<Button
|
<Button className="flex-1" loading={isSubmitting} type="submit" form={FORM_ID}>
|
||||||
className="flex-1"
|
|
||||||
loading={isSubmitting}
|
|
||||||
type="submit"
|
|
||||||
form={FORM_ID}
|
|
||||||
disabled={isSubmitting || selectedRecipients.length === 0}
|
|
||||||
>
|
|
||||||
<Trans>Send reminder</Trans>
|
<Trans>Send reminder</Trans>
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -160,14 +160,6 @@ export const DocumentSigningPageView = ({
|
|||||||
return (
|
return (
|
||||||
<DocumentSigningRecipientProvider recipient={recipient} targetSigner={targetSigner}>
|
<DocumentSigningRecipientProvider recipient={recipient} targetSigner={targetSigner}>
|
||||||
<div className="mx-auto w-full max-w-screen-xl sm:px-6">
|
<div className="mx-auto w-full max-w-screen-xl sm:px-6">
|
||||||
{document.team.teamGlobalSettings.brandingEnabled &&
|
|
||||||
document.team.teamGlobalSettings.brandingLogo && (
|
|
||||||
<img
|
|
||||||
src={`/api/branding/logo/team/${document.teamId}`}
|
|
||||||
alt={`${document.team.name}'s Logo`}
|
|
||||||
className="mb-4 h-12 w-12 md:mb-2"
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
<h1
|
<h1
|
||||||
className="block max-w-[20rem] truncate text-2xl font-semibold sm:mt-4 md:max-w-[30rem] md:text-3xl"
|
className="block max-w-[20rem] truncate text-2xl font-semibold sm:mt-4 md:max-w-[30rem] md:text-3xl"
|
||||||
title={document.title}
|
title={document.title}
|
||||||
|
|||||||
@ -1,13 +1,16 @@
|
|||||||
|
import { useState } from 'react';
|
||||||
|
|
||||||
import { msg } from '@lingui/core/macro';
|
import { msg } from '@lingui/core/macro';
|
||||||
import { useLingui } from '@lingui/react';
|
import { useLingui } from '@lingui/react';
|
||||||
import { Trans } from '@lingui/react/macro';
|
import { Trans } from '@lingui/react/macro';
|
||||||
import { DownloadIcon } from 'lucide-react';
|
import { DownloadIcon } from 'lucide-react';
|
||||||
|
|
||||||
import { trpc } from '@documenso/trpc/react';
|
|
||||||
import { cn } from '@documenso/ui/lib/utils';
|
import { cn } from '@documenso/ui/lib/utils';
|
||||||
import { Button } from '@documenso/ui/primitives/button';
|
import { Button } from '@documenso/ui/primitives/button';
|
||||||
import { useToast } from '@documenso/ui/primitives/use-toast';
|
import { useToast } from '@documenso/ui/primitives/use-toast';
|
||||||
|
|
||||||
|
import { useCurrentTeam } from '~/providers/team';
|
||||||
|
|
||||||
export type DocumentAuditLogDownloadButtonProps = {
|
export type DocumentAuditLogDownloadButtonProps = {
|
||||||
className?: string;
|
className?: string;
|
||||||
documentId: number;
|
documentId: number;
|
||||||
@ -19,44 +22,38 @@ export const DocumentAuditLogDownloadButton = ({
|
|||||||
}: DocumentAuditLogDownloadButtonProps) => {
|
}: DocumentAuditLogDownloadButtonProps) => {
|
||||||
const { toast } = useToast();
|
const { toast } = useToast();
|
||||||
const { _ } = useLingui();
|
const { _ } = useLingui();
|
||||||
|
const [isPending, setIsPending] = useState(false);
|
||||||
const { mutateAsync: downloadAuditLogs, isPending } =
|
const team = useCurrentTeam();
|
||||||
trpc.document.auditLog.download.useMutation();
|
|
||||||
|
|
||||||
const onDownloadAuditLogsClick = async () => {
|
const onDownloadAuditLogsClick = async () => {
|
||||||
|
setIsPending(true);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const { url } = await downloadAuditLogs({ documentId });
|
const response = await fetch(`/api/t/${team.url}/download/audit-logs/${documentId}`);
|
||||||
|
|
||||||
const iframe = Object.assign(document.createElement('iframe'), {
|
if (!response.ok) {
|
||||||
src: url,
|
throw new Error('Failed to download certificate');
|
||||||
});
|
|
||||||
|
|
||||||
Object.assign(iframe.style, {
|
|
||||||
position: 'fixed',
|
|
||||||
top: '0',
|
|
||||||
left: '0',
|
|
||||||
width: '0',
|
|
||||||
height: '0',
|
|
||||||
});
|
|
||||||
|
|
||||||
const onLoaded = () => {
|
|
||||||
if (iframe.contentDocument?.readyState === 'complete') {
|
|
||||||
iframe.contentWindow?.print();
|
|
||||||
|
|
||||||
iframe.contentWindow?.addEventListener('afterprint', () => {
|
|
||||||
document.body.removeChild(iframe);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
};
|
|
||||||
|
|
||||||
// When the iframe has loaded, print the iframe and remove it from the dom
|
const contentDisposition = response.headers.get('Content-Disposition');
|
||||||
iframe.addEventListener('load', onLoaded);
|
const filename =
|
||||||
|
contentDisposition?.split('filename="')[1]?.split('"')[0] ||
|
||||||
|
`document_${documentId}_audit_logs.pdf`;
|
||||||
|
|
||||||
document.body.appendChild(iframe);
|
const blob = await response.blob();
|
||||||
|
const url = URL.createObjectURL(blob);
|
||||||
|
const link = document.createElement('a');
|
||||||
|
|
||||||
onLoaded();
|
link.href = url;
|
||||||
|
link.download = filename;
|
||||||
|
|
||||||
|
document.body.appendChild(link);
|
||||||
|
link.click();
|
||||||
|
|
||||||
|
document.body.removeChild(link);
|
||||||
|
URL.revokeObjectURL(url);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(error);
|
console.error('Audit logs download error:', error);
|
||||||
|
|
||||||
toast({
|
toast({
|
||||||
title: _(msg`Something went wrong`),
|
title: _(msg`Something went wrong`),
|
||||||
@ -65,6 +62,8 @@ export const DocumentAuditLogDownloadButton = ({
|
|||||||
),
|
),
|
||||||
variant: 'destructive',
|
variant: 'destructive',
|
||||||
});
|
});
|
||||||
|
} finally {
|
||||||
|
setIsPending(false);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -1,3 +1,5 @@
|
|||||||
|
import { useState } from 'react';
|
||||||
|
|
||||||
import { msg } from '@lingui/core/macro';
|
import { msg } from '@lingui/core/macro';
|
||||||
import { useLingui } from '@lingui/react';
|
import { useLingui } from '@lingui/react';
|
||||||
import { Trans } from '@lingui/react/macro';
|
import { Trans } from '@lingui/react/macro';
|
||||||
@ -5,11 +7,12 @@ import type { DocumentStatus } from '@prisma/client';
|
|||||||
import { DownloadIcon } from 'lucide-react';
|
import { DownloadIcon } from 'lucide-react';
|
||||||
|
|
||||||
import { isDocumentCompleted } from '@documenso/lib/utils/document';
|
import { isDocumentCompleted } from '@documenso/lib/utils/document';
|
||||||
import { trpc } from '@documenso/trpc/react';
|
|
||||||
import { cn } from '@documenso/ui/lib/utils';
|
import { cn } from '@documenso/ui/lib/utils';
|
||||||
import { Button } from '@documenso/ui/primitives/button';
|
import { Button } from '@documenso/ui/primitives/button';
|
||||||
import { useToast } from '@documenso/ui/primitives/use-toast';
|
import { useToast } from '@documenso/ui/primitives/use-toast';
|
||||||
|
|
||||||
|
import { useCurrentTeam } from '~/providers/team';
|
||||||
|
|
||||||
export type DocumentCertificateDownloadButtonProps = {
|
export type DocumentCertificateDownloadButtonProps = {
|
||||||
className?: string;
|
className?: string;
|
||||||
documentId: number;
|
documentId: number;
|
||||||
@ -23,44 +26,38 @@ export const DocumentCertificateDownloadButton = ({
|
|||||||
}: DocumentCertificateDownloadButtonProps) => {
|
}: DocumentCertificateDownloadButtonProps) => {
|
||||||
const { toast } = useToast();
|
const { toast } = useToast();
|
||||||
const { _ } = useLingui();
|
const { _ } = useLingui();
|
||||||
|
const [isPending, setIsPending] = useState(false);
|
||||||
const { mutateAsync: downloadCertificate, isPending } =
|
const team = useCurrentTeam();
|
||||||
trpc.document.downloadCertificate.useMutation();
|
|
||||||
|
|
||||||
const onDownloadCertificatesClick = async () => {
|
const onDownloadCertificatesClick = async () => {
|
||||||
|
setIsPending(true);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const { url } = await downloadCertificate({ documentId });
|
const response = await fetch(`/api/t/${team.url}/download/certificate/${documentId}`);
|
||||||
|
|
||||||
const iframe = Object.assign(document.createElement('iframe'), {
|
if (!response.ok) {
|
||||||
src: url,
|
throw new Error('Failed to download certificate');
|
||||||
});
|
|
||||||
|
|
||||||
Object.assign(iframe.style, {
|
|
||||||
position: 'fixed',
|
|
||||||
top: '0',
|
|
||||||
left: '0',
|
|
||||||
width: '0',
|
|
||||||
height: '0',
|
|
||||||
});
|
|
||||||
|
|
||||||
const onLoaded = () => {
|
|
||||||
if (iframe.contentDocument?.readyState === 'complete') {
|
|
||||||
iframe.contentWindow?.print();
|
|
||||||
|
|
||||||
iframe.contentWindow?.addEventListener('afterprint', () => {
|
|
||||||
document.body.removeChild(iframe);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
};
|
|
||||||
|
|
||||||
// When the iframe has loaded, print the iframe and remove it from the dom
|
const contentDisposition = response.headers.get('Content-Disposition');
|
||||||
iframe.addEventListener('load', onLoaded);
|
const filename =
|
||||||
|
contentDisposition?.split('filename="')[1]?.split('"')[0] ||
|
||||||
|
`document_${documentId}_certificate.pdf`;
|
||||||
|
|
||||||
document.body.appendChild(iframe);
|
const blob = await response.blob();
|
||||||
|
const url = URL.createObjectURL(blob);
|
||||||
|
const link = document.createElement('a');
|
||||||
|
|
||||||
onLoaded();
|
link.href = url;
|
||||||
|
link.download = filename;
|
||||||
|
|
||||||
|
document.body.appendChild(link);
|
||||||
|
link.click();
|
||||||
|
|
||||||
|
document.body.removeChild(link);
|
||||||
|
URL.revokeObjectURL(url);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(error);
|
console.error('Certificate download error:', error);
|
||||||
|
|
||||||
toast({
|
toast({
|
||||||
title: _(msg`Something went wrong`),
|
title: _(msg`Something went wrong`),
|
||||||
@ -69,6 +66,8 @@ export const DocumentCertificateDownloadButton = ({
|
|||||||
),
|
),
|
||||||
variant: 'destructive',
|
variant: 'destructive',
|
||||||
});
|
});
|
||||||
|
} finally {
|
||||||
|
setIsPending(false);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -23,12 +23,10 @@ export const loader = async () => {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
const certStatus = getCertificateStatus();
|
const certStatus = getCertificateStatus();
|
||||||
|
|
||||||
if (certStatus.isAvailable) {
|
if (certStatus.isAvailable) {
|
||||||
checks.certificate = { status: 'ok' };
|
checks.certificate = { status: 'ok' };
|
||||||
} else {
|
} else {
|
||||||
checks.certificate = { status: 'warning' };
|
checks.certificate = { status: 'warning' };
|
||||||
|
|
||||||
if (overallStatus === 'ok') {
|
if (overallStatus === 'ok') {
|
||||||
overallStatus = 'warning';
|
overallStatus = 'warning';
|
||||||
}
|
}
|
||||||
|
|||||||
@ -0,0 +1,61 @@
|
|||||||
|
import { getSession } from '@documenso/auth/server/lib/utils/get-session';
|
||||||
|
import { AppError, AppErrorCode } from '@documenso/lib/errors/app-error';
|
||||||
|
import { getDocumentById } from '@documenso/lib/server-only/document/get-document-by-id';
|
||||||
|
import { getAuditLogsPdf } from '@documenso/lib/server-only/htmltopdf/get-audit-logs-pdf';
|
||||||
|
import { getTeamByUrl } from '@documenso/lib/server-only/team/get-team';
|
||||||
|
|
||||||
|
import type { Route } from './+types/t.$teamUrl.download.audit-logs.$documentId';
|
||||||
|
|
||||||
|
export async function loader({ request, params }: Route.LoaderArgs) {
|
||||||
|
const documentId = Number(params.documentId);
|
||||||
|
const teamUrl = params.teamUrl;
|
||||||
|
|
||||||
|
if (!documentId || !teamUrl) {
|
||||||
|
return Response.json({ error: 'Invalid document ID or team URL' }, { status: 400 });
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
const { user } = await getSession(request);
|
||||||
|
|
||||||
|
const team = await getTeamByUrl({ userId: user.id, teamUrl });
|
||||||
|
|
||||||
|
if (!team) {
|
||||||
|
return Response.json({ error: 'Team not found or access denied' }, { status: 404 });
|
||||||
|
}
|
||||||
|
|
||||||
|
const document = await getDocumentById({
|
||||||
|
documentId,
|
||||||
|
userId: user.id,
|
||||||
|
teamId: team.id,
|
||||||
|
}).catch(() => null);
|
||||||
|
|
||||||
|
if (!document || (team.id && document.teamId !== team.id)) {
|
||||||
|
return Response.json({ error: 'Document not found or access denied' }, { status: 404 });
|
||||||
|
}
|
||||||
|
|
||||||
|
const pdfBuffer = await getAuditLogsPdf({
|
||||||
|
documentId: document.id,
|
||||||
|
language: document.documentMeta?.language,
|
||||||
|
});
|
||||||
|
|
||||||
|
const filename = `${document.title.replace(/\.pdf$/, '')}_audit_logs.pdf`;
|
||||||
|
|
||||||
|
return new Response(pdfBuffer, {
|
||||||
|
headers: {
|
||||||
|
'Content-Type': 'application/pdf',
|
||||||
|
'Content-Disposition': `attachment; filename="${filename}"`,
|
||||||
|
'Content-Length': pdfBuffer.length.toString(),
|
||||||
|
'Cache-Control': 'no-cache, no-store, must-revalidate',
|
||||||
|
Expires: '0',
|
||||||
|
},
|
||||||
|
});
|
||||||
|
} catch (error) {
|
||||||
|
if (error instanceof AppError) {
|
||||||
|
const statusCode = error.code === AppErrorCode.UNAUTHORIZED ? 401 : 400;
|
||||||
|
|
||||||
|
return Response.json({ error: error.message }, { status: statusCode });
|
||||||
|
}
|
||||||
|
|
||||||
|
return Response.json({ error: 'Failed to generate audit logs PDF' }, { status: 500 });
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,69 @@
|
|||||||
|
import { getSession } from '@documenso/auth/server/lib/utils/get-session';
|
||||||
|
import { AppError, AppErrorCode } from '@documenso/lib/errors/app-error';
|
||||||
|
import { getDocumentById } from '@documenso/lib/server-only/document/get-document-by-id';
|
||||||
|
import { getCertificatePdf } from '@documenso/lib/server-only/htmltopdf/get-certificate-pdf';
|
||||||
|
import { getTeamByUrl } from '@documenso/lib/server-only/team/get-team';
|
||||||
|
import { isDocumentCompleted } from '@documenso/lib/utils/document';
|
||||||
|
|
||||||
|
import type { Route } from './+types/t.$teamUrl.download.certificate.$documentId';
|
||||||
|
|
||||||
|
export async function loader({ request, params }: Route.LoaderArgs) {
|
||||||
|
const documentId = Number(params.documentId);
|
||||||
|
const teamUrl = params.teamUrl;
|
||||||
|
|
||||||
|
if (!documentId || !teamUrl) {
|
||||||
|
return Response.json({ error: 'Invalid document ID or team URL' }, { status: 400 });
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
const { user } = await getSession(request);
|
||||||
|
|
||||||
|
const team = await getTeamByUrl({ userId: user.id, teamUrl }).catch(() => null);
|
||||||
|
|
||||||
|
if (!team) {
|
||||||
|
return Response.json({ error: 'Team not found or access denied' }, { status: 404 });
|
||||||
|
}
|
||||||
|
|
||||||
|
const document = await getDocumentById({
|
||||||
|
documentId,
|
||||||
|
userId: user.id,
|
||||||
|
teamId: team.id,
|
||||||
|
}).catch(() => null);
|
||||||
|
|
||||||
|
if (!document || document.teamId !== team.id) {
|
||||||
|
return Response.json({ error: 'Document not found or access denied' }, { status: 404 });
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!isDocumentCompleted(document.status)) {
|
||||||
|
return Response.json(
|
||||||
|
{ error: 'Document must be completed to download the certificate' },
|
||||||
|
{ status: 400 },
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const pdfBuffer = await getCertificatePdf({
|
||||||
|
documentId: document.id,
|
||||||
|
language: document.documentMeta?.language,
|
||||||
|
});
|
||||||
|
|
||||||
|
const filename = `${document.title.replace(/\.pdf$/, '')}_certificate.pdf`;
|
||||||
|
|
||||||
|
return new Response(pdfBuffer, {
|
||||||
|
headers: {
|
||||||
|
'Content-Type': 'application/pdf',
|
||||||
|
'Content-Disposition': `attachment; filename="${filename}"`,
|
||||||
|
'Content-Length': pdfBuffer.length.toString(),
|
||||||
|
'Cache-Control': 'no-cache, no-store, must-revalidate',
|
||||||
|
Expires: '0',
|
||||||
|
},
|
||||||
|
});
|
||||||
|
} catch (error) {
|
||||||
|
if (error instanceof AppError) {
|
||||||
|
const statusCode = error.code === AppErrorCode.UNAUTHORIZED ? 401 : 400;
|
||||||
|
|
||||||
|
return Response.json({ error: error.message }, { status: statusCode });
|
||||||
|
}
|
||||||
|
|
||||||
|
return Response.json({ error: 'Failed to generate certificate PDF' }, { status: 500 });
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -101,5 +101,5 @@
|
|||||||
"vite-plugin-babel-macros": "^1.0.6",
|
"vite-plugin-babel-macros": "^1.0.6",
|
||||||
"vite-tsconfig-paths": "^5.1.4"
|
"vite-tsconfig-paths": "^5.1.4"
|
||||||
},
|
},
|
||||||
"version": "1.12.4"
|
"version": "1.12.2-rc.6"
|
||||||
}
|
}
|
||||||
|
|||||||
6
package-lock.json
generated
6
package-lock.json
generated
@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "@documenso/root",
|
"name": "@documenso/root",
|
||||||
"version": "1.12.4",
|
"version": "1.12.2-rc.6",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "@documenso/root",
|
"name": "@documenso/root",
|
||||||
"version": "1.12.4",
|
"version": "1.12.2-rc.6",
|
||||||
"workspaces": [
|
"workspaces": [
|
||||||
"apps/*",
|
"apps/*",
|
||||||
"packages/*"
|
"packages/*"
|
||||||
@ -89,7 +89,7 @@
|
|||||||
},
|
},
|
||||||
"apps/remix": {
|
"apps/remix": {
|
||||||
"name": "@documenso/remix",
|
"name": "@documenso/remix",
|
||||||
"version": "1.12.4",
|
"version": "1.12.2-rc.6",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@documenso/api": "*",
|
"@documenso/api": "*",
|
||||||
"@documenso/assets": "*",
|
"@documenso/assets": "*",
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"private": true,
|
"private": true,
|
||||||
"version": "1.12.4",
|
"version": "1.12.2-rc.6",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "turbo run build",
|
"build": "turbo run build",
|
||||||
"dev": "turbo run dev --filter=@documenso/remix",
|
"dev": "turbo run dev --filter=@documenso/remix",
|
||||||
|
|||||||
@ -2,25 +2,18 @@ import * as fs from 'node:fs';
|
|||||||
|
|
||||||
import { env } from '@documenso/lib/utils/env';
|
import { env } from '@documenso/lib/utils/env';
|
||||||
|
|
||||||
export const getCertificateStatus = () => {
|
export type CertificateStatus = {
|
||||||
if (env('NEXT_PRIVATE_SIGNING_TRANSPORT') !== 'local') {
|
isAvailable: boolean;
|
||||||
return { isAvailable: true };
|
};
|
||||||
}
|
|
||||||
|
|
||||||
if (env('NEXT_PRIVATE_SIGNING_LOCAL_FILE_CONTENTS')) {
|
|
||||||
return { isAvailable: true };
|
|
||||||
}
|
|
||||||
|
|
||||||
|
export const getCertificateStatus = (): CertificateStatus => {
|
||||||
const defaultPath =
|
const defaultPath =
|
||||||
env('NODE_ENV') === 'production' ? '/opt/documenso/cert.p12' : './example/cert.p12';
|
env('NODE_ENV') === 'production' ? '/opt/documenso/cert.p12' : './example/cert.p12';
|
||||||
|
|
||||||
const filePath = env('NEXT_PRIVATE_SIGNING_LOCAL_FILE_PATH') || defaultPath;
|
const filePath = env('NEXT_PRIVATE_SIGNING_LOCAL_FILE_PATH') || defaultPath;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
fs.accessSync(filePath, fs.constants.F_OK | fs.constants.R_OK);
|
fs.accessSync(filePath, fs.constants.F_OK | fs.constants.R_OK);
|
||||||
|
|
||||||
const stats = fs.statSync(filePath);
|
const stats = fs.statSync(filePath);
|
||||||
|
|
||||||
return { isAvailable: stats.size > 0 };
|
return { isAvailable: stats.size > 0 };
|
||||||
} catch {
|
} catch {
|
||||||
return { isAvailable: false };
|
return { isAvailable: false };
|
||||||
|
|||||||
@ -91,12 +91,6 @@ export const getDocumentAndSenderByToken = async ({
|
|||||||
select: {
|
select: {
|
||||||
name: true,
|
name: true,
|
||||||
teamEmail: true,
|
teamEmail: true,
|
||||||
teamGlobalSettings: {
|
|
||||||
select: {
|
|
||||||
brandingEnabled: true,
|
|
||||||
brandingLogo: true,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
@ -714,6 +714,7 @@ export const AddSignersFormPartial = ({
|
|||||||
handleRecipientAutoCompleteSelect(index, suggestion)
|
handleRecipientAutoCompleteSelect(index, suggestion)
|
||||||
}
|
}
|
||||||
onSearchQueryChange={(query) => {
|
onSearchQueryChange={(query) => {
|
||||||
|
console.log('onSearchQueryChange', query);
|
||||||
field.onChange(query);
|
field.onChange(query);
|
||||||
setRecipientSearchQuery(query);
|
setRecipientSearchQuery(query);
|
||||||
}}
|
}}
|
||||||
|
|||||||
Reference in New Issue
Block a user