mirror of
https://github.com/documenso/documenso.git
synced 2025-11-13 00:03:33 +10:00
Enable typed signature by default and also add the option to set a typed signature in the profile page.
65 lines
1.5 KiB
TypeScript
65 lines
1.5 KiB
TypeScript
import { prisma } from '@documenso/prisma';
|
|
import type { DocumentVisibility } from '@documenso/prisma/client';
|
|
import { TeamMemberRole } from '@documenso/prisma/client';
|
|
|
|
import type { SupportedLanguageCodes } from '../../constants/i18n';
|
|
|
|
export type UpdateTeamDocumentSettingsOptions = {
|
|
userId: number;
|
|
teamId: number;
|
|
|
|
settings: {
|
|
documentVisibility: DocumentVisibility;
|
|
documentLanguage: SupportedLanguageCodes;
|
|
includeSenderDetails: boolean;
|
|
typedSignatureEnabled: boolean;
|
|
includeSigningCertificate: boolean;
|
|
};
|
|
};
|
|
|
|
export const updateTeamDocumentSettings = async ({
|
|
userId,
|
|
teamId,
|
|
settings,
|
|
}: UpdateTeamDocumentSettingsOptions) => {
|
|
const {
|
|
documentVisibility,
|
|
documentLanguage,
|
|
includeSenderDetails,
|
|
includeSigningCertificate,
|
|
typedSignatureEnabled,
|
|
} = settings;
|
|
|
|
const member = await prisma.teamMember.findFirst({
|
|
where: {
|
|
userId,
|
|
teamId,
|
|
},
|
|
});
|
|
|
|
if (!member || member.role !== TeamMemberRole.ADMIN) {
|
|
throw new Error('You do not have permission to update this team.');
|
|
}
|
|
|
|
return await prisma.teamGlobalSettings.upsert({
|
|
where: {
|
|
teamId,
|
|
},
|
|
create: {
|
|
teamId,
|
|
documentVisibility,
|
|
documentLanguage,
|
|
includeSenderDetails,
|
|
typedSignatureEnabled,
|
|
includeSigningCertificate,
|
|
},
|
|
update: {
|
|
documentVisibility,
|
|
documentLanguage,
|
|
includeSenderDetails,
|
|
typedSignatureEnabled,
|
|
includeSigningCertificate,
|
|
},
|
|
});
|
|
};
|