fix: updates from review

This commit is contained in:
Mythie
2023-12-21 20:42:45 +11:00
parent 298396c86c
commit 7babd82470
10 changed files with 37 additions and 20 deletions

View File

@ -19,10 +19,11 @@ export const getRecipientsStats = async () => {
results.forEach((result) => {
const { readStatus, signingStatus, sendStatus, _count } = result;
stats[readStatus as keyof typeof stats] += _count;
stats.TOTAL_RECIPIENTS += _count;
stats[signingStatus as keyof typeof stats] += _count;
stats[sendStatus as keyof typeof stats] += _count;
stats[readStatus] += _count;
stats[signingStatus] += _count;
stats[sendStatus] += _count;
stats.TOTAL_RECIPIENTS += _count;
});

View File

@ -1,5 +1,6 @@
import { prisma } from '@documenso/prisma';
import { FieldType, SendStatus, SigningStatus } from '@documenso/prisma/client';
import type { FieldType } from '@documenso/prisma/client';
import { SendStatus, SigningStatus } from '@documenso/prisma/client';
export interface SetFieldsForDocumentOptions {
userId: number;

View File

@ -1,5 +1,5 @@
import { prisma } from '@documenso/prisma';
import { FieldType } from '@documenso/prisma/client';
import type { FieldType } from '@documenso/prisma/client';
export type Field = {
id?: number | null;
@ -32,7 +32,7 @@ export const setFieldsForTemplate = async ({
});
if (!template) {
throw new Error('Document not found');
throw new Error('Template not found');
}
const existingFields = await prisma.field.findMany({
@ -93,8 +93,10 @@ export const setFieldsForTemplate = async ({
},
Recipient: {
connect: {
id: field.signerId,
email: field.signerEmail,
templateId_email: {
templateId,
email: field.signerEmail.toLowerCase(),
},
},
},
},

View File

@ -0,0 +1,12 @@
/*
Warnings:
- Made the column `readStatus` on table `Recipient` required. This step will fail if there are existing NULL values in that column.
- Made the column `signingStatus` on table `Recipient` required. This step will fail if there are existing NULL values in that column.
- Made the column `sendStatus` on table `Recipient` required. This step will fail if there are existing NULL values in that column.
*/
-- AlterTable
ALTER TABLE "Recipient" ALTER COLUMN "readStatus" SET NOT NULL,
ALTER COLUMN "signingStatus" SET NOT NULL,
ALTER COLUMN "sendStatus" SET NOT NULL;

View File

@ -189,9 +189,9 @@ model Recipient {
token String
expired DateTime?
signedAt DateTime?
readStatus ReadStatus? @default(NOT_OPENED)
signingStatus SigningStatus? @default(NOT_SIGNED)
sendStatus SendStatus? @default(NOT_SENT)
readStatus ReadStatus @default(NOT_OPENED)
signingStatus SigningStatus @default(NOT_SIGNED)
sendStatus SendStatus @default(NOT_SENT)
Document Document? @relation(fields: [documentId], references: [id], onDelete: Cascade)
Template Template? @relation(fields: [templateId], references: [id], onDelete: Cascade)
Field Field[]