documenso/packages/lib/server-only/admin/update-recipient.ts
Lucas Smith af346b179c
feat: add recipient role editing and audit log PDF download in admin (#2594)
- Allow admins to update recipient role from document detail page
- Add download button to export audit logs as PDF
- Display recipient status details in accordion
- Add LocalTime component with hover popover for timestamps
2026-03-10 21:41:46 +11:00

33 lines
730 B
TypeScript

import { type RecipientRole, SigningStatus } from '@prisma/client';
import { prisma } from '@documenso/prisma';
export type UpdateRecipientOptions = {
id: number;
name: string | undefined;
email: string | undefined;
role: RecipientRole | undefined;
};
export const updateRecipient = async ({ id, name, email, role }: UpdateRecipientOptions) => {
const recipient = await prisma.recipient.findFirstOrThrow({
where: {
id,
},
});
if (recipient.signingStatus === SigningStatus.SIGNED) {
throw new Error('Cannot update a recipient that has already signed.');
}
return await prisma.recipient.update({
where: {
id,
},
data: {
name,
email,
role,
},
});
};