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) => ({
|
data.fields.map((field, i) => ({
|
||||||
id: i,
|
id: i,
|
||||||
documentId: -1,
|
documentId: -1,
|
||||||
|
templateId: null,
|
||||||
recipientId: -1,
|
recipientId: -1,
|
||||||
type: field.type,
|
type: field.type,
|
||||||
page: field.pageNumber,
|
page: field.pageNumber,
|
||||||
@ -148,10 +149,10 @@ export const SinglePlayerClient = () => {
|
|||||||
const placeholderRecipient: Recipient = {
|
const placeholderRecipient: Recipient = {
|
||||||
id: -1,
|
id: -1,
|
||||||
documentId: -1,
|
documentId: -1,
|
||||||
|
templateId: null,
|
||||||
email: '',
|
email: '',
|
||||||
name: '',
|
name: '',
|
||||||
token: '',
|
token: '',
|
||||||
templateToken: '',
|
|
||||||
expired: null,
|
expired: null,
|
||||||
signedAt: null,
|
signedAt: null,
|
||||||
readStatus: 'OPENED',
|
readStatus: 'OPENED',
|
||||||
|
|||||||
@ -77,7 +77,6 @@ export const setRecipientsForTemplate = async ({
|
|||||||
name: recipient.name,
|
name: recipient.name,
|
||||||
email: recipient.email,
|
email: recipient.email,
|
||||||
token: nanoid(),
|
token: nanoid(),
|
||||||
templateToken: nanoid(),
|
|
||||||
templateId,
|
templateId,
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
import { nanoid } from '@documenso/lib/universal/id';
|
import { nanoid } from '@documenso/lib/universal/id';
|
||||||
import { prisma } from '@documenso/prisma';
|
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 & {
|
export type CreateDocumentFromTemplateOptions = TCreateDocumentFromTemplateMutationSchema & {
|
||||||
userId: number;
|
userId: number;
|
||||||
@ -41,7 +41,6 @@ export const createDocumentFromTemplate = async ({
|
|||||||
email: recipient.email,
|
email: recipient.email,
|
||||||
name: recipient.name,
|
name: recipient.name,
|
||||||
token: nanoid(),
|
token: nanoid(),
|
||||||
templateToken: recipient.templateToken,
|
|
||||||
})),
|
})),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -55,9 +54,7 @@ export const createDocumentFromTemplate = async ({
|
|||||||
data: template.Field.map((field) => {
|
data: template.Field.map((field) => {
|
||||||
const recipient = template.Recipient.find((recipient) => recipient.id === field.recipientId);
|
const recipient = template.Recipient.find((recipient) => recipient.id === field.recipientId);
|
||||||
|
|
||||||
const documentRecipient = document.Recipient.find(
|
const documentRecipient = document.Recipient.find((doc) => doc.email === recipient?.email);
|
||||||
(doc) => doc.templateToken === recipient?.templateToken,
|
|
||||||
);
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
type: field.type,
|
type: field.type,
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
import { nanoid } from '@documenso/lib/universal/id';
|
import { nanoid } from '@documenso/lib/universal/id';
|
||||||
import { prisma } from '@documenso/prisma';
|
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 & {
|
export type DuplicateTemplateOptions = TDuplicateTemplateMutationSchema & {
|
||||||
userId: number;
|
userId: number;
|
||||||
@ -38,7 +38,6 @@ export const duplicateTemplate = async ({ templateId, userId }: DuplicateTemplat
|
|||||||
email: recipient.email,
|
email: recipient.email,
|
||||||
name: recipient.name,
|
name: recipient.name,
|
||||||
token: nanoid(),
|
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 recipient = template.Recipient.find((recipient) => recipient.id === field.recipientId);
|
||||||
|
|
||||||
const duplicatedTemplateRecipient = duplicatedTemplate.Recipient.find(
|
const duplicatedTemplateRecipient = duplicatedTemplate.Recipient.find(
|
||||||
(doc) => doc.templateToken === recipient?.templateToken,
|
(doc) => doc.email === recipient?.email,
|
||||||
);
|
);
|
||||||
|
|
||||||
return {
|
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)
|
email String @db.VarChar(255)
|
||||||
name String @default("") @db.VarChar(255)
|
name String @default("") @db.VarChar(255)
|
||||||
token String
|
token String
|
||||||
templateToken String?
|
|
||||||
expired DateTime?
|
expired DateTime?
|
||||||
signedAt DateTime?
|
signedAt DateTime?
|
||||||
readStatus ReadStatus? @default(NOT_OPENED)
|
readStatus ReadStatus? @default(NOT_OPENED)
|
||||||
@ -272,14 +271,15 @@ enum TemplateType {
|
|||||||
|
|
||||||
model Template {
|
model Template {
|
||||||
id Int @id @default(autoincrement())
|
id Int @id @default(autoincrement())
|
||||||
userId Int
|
|
||||||
User User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
||||||
title String
|
|
||||||
type TemplateType @default(PRIVATE)
|
type TemplateType @default(PRIVATE)
|
||||||
|
title String
|
||||||
|
userId Int
|
||||||
templateDocumentDataId String
|
templateDocumentDataId String
|
||||||
templateDocumentData DocumentData @relation(fields: [templateDocumentDataId], references: [id], onDelete: Cascade)
|
|
||||||
createdAt DateTime @default(now())
|
createdAt DateTime @default(now())
|
||||||
updatedAt DateTime @default(now()) @updatedAt
|
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[]
|
Recipient Recipient[]
|
||||||
Field Field[]
|
Field Field[]
|
||||||
|
|
||||||
|
|||||||
@ -63,6 +63,7 @@ export const singleplayerRouter = router({
|
|||||||
// Dummy data.
|
// Dummy data.
|
||||||
id: -1,
|
id: -1,
|
||||||
documentId: -1,
|
documentId: -1,
|
||||||
|
templateId: null,
|
||||||
recipientId: -1,
|
recipientId: -1,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@ -89,7 +89,7 @@ export const AddTemplateFieldsFormPartial = ({
|
|||||||
signerEmail:
|
signerEmail:
|
||||||
recipients.find((recipient) => recipient.id === field.recipientId)?.email ?? '',
|
recipients.find((recipient) => recipient.id === field.recipientId)?.email ?? '',
|
||||||
signerToken:
|
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,
|
pageHeight: fieldPageHeight,
|
||||||
signerEmail: selectedSigner.email,
|
signerEmail: selectedSigner.email,
|
||||||
signerId: selectedSigner.id,
|
signerId: selectedSigner.id,
|
||||||
signerToken: selectedSigner.templateToken ?? '',
|
signerToken: selectedSigner.token ?? '',
|
||||||
});
|
});
|
||||||
|
|
||||||
setIsFieldWithinBounds(false);
|
setIsFieldWithinBounds(false);
|
||||||
|
|||||||
Reference in New Issue
Block a user