fix: updates from review
This commit is contained in:
@@ -41,6 +41,7 @@ export const DuplicateDocumentDialog = ({
|
|||||||
trpcReact.document.duplicateDocument.useMutation({
|
trpcReact.document.duplicateDocument.useMutation({
|
||||||
onSuccess: (newId) => {
|
onSuccess: (newId) => {
|
||||||
router.push(`/documents/${newId}`);
|
router.push(`/documents/${newId}`);
|
||||||
|
|
||||||
toast({
|
toast({
|
||||||
title: 'Document Duplicated',
|
title: 'Document Duplicated',
|
||||||
description: 'Your document has been successfully duplicated.',
|
description: 'Your document has been successfully duplicated.',
|
||||||
|
|||||||
@@ -58,11 +58,13 @@ export const TemplatesDataTable = ({
|
|||||||
const { id } = await createDocumentFromTemplate({
|
const { id } = await createDocumentFromTemplate({
|
||||||
templateId,
|
templateId,
|
||||||
});
|
});
|
||||||
|
|
||||||
toast({
|
toast({
|
||||||
title: 'Document created',
|
title: 'Document created',
|
||||||
description: 'Your document has been created from the template successfully.',
|
description: 'Your document has been created from the template successfully.',
|
||||||
duration: 5000,
|
duration: 5000,
|
||||||
});
|
});
|
||||||
|
|
||||||
router.push(`/documents/${id}`);
|
router.push(`/documents/${id}`);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
toast({
|
toast({
|
||||||
|
|||||||
@@ -23,13 +23,13 @@ export const DeleteTemplateDialog = ({ id, open, onOpenChange }: DeleteTemplateD
|
|||||||
|
|
||||||
const { toast } = useToast();
|
const { toast } = useToast();
|
||||||
|
|
||||||
const { mutateAsync: deleteDocument, isLoading } = trpcReact.template.deleteTemplate.useMutation({
|
const { mutateAsync: deleteTemplate, isLoading } = trpcReact.template.deleteTemplate.useMutation({
|
||||||
onSuccess: () => {
|
onSuccess: () => {
|
||||||
router.refresh();
|
router.refresh();
|
||||||
|
|
||||||
toast({
|
toast({
|
||||||
title: 'Template deleted',
|
title: 'Template deleted',
|
||||||
description: 'Your document has been successfully deleted.',
|
description: 'Your template has been successfully deleted.',
|
||||||
duration: 5000,
|
duration: 5000,
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -37,9 +37,9 @@ export const DeleteTemplateDialog = ({ id, open, onOpenChange }: DeleteTemplateD
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const onDraftDelete = async () => {
|
const onDeleteTemplate = async () => {
|
||||||
try {
|
try {
|
||||||
await deleteDocument({ id });
|
await deleteTemplate({ id });
|
||||||
} catch {
|
} catch {
|
||||||
toast({
|
toast({
|
||||||
title: 'Something went wrong',
|
title: 'Something went wrong',
|
||||||
@@ -73,7 +73,7 @@ export const DeleteTemplateDialog = ({ id, open, onOpenChange }: DeleteTemplateD
|
|||||||
Cancel
|
Cancel
|
||||||
</Button>
|
</Button>
|
||||||
|
|
||||||
<Button type="button" loading={isLoading} onClick={onDraftDelete} className="flex-1">
|
<Button type="button" loading={isLoading} onClick={onDeleteTemplate} className="flex-1">
|
||||||
Delete
|
Delete
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -47,8 +47,6 @@ export const DuplicateTemplateDialog = ({
|
|||||||
await duplicateTemplate({
|
await duplicateTemplate({
|
||||||
templateId: id,
|
templateId: id,
|
||||||
});
|
});
|
||||||
|
|
||||||
router.refresh();
|
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
toast({
|
toast({
|
||||||
title: 'Error',
|
title: 'Error',
|
||||||
|
|||||||
@@ -49,10 +49,10 @@ export const NewTemplateDialog = () => {
|
|||||||
const { toast } = useToast();
|
const { toast } = useToast();
|
||||||
|
|
||||||
const form = useForm<TCreateTemplateFormSchema>({
|
const form = useForm<TCreateTemplateFormSchema>({
|
||||||
resolver: zodResolver(ZCreateTemplateFormSchema),
|
|
||||||
defaultValues: {
|
defaultValues: {
|
||||||
name: '',
|
name: '',
|
||||||
},
|
},
|
||||||
|
resolver: zodResolver(ZCreateTemplateFormSchema),
|
||||||
});
|
});
|
||||||
|
|
||||||
const { mutateAsync: createTemplate, isLoading: isCreatingTemplate } =
|
const { mutateAsync: createTemplate, isLoading: isCreatingTemplate } =
|
||||||
|
|||||||
@@ -19,10 +19,11 @@ export const getRecipientsStats = async () => {
|
|||||||
|
|
||||||
results.forEach((result) => {
|
results.forEach((result) => {
|
||||||
const { readStatus, signingStatus, sendStatus, _count } = result;
|
const { readStatus, signingStatus, sendStatus, _count } = result;
|
||||||
stats[readStatus as keyof typeof stats] += _count;
|
|
||||||
stats.TOTAL_RECIPIENTS += _count;
|
stats[readStatus] += _count;
|
||||||
stats[signingStatus as keyof typeof stats] += _count;
|
stats[signingStatus] += _count;
|
||||||
stats[sendStatus as keyof typeof stats] += _count;
|
stats[sendStatus] += _count;
|
||||||
|
|
||||||
stats.TOTAL_RECIPIENTS += _count;
|
stats.TOTAL_RECIPIENTS += _count;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import { prisma } from '@documenso/prisma';
|
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 {
|
export interface SetFieldsForDocumentOptions {
|
||||||
userId: number;
|
userId: number;
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { prisma } from '@documenso/prisma';
|
import { prisma } from '@documenso/prisma';
|
||||||
import { FieldType } from '@documenso/prisma/client';
|
import type { FieldType } from '@documenso/prisma/client';
|
||||||
|
|
||||||
export type Field = {
|
export type Field = {
|
||||||
id?: number | null;
|
id?: number | null;
|
||||||
@@ -32,7 +32,7 @@ export const setFieldsForTemplate = async ({
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (!template) {
|
if (!template) {
|
||||||
throw new Error('Document not found');
|
throw new Error('Template not found');
|
||||||
}
|
}
|
||||||
|
|
||||||
const existingFields = await prisma.field.findMany({
|
const existingFields = await prisma.field.findMany({
|
||||||
@@ -93,8 +93,10 @@ export const setFieldsForTemplate = async ({
|
|||||||
},
|
},
|
||||||
Recipient: {
|
Recipient: {
|
||||||
connect: {
|
connect: {
|
||||||
id: field.signerId,
|
templateId_email: {
|
||||||
email: field.signerEmail,
|
templateId,
|
||||||
|
email: field.signerEmail.toLowerCase(),
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -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;
|
||||||
@@ -189,9 +189,9 @@ model Recipient {
|
|||||||
token String
|
token String
|
||||||
expired DateTime?
|
expired DateTime?
|
||||||
signedAt DateTime?
|
signedAt DateTime?
|
||||||
readStatus ReadStatus? @default(NOT_OPENED)
|
readStatus ReadStatus @default(NOT_OPENED)
|
||||||
signingStatus SigningStatus? @default(NOT_SIGNED)
|
signingStatus SigningStatus @default(NOT_SIGNED)
|
||||||
sendStatus SendStatus? @default(NOT_SENT)
|
sendStatus SendStatus @default(NOT_SENT)
|
||||||
Document Document? @relation(fields: [documentId], references: [id], onDelete: Cascade)
|
Document Document? @relation(fields: [documentId], references: [id], onDelete: Cascade)
|
||||||
Template Template? @relation(fields: [templateId], references: [id], onDelete: Cascade)
|
Template Template? @relation(fields: [templateId], references: [id], onDelete: Cascade)
|
||||||
Field Field[]
|
Field Field[]
|
||||||
|
|||||||
Reference in New Issue
Block a user