mirror of
https://github.com/documenso/documenso.git
synced 2025-11-19 03:01:59 +10:00
♻️ 🚧 date and text field
This commit is contained in:
@ -46,6 +46,7 @@ async function postHandler(req: NextApiRequest, res: NextApiResponse) {
|
||||
positionX: number;
|
||||
positionY: number;
|
||||
Recipient: { id: number };
|
||||
customText: string;
|
||||
} = req.body;
|
||||
|
||||
if (!user) return;
|
||||
@ -69,6 +70,7 @@ async function postHandler(req: NextApiRequest, res: NextApiResponse) {
|
||||
update: {
|
||||
positionX: +body.positionX,
|
||||
positionY: +body.positionY,
|
||||
customText: body.customText,
|
||||
},
|
||||
create: {
|
||||
documentId: +documentId,
|
||||
@ -76,6 +78,7 @@ async function postHandler(req: NextApiRequest, res: NextApiResponse) {
|
||||
page: +body.page,
|
||||
positionX: +body.positionX,
|
||||
positionY: +body.positionY,
|
||||
customText: body.customText,
|
||||
// todo refactor only one type of recipientId
|
||||
recipientId: body.Recipient.id,
|
||||
},
|
||||
|
||||
@ -71,20 +71,24 @@ async function postHandler(req: NextApiRequest, res: NextApiResponse) {
|
||||
},
|
||||
});
|
||||
|
||||
const dateFields = await prisma.field.findMany({
|
||||
const nonSignatureFields = await prisma.field.findMany({
|
||||
where: {
|
||||
documentId: document.id,
|
||||
type: FieldType.DATE,
|
||||
type: { in: [FieldType.DATE, FieldType.TEXT] },
|
||||
},
|
||||
});
|
||||
|
||||
for (const dateField of dateFields) {
|
||||
// Insert fields other than signatures
|
||||
for (const field of nonSignatureFields) {
|
||||
documentWithInserts = await insertTextInPDF(
|
||||
documentWithInserts,
|
||||
new Date().toDateString(),
|
||||
dateField.positionX,
|
||||
dateField.positionY,
|
||||
dateField.page
|
||||
field.type === FieldType.DATE
|
||||
? new Date().toDateString()
|
||||
: field.customText || "",
|
||||
field.positionX,
|
||||
field.positionY,
|
||||
field.page,
|
||||
false
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user