chore: enable typed signature by default (#1436)

Enable typed signature by default and also add the option to set a typed
signature in the profile page.
This commit is contained in:
Catalin Pit
2024-11-26 12:03:44 +02:00
committed by GitHub
parent dcb7c2436f
commit ab654a63d8
43 changed files with 1285 additions and 1351 deletions

View File

@ -35,6 +35,7 @@ import {
ZSetSigningOrderForTemplateMutationSchema,
ZToggleTemplateDirectLinkMutationSchema,
ZUpdateTemplateSettingsMutationSchema,
ZUpdateTemplateTypedSignatureSettingsMutationSchema,
} from './schema';
export const templateRouter = router({
@ -359,4 +360,48 @@ export const templateRouter = router({
});
}
}),
updateTemplateTypedSignatureSettings: authenticatedProcedure
.input(ZUpdateTemplateTypedSignatureSettingsMutationSchema)
.mutation(async ({ input, ctx }) => {
try {
const { templateId, teamId, typedSignatureEnabled } = input;
const template = await getTemplateById({
id: templateId,
teamId,
userId: ctx.user.id,
}).catch(() => null);
if (!template) {
throw new TRPCError({
code: 'NOT_FOUND',
message: 'Template not found',
});
}
return await updateTemplateSettings({
templateId,
teamId,
userId: ctx.user.id,
data: {},
meta: {
typedSignatureEnabled,
},
requestMetadata: extractNextApiRequestMetadata(ctx.req),
});
} catch (err) {
console.error(err);
if (err instanceof TRPCError) {
throw err;
}
throw new TRPCError({
code: 'BAD_REQUEST',
message:
'We were unable to update the settings for this template. Please try again later.',
});
}
}),
});