fix: allow note only in edit mode

This commit is contained in:
Manuel
2023-08-12 23:23:04 +02:00
parent 7ce09af5a8
commit b2cbb1a388

View File

@@ -12,13 +12,20 @@ export const notebookRouter = createTRPCRouter({
update: publicProcedure
.input(z.object({ widgetId: z.string(), content: z.string(), configName: z.string() }))
.mutation(async ({ input }) => {
if (!process.env.DISABLE_EDIT_MODE) {
throw new TRPCError({
code: 'METHOD_NOT_SUPPORTED',
message: 'Edit is not allowed, because edit mode is disabled'
});
}
const config = getConfig(input.configName);
const widget = config.widgets.find((widget) => widget.id === input.widgetId) as
| INotebookWidget
| undefined;
if (!widget) {
return new TRPCError({
throw new TRPCError({
code: 'BAD_REQUEST',
message: 'Specified widget was not found',
});