mirror of
https://github.com/documenso/documenso.git
synced 2025-11-13 08:13:56 +10:00
fix: remove templateToken
This commit is contained in:
@ -86,6 +86,7 @@ export const SinglePlayerClient = () => {
|
||||
data.fields.map((field, i) => ({
|
||||
id: i,
|
||||
documentId: -1,
|
||||
templateId: null,
|
||||
recipientId: -1,
|
||||
type: field.type,
|
||||
page: field.pageNumber,
|
||||
@ -148,10 +149,10 @@ export const SinglePlayerClient = () => {
|
||||
const placeholderRecipient: Recipient = {
|
||||
id: -1,
|
||||
documentId: -1,
|
||||
templateId: null,
|
||||
email: '',
|
||||
name: '',
|
||||
token: '',
|
||||
templateToken: '',
|
||||
expired: null,
|
||||
signedAt: null,
|
||||
readStatus: 'OPENED',
|
||||
|
||||
@ -77,7 +77,6 @@ export const setRecipientsForTemplate = async ({
|
||||
name: recipient.name,
|
||||
email: recipient.email,
|
||||
token: nanoid(),
|
||||
templateToken: nanoid(),
|
||||
templateId,
|
||||
},
|
||||
}),
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import { nanoid } from '@documenso/lib/universal/id';
|
||||
import { prisma } from '@documenso/prisma';
|
||||
import { TCreateDocumentFromTemplateMutationSchema } from '@documenso/trpc/server/template-router/schema';
|
||||
import type { TCreateDocumentFromTemplateMutationSchema } from '@documenso/trpc/server/template-router/schema';
|
||||
|
||||
export type CreateDocumentFromTemplateOptions = TCreateDocumentFromTemplateMutationSchema & {
|
||||
userId: number;
|
||||
@ -41,7 +41,6 @@ export const createDocumentFromTemplate = async ({
|
||||
email: recipient.email,
|
||||
name: recipient.name,
|
||||
token: nanoid(),
|
||||
templateToken: recipient.templateToken,
|
||||
})),
|
||||
},
|
||||
},
|
||||
@ -55,9 +54,7 @@ export const createDocumentFromTemplate = async ({
|
||||
data: template.Field.map((field) => {
|
||||
const recipient = template.Recipient.find((recipient) => recipient.id === field.recipientId);
|
||||
|
||||
const documentRecipient = document.Recipient.find(
|
||||
(doc) => doc.templateToken === recipient?.templateToken,
|
||||
);
|
||||
const documentRecipient = document.Recipient.find((doc) => doc.email === recipient?.email);
|
||||
|
||||
return {
|
||||
type: field.type,
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import { nanoid } from '@documenso/lib/universal/id';
|
||||
import { prisma } from '@documenso/prisma';
|
||||
import { TDuplicateTemplateMutationSchema } from '@documenso/trpc/server/template-router/schema';
|
||||
import type { TDuplicateTemplateMutationSchema } from '@documenso/trpc/server/template-router/schema';
|
||||
|
||||
export type DuplicateTemplateOptions = TDuplicateTemplateMutationSchema & {
|
||||
userId: number;
|
||||
@ -38,7 +38,6 @@ export const duplicateTemplate = async ({ templateId, userId }: DuplicateTemplat
|
||||
email: recipient.email,
|
||||
name: recipient.name,
|
||||
token: nanoid(),
|
||||
templateToken: recipient.templateToken,
|
||||
})),
|
||||
},
|
||||
},
|
||||
@ -53,7 +52,7 @@ export const duplicateTemplate = async ({ templateId, userId }: DuplicateTemplat
|
||||
const recipient = template.Recipient.find((recipient) => recipient.id === field.recipientId);
|
||||
|
||||
const duplicatedTemplateRecipient = duplicatedTemplate.Recipient.find(
|
||||
(doc) => doc.templateToken === recipient?.templateToken,
|
||||
(doc) => doc.email === recipient?.email,
|
||||
);
|
||||
|
||||
return {
|
||||
|
||||
@ -0,0 +1,8 @@
|
||||
/*
|
||||
Warnings:
|
||||
|
||||
- You are about to drop the column `templateToken` on the `Recipient` table. All the data in the column will be lost.
|
||||
|
||||
*/
|
||||
-- AlterTable
|
||||
ALTER TABLE "Recipient" DROP COLUMN "templateToken";
|
||||
@ -188,7 +188,6 @@ model Recipient {
|
||||
email String @db.VarChar(255)
|
||||
name String @default("") @db.VarChar(255)
|
||||
token String
|
||||
templateToken String?
|
||||
expired DateTime?
|
||||
signedAt DateTime?
|
||||
readStatus ReadStatus? @default(NOT_OPENED)
|
||||
@ -272,14 +271,15 @@ enum TemplateType {
|
||||
|
||||
model Template {
|
||||
id Int @id @default(autoincrement())
|
||||
userId Int
|
||||
User User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
||||
title String
|
||||
type TemplateType @default(PRIVATE)
|
||||
title String
|
||||
userId Int
|
||||
templateDocumentDataId String
|
||||
templateDocumentData DocumentData @relation(fields: [templateDocumentDataId], references: [id], onDelete: Cascade)
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @default(now()) @updatedAt
|
||||
|
||||
templateDocumentData DocumentData @relation(fields: [templateDocumentDataId], references: [id], onDelete: Cascade)
|
||||
User User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
||||
Recipient Recipient[]
|
||||
Field Field[]
|
||||
|
||||
|
||||
@ -63,6 +63,7 @@ export const singleplayerRouter = router({
|
||||
// Dummy data.
|
||||
id: -1,
|
||||
documentId: -1,
|
||||
templateId: null,
|
||||
recipientId: -1,
|
||||
});
|
||||
}
|
||||
|
||||
@ -89,7 +89,7 @@ export const AddTemplateFieldsFormPartial = ({
|
||||
signerEmail:
|
||||
recipients.find((recipient) => recipient.id === field.recipientId)?.email ?? '',
|
||||
signerToken:
|
||||
recipients.find((recipient) => recipient.id === field.recipientId)?.templateToken ?? '',
|
||||
recipients.find((recipient) => recipient.id === field.recipientId)?.token ?? '',
|
||||
})),
|
||||
},
|
||||
});
|
||||
@ -187,7 +187,7 @@ export const AddTemplateFieldsFormPartial = ({
|
||||
pageHeight: fieldPageHeight,
|
||||
signerEmail: selectedSigner.email,
|
||||
signerId: selectedSigner.id,
|
||||
signerToken: selectedSigner.templateToken ?? '',
|
||||
signerToken: selectedSigner.token ?? '',
|
||||
});
|
||||
|
||||
setIsFieldWithinBounds(false);
|
||||
|
||||
Reference in New Issue
Block a user